I.Manev
I.Manev

Reputation: 727

System.IO Namespace in Azure File Storage

Basically, I have mapped an Azure File Storage as network device and managed to get the following code to work:

public ActionResult Post([FromBody]ConfiguratorApi configuratorApi)
{
    string SourcePath = "Z:\\Skeleton";
    string DestinationPath = "Z:\\TMP";
    return GenerateConfigFiles(configuratorApi, SourcePath, DestinationPath);
}

What this GenerateConfigFiles actually does is coping from the skeleton to tmp folder a certain files and editing some of them(using System.IO), according to the input. What I want to achieve is to deploy the app in Azure as App Service (not VM) and continue using the System.IO. I've tried something like this:

public ActionResult Post([FromBody]ConfiguratorApi configuratorApi)
{

    CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
    CloudFileShare share = fileClient.GetShareReference("config");
    CloudFileDirectory rootDir = share.GetRootDirectoryReference();
    CloudFileDirectory skeletonDir = rootDir.GetDirectoryReference("Skeleton");
    CloudFileDirectory newConfigDir = rootDir.GetDirectoryReference("TMP");


    string SourcePath = skeletonDir.Uri.ToString(); 
    string DestinationPath = newConfigDir.Uri.ToString(); 
    return GenerateConfigFiles(configuratorApi, SourcePath, DestinationPath);
}

and out of that I get

System.NotSupportedException: 'The given path's format is not supported.'

because the paths are like

https://mystoragename.file.core.windows.net/config/Skeleton

Moreover, I went through the web, but most of the posts are fairly old and not relevant anymore. Is this possible at all(maybe by SAS - shared access signature) or I am going in totally wrong direction? I am also open for other solutions.

The folders are not larger than 2MB.

Upvotes: 2

Views: 1208

Answers (1)

Bruce Chen
Bruce Chen

Reputation: 18465

According to your description, the GenerateConfigFiles method is used to copy files based on the path of file system. For hosting your application on Azure Web App, I assume that you could not mount your Azure File share. But you could leverage the storage client library to download files from your share to the temp folder of your web app, then process the files as you need, then save back to your share. For the available directory access under azure web app, you could follow the File System Restrictions/Considerations section under Azure Web App sandbox.

Or you need to host your application to azure cloud service or azure VM, then Mount an Azure File share.

Upvotes: 1

Related Questions