Reputation: 1138
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?
Upvotes: 2
Views: 1268
Reputation: 1138
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
Upvotes: 2
Reputation: 58961
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.
Upvotes: 3