For local storage, I would not catch the granting of permissions to access various directories. Instead, take advantage of the storage resources available specifically for your running virtual machines. For a given instance size, you have local storage available to you from 20 GB to almost 2 TB (detailed size information here ). To take advantage of this space, you must create local storage resources in your project:
Then in the code, take the drive letter for this storage:
var storageRoot = RoleEnvironment.GetLocalResource("moreStorage").RootPath;
Now you can use this storage. And ... none of this requires any launch or permission tasks.
Now for the caveat: this is a repository local to each running instance, and not shared between instances. In addition, it is not durable - if the disk fails, the data disappears.
For permanent and long-term storage of files, Blob Storage is a much better choice because it is durable (replicated three times in the data center and geo-replicated to another data center) and is external to your role instances, accessible from any instance (or any application, including your local applications).
Since the blob storage is organized by the container and drops in the container, itβs quite simple to organize your drops (and store almost anything in this blob, up to 200 GB each). In addition, it is trivial to upload / download files to / from blocks, either to file streams or to local files (in the storage resources you have allocated, as shown above).
source share