Within Azure App Service, we have the advantage of mounting onto an SMB Azure Files Share for our benefit, providing instant access to large storage that behaves like a local storage folder on our running App Service. This means that users using the Azure Files Share from machines that have it connected as a Networked Drive can get access to files created, edited or manipulated by App Services in our infrastructure.
Mount Azure Files to Local Server
We will assume we have an App Service instance, and an Azure File Share from a storage account that is already connected to our target machine using the following Powershell script (example for Windows here) - which can be found from your the SMB File share in your storage account > Connect > Show Script:
After executing the Powershell script on a target machine, you should see something like the following:
On your target local system, the Azure File share should appear like the following:
Configure Azure Files mount path in App Service
Within the Azure App Service Configuration in settings under PortMapping > Mount Azure Storage, mount the Azure Files Share:
Read and write to Azure Files in Azure App Service
Once the Azure File Share is created, we can have code to write to our Azure File Share as follows simply by referencing the mount path and writing our files there:
To get the image bytes:
The View would be the following, with images as base64 strings for protecting our Azure File Share image paths from the client:
Deploy to Azure App Service, or run locally, visit your site, and you'll observe that the files have been written to the mounted SMB share:
Result
Below is the result shown when we add optional Descriptions to each image with GPT4-o vision capabilities under the Sematic Kernel (Discussed in separate blog), but with our current code, the images would be labelled with their file names: