Azure Storage Documentation

Mounting an Azure File Share

Mounting an Azure File Share allows you to access your files directly from your on-premises servers or cloud virtual machines as if it were a local drive. This guide covers the common methods for mounting a file share on Windows and Linux.

Prerequisites

Mounting on Windows

You can mount an Azure File Share on Windows using Server Message Block (SMB) protocol. This can be done via the command line or PowerShell.

Using Command Prompt (cmd.exe)

Open Command Prompt as an administrator and use the net use command:

net use Z: \\yourstorageaccountname.file.core.windows.net\yourfilesharename /u:Azure\yourstorageaccountname yourstorageaccountkey

Using PowerShell

Open PowerShell as an administrator and use the New-PSDrive cmdlet:

New-PSDrive -Name Z -PSProvider FileSystem -Root "\\yourstorageaccountname.file.core.windows.net\yourfilesharename" -Persist -Credential (Get-Credential)

You will be prompted to enter your storage account name and access key as credentials.

Mounting on Linux

Mounting on Linux also uses the SMB protocol. You'll need to install the cifs-utils package first.

Install cifs-utils

For Debian/Ubuntu:

sudo apt update
sudo apt install cifs-utils

For RHEL/CentOS/Fedora:

sudo yum install cifs-utils

Create a Mount Point and Mount

Create a directory where you want to mount the share:

sudo mkdir /mnt/azurefiles

Mount the file share:

sudo mount -t cifs //yourstorageaccountname.file.core.windows.net/yourfilesharename /mnt/azurefiles -o vers=3.0,username=yourstorageaccountname,password=yourstorageaccountkey,dir_mode=0777,file_mode=0777,serverino

Auto-mounting with fstab

To mount the file share automatically on boot, edit your /etc/fstab file:

//yourstorageaccountname.file.core.windows.net/yourfilesharename /mnt/azurefiles cifs vers=3.0,username=yourstorageaccountname,password=yourstorageaccountkey,dir_mode=0777,file_mode=0777,_netdev 0 0

Security Note: Storing credentials directly in fstab is not recommended. Consider using a credentials file with restricted permissions.

Important: Ensure your firewall rules and network security groups allow SMB traffic (TCP port 445) to your Azure File Share.

Troubleshooting

Common issues include incorrect credentials, network connectivity problems, or incorrect SMB version specified.