2

just started testing azure functions to see if it will fit in our application.

What I want is a function like /api/updateToVersion/3.0 where the code will look if there is a folder 3.0 and if there is it will zip the folder and send over as byte[].

But I don't understand where should I keep this folder (which may have multiple files). Azube blob storage (correct me if I am wrong) is for single files. Not folders. I have uploaded folder 3.0 to my microsoft azure storage (in Files shares). How can I access the from my function?

2 Answers 2

3

You can interact with your files using the Azure Storage SDK. Unfortunately, you won't be able to simple mount your Azure File Share within your Azure Function.


However, I would use Azure Blob Storage. Azure Blob Storage uses something like virtual directories where the directory name is part of the filename.

e. g. you have a container named mycontainer you can have files in there like:

/api/updateToVersion/3.0/customers.csv
/api/updateToVersion/3.0/account.txt

Now you can retrieve all files that are within /api/updateToVersion/3.0/ - example:

 var directory = CloudStorageAccount.Parse("yourCs").
    CreateCloudBlobClient().
    GetContainerReference("mycontainer").
    GetDirectoryReference(@"/api/updateToVersion/3.0/");

Finally iterate over the files and zip / send them.

Sign up to request clarification or add additional context in comments.

Comments

2

So after some research I concluded to this:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(webStorageConfigString);
CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
CloudFileShare share = fileClient.GetShareReference("MYFOLDERNAME");
if (!(await share.ExistsAsync()))
  throw new Exception($"No folder found: MYFOLDERNAME");

// Get a reference to the root directory for the share.
CloudFileDirectory rootDir = share.GetRootDirectoryReference();
CloudFileDirectory mcmUpdateDir = rootDir.GetDirectoryReference("OTHER FOLDER");

and so on. I just post it here for others which have the same questions

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.