Introduction
Azure Files offers fully managed cloud file shares that are accessible via the industry-standard Server Message Block (SMB) protocol and Network File System (NFS) protocol. You can mount an Azure Files share to your on-premises or cloud applications, making it a versatile solution for various scenarios like shared configuration files, application settings, or data synchronization.
This guide provides detailed instructions on how to mount an Azure Files share to different operating systems.
Prerequisites
Before you begin, ensure you have the following:
- An Azure subscription.
- An Azure Storage account with a file share created.
- The storage account name and access key, or a Shared Access Signature (SAS). For NFS mounts, you'll need specific permissions and configurations.
Access Keys
Storage account access keys provide full access to your storage account. Treat them with the same level of security as you would any password. Consider using Azure AD authentication or SAS tokens for more granular control.
Mounting on Windows
Mounting an Azure Files share on Windows is straightforward using File Explorer or the command line.
Using File Explorer
- Open File Explorer.
- Right-click on This PC or Computer.
- Select Map network drive....
- Choose a drive letter.
- In the Folder field, enter the UNC path to your Azure Files share in the following format:
\\<storage-account-name>.file.core.windows.net\%lt;file-share-name>
- Check Reconnect at sign-in if you want the drive to be available every time you log in.
- Check Connect using different credentials.
- Click Finish.
- When prompted for credentials, enter the storage account name as the username and the storage account access key as the password.
Using PowerShell
You can also mount the share using PowerShell:
$AccountName = "<storage-account-name>"
$ShareName = "<file-share-name>"
$AccessKey = "<storage-account-access-key>"
$MountDrive = "Z:" # Or any other available drive letter
$UncPath = "\$AccountName.file.core.windows.net\$ShareName"
New-PSDrive -Name $MountDrive.Substring(0,1) -PSProvider FileSystem -Root $UncPath -Persist -Scope Global -Credential (New-Object System.Management.Automation.PSCredential($AccountName, (ConvertTo-SecureString $AccessKey -AsPlainText -Force)))
For better security, consider using Azure AD Kerberos authentication for Azure Files with supported operating systems.
Mounting on Linux
Azure Files can be mounted on Linux using SMB/CIFS. You'll need to install the cifs-utils
package.
Install cifs-utils
On Debian/Ubuntu:
sudo apt update
sudo apt install cifs-utils
On Red Hat/CentOS/Fedora:
sudo yum install cifs-utils
Mounting the Share
- Create a mount point directory:
sudo mkdir /mnt/azure
- Mount the share using the following command, replacing placeholders with your actual details:
sudo mount -t cifs //<storage-account-name>.file.core.windows.net/<file-share-name> /mnt/azure -o vers=3.0,username=<storage-account-name>,password=<storage-account-access-key>,dir_mode=0777,file_mode=0777,serverino
For persistent mounts, add an entry to your /etc/fstab
file:
//<storage-account-name>.file.core.windows.net/<file-share-name> /mnt/azure cifs vers=3.0,username=<storage-account-name>,password=<storage-account-access-key>,dir_mode=0777,file_mode=0777,serverino,_netdev 0 0
Storing credentials directly in fstab
is a security risk. Consider using a credentials file (e.g., ~/.smbcredentials
) and referencing it in fstab
like this: credentials=/path/to/your/.smbcredentials
.
Mounting on macOS
Mounting Azure Files on macOS can be done via Finder or the command line.
Using Finder
- Open Finder.
- Go to Go > Connect to Server... (or press
Cmd+K
). - In the Server Address field, enter the SMB path:
smb://<storage-account-name>.file.core.windows.net/<file-share-name>
- Click Connect.
- You will be prompted to enter credentials. Use the storage account name as the username and the storage account access key as the password.
Using Terminal
You can use the mount_smbfs
command:
mkdir ~/azure_files
mount_smbfs "//<storage-account-name>;<storage-account-access-key>@<storage-account-name>.file.core.windows.net/<file-share-name>" ~/azure_files
You will be prompted for the password (access key).
Troubleshooting
Here are some common issues and their solutions:
- Authentication Failed: Double-check your storage account name, access key, and the exact UNC/SMB path. Ensure your firewall is not blocking SMB traffic (port 445).
- Connection Timed Out: Verify network connectivity. If you're on-premises, ensure your network allows outbound connections to Azure IP ranges on port 445.
- Permissions Errors: Ensure the credentials used have the necessary read/write permissions for the share.
- NFS Mount Issues: NFS mounts require specific Azure Files API versions, network configurations (e.g., NFSv3 enabled), and often a private endpoint for secure access. Refer to Azure's NFS documentation for detailed steps.
Azure Files supports SMB 3.0 and later. Ensure your client OS supports SMB 3.0+ for optimal performance and security.
Next Steps
Once you have successfully mounted your Azure Files share, you can start using it like any other network drive:
- Copy files to and from the share.
- Configure applications to use the mounted path for storage or configuration.
- Explore Azure Files snapshot capabilities for data protection.
- Investigate Azure AD integration for enhanced security and simplified access management.
For more advanced scenarios, such as using NFS shares or integrating with Azure services, please consult the official Azure documentation.