Search code examples
azureazure-worker-rolesazure-files

Access AzureFileStorage share from Worker Role?


I've created an Azure storage account and created a file share and put some files on a directory. I want to access these files from a WorkerRole. Is it possible to set this up so that it survives refreshes of the host cloud server and or worker role?


Solution

  • I solved this issue by going another way.

    In the OnStart() of the WebJob copy the file from the AzureFileShare to a local directory and then access it as a local file.

       var tmpl = access.GetFile("reviewer-stats/templates/","revrStatsVer_2_3.xltx");
          if (!Directory.Exists(@"E:\reports\stat`enter code here`s\templates"))
              Directory.CreateDirectory(@"E:\reports\stats\templates");
          tmpl.DownloadToFile(@"E:\reports\stats\templates\Stats2.xltx",FileMode.Create);
    

    You can find info on info on accessing Azure Files via C# here