Mount Azure Storage as a local share in App Service
Article
Azure Storage is Microsoft's cloud storage solution for modern data storage scenarios. Azure Storage offers highly available, massively scalable, durable, and secure storage for a variety of data objects in the cloud. This guide shows how to mount Azure Storage Files as a network share in Windows code (noncontainer) in App Service. Only Azure Files Shares and Premium Files Shares are supported. Azure Storage is non-default storage for App Service and billed separately. You can also configure Azure Storage in an ARM template.
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 logs to Azure File shares.
Share content across multiple apps or with other Azure services.
The following features are supported for Windows code:
Mount Azure Storage file shares using "/mounts/<path-name>".
Here are the three options to mount Azure storage to your app:
Mounting option
Usage
Basic
Choose this option when mounting storage using the Azure portal. You can use the basic option as long as the storage account isn't using service endpoints, private endpoints, or Azure Key Vault. In this case, the portal gets and stores the access key for you.
Also use this option when you plan to mount storage using the Azure CLI, which requires the access key. Choose this option when using Azure Key Vault to securely store and retrieve access keys. Azure Key Vault has the benefits of storing application secrets centrally and securely with the ability to monitor, administer, and integrate with other Azure services like Azure App Service.
Mapping /mounts, mounts/foo/bar, /, and /mounts/foo.bar/ to custom-mounted storage isn't supported (you can only use /mounts/pathname for mounting custom storage to your web app.)
Storage mounts aren't included in backups. Be sure to follow best practices to back up Azure Storage accounts.
With VNET integration on your app, the mounted drive uses an RFC1918 IP address and not an IP address from your VNET.
Verify your storage is mounted by running the following command:
az webapp config storage-account list --resource-group <resource-group> --name <app-name>
Mounting storage with Key Vault access isn't currently supported by the Azure CLI. Use the portal instead.
Note
Adding, editing, or deleting a storage mount causes the app to be restarted.
Best practices
Azure Storage mounts can be configured as a virtual directory to serve static content. To configure the virtual directory, in the left navigation click Configuration > Path Mappings > New Virtual Application or Directory. Set the Physical path to the Mount path defined on the Azure Storage mount.
To avoid latency issues, place the app and the Azure Storage account in the same region. If you grant access from App Service IP addresses in the Azure Storage firewall configuration when the app and Azure Storage account are in the same region, then these IP restrictions aren't honored.
In the Azure Storage account, avoid regenerating the access key that's used to mount the storage in the app. The storage account contains two different keys. Azure App Services stores Azure storage account key. Use a stepwise approach to ensure that the storage mount remains available to the app during key regeneration. For example, assuming that you used key1 to configure storage mount in your app:
Regenerate key2.
In the storage mount configuration, update the access the key to use the regenerated key2.
Regenerate key1.
If you delete an Azure Storage account, container, or share, remove the corresponding storage mount configuration in the app to avoid possible error scenarios.
The mounted Azure Storage account can be either Standard or Premium performance tier. Based on the app capacity and throughput requirements, choose the appropriate performance tier for the storage account. See the scalability and performance targets for Files.
If your app scales to multiple instances, all the instances connect to the same mounted Azure Storage account. To avoid performance bottlenecks and throughput issues, choose the appropriate performance tier for the storage account.
It isn't recommended to use storage mounts for local databases (such as SQLite) or for any other applications and components that rely on file handles and locks.
If you initiate a storage failover when the storage account is mounted to the app, the mount won't connect until the app is restarted or the storage mount is removed and readded.
When VNET integration is used, ensure app setting, WEBSITE_CONTENTOVERVNET is set to 1 and the following ports are open:
Azure Files: 80 and 445
The mounted Azure Storage account can be either Standard or Premium performance tier. Based on the app capacity and throughput requirements, choose the appropriate performance tier for the storage account. See the scalability and performance targets for Files
Azure Storage is Microsoft's cloud storage solution for modern data storage scenarios. Azure Storage offers highly available, massively scalable, durable, and secure storage for a variety of data objects in the cloud. This guide shows how to mount Azure Storage Files as a network share in a Windows container in App Service. Only Azure Files Shares and Premium Files Shares are supported. Azure Storage is non-default storage for App Service and billed separately. You can also configure Azure Storage in an ARM template.
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.
Here are the three options to mount Azure storage to your app:
Mounting option
Usage
Basic
Choose this option when mounting storage using the Azure portal. You can use the basic option as long as the storage account isn't using service endpoints, private endpoints, or Azure Key Vault. In this case, the portal gets and stores the access key for you.
Also use this option when you plan to mount storage using the Azure CLI, which requires the access key. Choose this option when using Azure Key Vault to securely store and retrieve access keys. Azure Key Vault has the benefits of storing application secrets centrally and securely with the ability to monitor, administer, and integrate with other Azure services like Azure App Service.
From the left navigation, click Configuration > Path Mappings > New Azure Storage Mount.
Configure the storage mount according to the following table. When finished, click OK.
Setting
Description
Name
Name of the mount configuration. Spaces are not allowed.
Configuration options
Select Basic
Storage accounts
Azure Storage account. It must contain an Azure Files share.
Share name
Files share to mount.
Mount path
Directory inside your Windows container that you want to mount. Do not use a root directory ([C-Z]:\ or /) or the home directory ([C-Z]:\home, or /home) as it's not supported.
Deployment slot setting
When checked, the storage mount settings also apply to deployment slots.
Directory inside your Windows container that you want to mount. Don't use a root directory ([C-Z]:\ or /) or the home directory ([C-Z]:\home, or /home) as it isn't supported.
Application settings
Select the app setting that's configured with the Azure Key Vault secret.
Deployment slot setting
When checked, the storage mount settings also apply to deployment slots.
--storage-type must be AzureFiles for Windows containers.
mount-path-directory must be in the form /path/to/dir or [C-Z]:\path\to\dir.
Verify your storage is mounted by running the following command:
az webapp config storage-account list --resource-group <resource-group> --name <app-name>
Mounting storage with Key Vault access isn't currently supported by the Azure CLI. Use the portal instead.
Note
Adding, editing, or deleting a storage mount causes the app to be restarted.
Best practices
To avoid latency issues, place the app and the Azure Storage account in the same region. If you grant access from App Service IP addresses in the Azure Storage firewall configuration when the app and Azure Storage account are in the same region, then these IP restrictions aren't honored.
In the Azure Storage account, avoid regenerating the access key that's used to mount the storage in the app. The storage account contains two different keys. Azure App Services stores Azure storage account key. Use a stepwise approach to ensure that the storage mount remains available to the app during key regeneration. For example, assuming that you used key1 to configure storage mount in your app:
Regenerate key2.
In the storage mount configuration, update the access the key to use the regenerated key2.
Regenerate key1.
If you delete an Azure Storage account, container, or share, remove the corresponding storage mount configuration in the app to avoid possible error scenarios.
The mounted Azure Storage account can be either Standard or Premium performance tier. Based on the app capacity and throughput requirements, choose the appropriate performance tier for the storage account. See the scalability and performance targets for Files.
If your app scales to multiple instances, all the instances connect to the same mounted Azure Storage account. To avoid performance bottlenecks and throughput issues, choose the appropriate performance tier for the storage account.
It isn't recommended to use storage mounts for local databases (such as SQLite) or for any other applications and components that rely on file handles and locks.
Ensure ports 80 and 445 are open when using Azure Files with VNET integration.
If you initiate a storage failover when the storage account is mounted to the app, the mount won't connect until the app is restarted or the storage mount is removed and readded.
NFS support is now available for App Service on Linux.
This guide shows how to mount Azure Storage as a network share in a built-in Linux container or a custom Linux container in App Service. Azure Storage is Microsoft's cloud storage solution for modern data storage scenarios. Azure Storage offers highly available, massively scalable, durable, and secure storage for a variety of data objects in the cloud. Azure Storage is non-default storage for App Service and billed separately. You can also configure Azure Storage in an ARM template.
Benefits
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.
Azure Files NFS and Azure Files SMB are supported.
Azure Blobs (read-only) are supported.
Up to five mount points per app are supported.
Limitations
The limitations of custom-mounted storage include:
Storage account shared access keys are the only means of authentication that are supported; Entra ID and RBAC Roles are not supported.
Azure CLI, Azure PowerShell, and Azure SDK support is in preview.
Mapping / or /home to custom-mounted storage isn't supported.
Don't map the storage mount to /tmp or its subdirectories as this action may cause a timeout during app startup.
Azure Storage isn't supported with Docker Compose scenarios.
Storage mounts aren't included in backups. Be sure to follow best practices to back up the Azure Storage accounts.
NFS support is only available for App Service on Linux. NFS isn't supported for Windows code and Windows containers. The web app and storage account need to be configured on the same VNET for NFS. The storage account used for file share should have "Premium" performance tier and "Filestorage" as the Account Kind. Azure Key Vault is not applicable when using the NFS protocol.
With VNET integration on your app, the mounted drive uses an RFC1918 IP address and not an IP address from your VNET.
Mounting options
You first need to mount the storage to the app. Here are three mounting options for Azure storage:
Mounting option
Usage
Basic
Choose this option when mounting storage using the Azure portal. You can use the basic option as long as the storage account isn't using service endpoints, private endpoints, or Azure Key Vault. In this case, the portal gets and stores the access key for you.
Also use this option when you plan to mount storage using the Azure CLI, which requires the access key. Choose this option when using Azure Key Vault to securely store and retrieve access keys. Azure Key Vault has the benefits of storing application secrets centrally and securely with the ability to monitor, administer, and integrate with other Azure services like Azure App Service.
In the SSH terminal, execute the following command:
df –h
Check if the storage share is mounted. If it's not present, there's an issue with mounting the storage share.
Check latency or general reachability of the storage mount with the following command:
tcpping Storageaccount.file.core.windows.net
Best practices
Performance
To avoid latency issues, place the app and the Azure Storage account in the same region. If you grant access from App Service IP addresses in the Azure Storage firewall configuration when the app and Azure Storage account are in the same region, then these IP restrictions aren't honored.
The mounted Azure Storage account can be either Standard or Premium performance tier. Based on the app capacity and throughput requirements, choose the appropriate performance tier for the storage account. See the scalability and performance targets that correspond to the storage type: Files and Blobs.
If your app scales to multiple instances, all the instances connect to the same mounted Azure Storage account. To avoid performance bottlenecks and throughput issues, choose the appropriate performance tier for the storage account.
Security
In the Azure Storage account, avoid regenerating the access key that's used to mount the storage in the app. The storage account contains two different keys. Azure App Services stores Azure storage account key. Use a stepwise approach to ensure that the storage mount remains available to the app during key regeneration. For example, assuming that you used key1 to configure storage mount in your app:
Regenerate key2.
In the storage mount configuration, update the access the key to use the regenerated key2.
Regenerate key1.
Troubleshooting
The mount directory in the custom container should be empty. Any content stored at this path is deleted when the Azure Storage is mounted (if you specify a directory under /home, for example). If you are migrating files for an existing app, make a backup of the app and its content before you begin.
If you delete an Azure Storage account, container, or share, remove the corresponding storage mount configuration in the app to avoid possible error scenarios.
It isn't recommended to use storage mounts for local databases (such as SQLite) or for any other applications and components that rely on file handles and locks.
Ensure the following ports are open when using VNET integration: Azure Files: 80 and 445. Azure Blobs: 80 and 443.
If you initiate a storage failover when the storage account is mounted to the app, the mount won't connect until the app is restarted or the storage mount is removed and re-added.