iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📂

Mounting Azure Files in Azure Container Apps

に公開

Introduction

This article records my experience mounting an Azure Files volume in Azure Container Apps.
It is a verification of the following article:

https://zenn.dev/georgeosddev/articles/azure-container-apps-container-volumes

Steps

https://learn.microsoft.com/ja-jp/azure/container-apps/storage-mounts?tabs=smb&pivots=azure-resource-manager

Azure Files supports both SMB (Server Message Block) and NFS (Network File System) protocols. You can mount an Azure Files share using either protocol.

It states that both are supported. While the choice depends on requirements, I will use NFS since this ACA uses a custom VNet.

https://techcommunity.microsoft.com/blog/fasttrackforazureblog/azure-container-apps-working-with-storage/3561853

  • For workloads that require fast permanent storage and multiple concurrent small random reads/writes, make sure to go for Azure Files Share Premium tier
  • For apps that write/read large sequential files, Azure Files Share (standard) might be a good option

https://learn.microsoft.com/ja-jp/azure/storage/files/files-smb-protocol?tabs=azure-portal

Common scenarios
SMB file shares are used by many applications for end-user file sharing, and file sharing to back up databases and applications. SMB file shares are often used in the following scenarios:

  • End-user file shares, such as team shares and home directories
  • Backing storage for Windows-based applications (such as SQL Server databases, line-of-business applications created for Win32 or .NET local file system APIs)
  • Developing new applications and services (especially if the application or service has random I/O and hierarchical storage requirements)

https://learn.microsoft.com/ja-jp/azure/storage/files/files-nfs-protocol#common-scenarios

Common scenarios
NFS file shares are often used in the following scenarios:

Backing storage for Linux/UNIX-based applications, such as line-of-business applications written using Linux or POSIX file system APIs (even if POSIX compliance isn't required).
Workloads that require POSIX-compliant file shares, case sensitivity, or Unix-style permissions (UID/GID).
Developing new applications and services (especially if the application or service has random I/O and hierarchical storage requirements).

I asked Copilot which is better, SMB or NFS

Here is a tutorial for using SMB

Creation

Following the documentation, I created a Storage Account with Premium SKU and granted access from the Env's subnet.

  1. Add volume to Env

Env-add-volume

  1. Add mount to App

App-add-mount

Regarding mount options, I referred to the following document and will set them accordingly.

https://learn.microsoft.com/ja-jp/troubleshoot/azure/azure-kubernetes/storage/mountoptions-settings-azure-files

mountOptions:
  - nconnect=4  # improves performance by enabling multiple connections to share
  - noresvport  # improves availability
  - actimeo=30  # reduces latency for metadata-heavy workloads

Immediately, I couldn't start due to a mount error...

Container 'aca-in-vnet-nginx' was terminated with exit code '1' and reason 'VolumeMountFailure'. Shell command exited with non-zero status code. StatusCode = 32 | StdOut = | StdErr = mount.nfs: access denied by server while mounting acastorage2026.file.core.windows.net:/acastorage2026/nginx-share

log-mount-error

The solution was written here.

https://azureossd.github.io/2025/10/17/Setting-up-a-NFS-volume-with-Azure-Container-Apps/#remove-secure-transfer-required

Remove “Secure Transfer Required”
On the Storage Accountt, go to Settings > Configuration and disable Secure transfer required. If this is not done, you’ll see a volume mount failure later on with a message of mount.nfs: access denied by server while mounting in Container App system logs

Since it's also stated as below, I'll try disabling it for now.

https://learn.microsoft.com/ja-jp/azure/storage/common/storage-require-secure-transfer

We recommend requiring secure transfer for all storage accounts, except when NFS Azure file shares are used with network-level security.

storage-disable-secure-transfer

The mount was successful, and the container started.

app-mount-ok

Verification from another replica

As expected, it is mounted, and file sharing is confirmed.

check from other replica

Trying subPath

A subpath is a path relative to the volume root. Do not start a subpath with /. Specifying a subpath that starts with / may cause the Container App to not start. For example, my-volume-folder is a valid subpath, but /my-volume-folder is not.
A subpath can refer to a folder or a file within the volume.

  • If the subpath refers to a folder, the mount path must refer to an empty folder in the container.
  • If the subpath refers to a file, the mount path must refer to a file that does not yet exist in the container.
    For example, assume a subpath my-volume-folder/my-volume-file.txt and a mount path /my-container-folder/my-container-file. The folder /my-container-folder must already exist in the container, but it should not yet contain the file my-container-file.txt.
    The system ignores subpaths with a trailing slash.

subPath itself is a Kubernetes mechanism, but the documentation is unclear, so I'll try it out.

As a preliminary step, using the mount from earlier, I'll prepare files and directories on Azure Files as follows:

root@aca-in-vnet-nginx--0000012-5cc9d54bcf-5lqbw:/azurefiles# tree
.
|-- subDir1
|   `-- ORIGINAL_PATH_IS_SUBDIR1.txt
|-- subDir2
|   |-- ORIGINAL_PATH_IS_SUBDIR2.txt
|   `-- subDir2File1.txt
|-- subDir3
|   |-- ORIGINAL_PATH_IS_SUBDIR3.txt
|   `-- subDir31
|       |-- ORIGINAL_PATH_IS_SUBDIR31.txt
|       `-- subDir31File1.txt
`-- testFromApp.txt

5 directories, 7 files

I'll try mounting each with a specified subPath.

subPath-setting

Results

subPath-verify

This means it's likely that you can also specify subdirectories and files for mounting.

This description seems to be the source of confusion.

For example, assume a subpath my-volume-folder/my-volume-file.txt and a mount path /my-container-folder/my-container-file. The folder /my-container-folder must already exist in the container, but it should not yet contain the file my-container-file.txt.

I think something is wrong because .txt is missing.

It should probably correctly state: "...and a mount path /my-container-folder/my-container-file.txt."

I've submitted a PR.

Discussion

This usage is similar to App Service mounts.

Other

Troubleshooting articles regarding mounting:

Discussion