Developers can mount Azure Files as a directory share in Linux App Service (source code and custom Linux container) as well as Windows container (Preview)
The benefits of custom-mounted storage include:
- Configure persistent storage for your App Service app and manage the storage separately.
- Make static content like video and images readily available for your App Service app.
- Write application log files or archive older application log to Azure File shares.
- Share content across multiple apps or with other Azure services.
Let’s try to understand custom mounted storage benefits listed above using a real-life business scenario explained below:
- Department A of a company uploads images to a file share using a web app hosted on Azure App Services for windows containers.
- Department B of the same company performs actions like watermarking, resizing of the images uploaded by department A using a web app hosted on Azure App Services for Linux.
- Azure SQL and Azure Storage File share are accessible only within the Azure VNET
Diagram below depicts sample deployment architecture for the scenario mentioned above:
Step 1: Create Azure Storage account, Create Azure App services Web App (Windows Container), Create Azure SQL Database, Configure an Azure File Share as a local share for your Web App and Configure Regional VNET integration
- Create an Azure App Services Web App for Windows Container (https://docs.microsoft.com/en-us/azure/app-service/quickstart-custom-container?tabs=dotnet&pivots=container-windows )
- Create an Azure SQL Database (https://docs.microsoft.com/en-us/azure/azure-sql/database/single-database-create-quickstart?tabs=azure-portal )
- Setup Regional VNET Integration for private connectivity between web app and database (https://docs.microsoft.com/en-us/azure/architecture/example-scenario/private-web-app/private-web-app )
- Deploy your web app code to Azure App Services web app for Windows Container created in step 1. Sample Source code for Image Upload Application is available at byosCPUplDwn/byosWinContUpload at master · gsethgit/byosCPUplDwn (github.com) and the sample app is available at https://gsethbyosblogwcont.azurewebsites.net
- Create Azure Storage Account & an Azure Files share and Setup Private Endpoint (https://docs.microsoft.com/en-us/azure/storage/common/storage-private-endpoints )
- Configure Azure Files share created in step 5 as local share for you Image Upload (Windows Container) web app(https://docs.microsoft.com/en-us/azure/app-service/configure-connect-to-azure-storage?tabs=portal&pivots=container-windows )
If you want to use Azure Portal for custom mount configuration then refer to Azure How-To YouTube video which guides you on how to mount custom storage in Azure App services and configure Private endpoint connection between your web app and Azure Storage files mount How to mount Azure Storage as a local share in a container app in App Service | Azure Portal Series - YouTube
You can also mount custom storage for your web app using below mentioned Azure Cli commands:
az webapp config storage-account add --resource-group <group-name> --name <app-name> --custom-id <custom-id> --storage-type AzureFiles --share-name <share-name> --account-name <storage-account-name> --access-key "<access-key>" --mount-path <mount-path-directory>
Verify your configuration by running the following command:
az webapp config storage-account list –resource-group <resource-group> --name <app-name>
*** Please remember that mount path (Azure Portal and Azure Cli) is used to upload content to Azure File share. In case of sample code provided mount path should be same as “uploadPath” App Setting
Step 2: Create Azure App services Web App (Linux) and Configure an Azure File Share as a local share for your Web App
- Create an Azure App Services Web App for Linux (https://docs.microsoft.com/en-us/azure/app-service/quickstart-dotnetcore?tabs=net50&pivots=development-environment-vs )
- Deploy your web app code to Azure App Services web app for Linux created in step 1. Sample Source code for Image Processing Application is available at byosCPUplDwn/byosLinuxImageWTM at master · gsethgit/byosCPUplDwn (github.com) and the sample app is available at https://gsethbyosbloglinux.azurewebsites.net/
- Configure Azure Files share created above as local share for you Image Processing (Linux) web app (https://docs.microsoft.com/en-us/azure/app-service/configure-connect-to-azure-storage?tabs=portal&pivots=container-linux )
*** Mount same Azure File Share for both the web apps for content sharing between these apps
If you want to use Azure Portal for custom mount configuration then refer to Azure How-To YouTube video which guides you on how to mount custom storage in Azure App services and configure Private endpoint connection between your web app and Azure Storage files mount How to mount Azure Storage as a local share in a container app in App Service | Azure Portal Series - YouTube
You can also mount custom storage for your web app using below mentioned Azure Cli commands:
az webapp config storage-account add --resource-group <group-name> --name <app-name> --custom-id <custom-id> --storage-type AzureFiles --share-name <share-name> --account-name <storage-account-name> --access-key "<access-key>" --mount-path <mount-path-directory>
Verify your configuration by running the following command:
az webapp config storage-account list –resource-group <resource-group> --name <app-name>
*** Please remember that mount path (Azure Portal and Azure Cli) is used to upload content to Azure File share. In case of sample code provided mount path should be same as “uploadPath” App Setting
There are many different scenarios that can be enabled using the sample described above and the apps that are producing and consuming the content may be developed in technology of your choice including legacy frameworks enabling wide variety of app dev scenarios on Azure App Services ex: Invoice processing, Image processing, Content publishing to name a few.
As you can see that the content stored on same custom mounted storage can be shared across multiple web apps hosted within Azure App services and even across other Azure services like Azure VMS’s etc. while ensuring secure end to end access to your content across these Azure resources via Azure VNET integration.
Posted at https://bit.ly/3EGJrB9