How to give RW permissions on a folder in Windows Azure?

asp.net-mvc-3, azure

Solution

For local storage, I wouldn't get caught up with granting access permissions to various directories. Instead, take advantage of the storage resources available specifically to your running VM's. With a given instance size, you have local storage available to you ranging from 20GB to almost 2TB (full sizing details here). To take advantage of this space, you'd create local storage resources within your project:

Then, in code, grab a drive letter to that storage:

var storageRoot = RoleEnvironment.GetLocalResource("moreStorage").RootPath;

Now you're free to use that storage. And... none of that requires any startup tasks or granting of permissions.

Now for the caveat: This is storage that's local to each running instance, and isn't shared between instances. Further, it's non-durable - if the disk crashes, the data is gone.

For persistent, durable file storage, Blob Storage is a much better choice, as it's durable (triple-replicated within the datacenter, and geo-replicated to another datacenter) and it's external to your role instances, accessible from any instance (or any app, including your on-premises apps).

Since blob storage is organized by container, and blobs within container, it's fairly straightforward to organize your blobs (and store pretty much anything in a given blob, up to 200GB each). Also, it's trivial to upload/download files to/from blobs, either to file streams or local files (in the storage resources you allocated, as illustrated above).

Problem

I am deploying an MVC 3.0 web app to Windows Azure. I have an action method that takes a file uploaded by the user and stores it in a folder within my web app. How could I give RW permissions to that folder to the running process? I read about start up tasks and have a basic understanding, but I wouldn't know, - How to give the permission itself, and - Which running process (user) should I give the permission to. Many thanks for the help. EDIT In addition to @David's answer below, I found this link extremely useful: https://www.windowsazure.com/en-us/develop/net/how-to-guides/blob-storage/

Original source