Azure File Storage
Azure Files provides fully managed cloud file shares accessible over SMB (Windows) and NFS (Linux). Mount them on VMs, on-premises machines, or containers — works like a regular network drive.
Simple Explanation
Azure Files is like a USB drive in the cloud that many computers can plug into simultaneously. You mount it as a network drive (SMB) or filesystem path (NFS), and apps see it as a normal folder.
When to Use Azure Files
- Lift-and-shift of on-premises apps that use UNC file paths.
- Shared configuration files or application settings across multiple VMs.
- Persistent storage volume for containers (AKS, ACI persistent volumes).
- Cross-platform shared storage (Windows + Linux VMs sharing the same share).
Use Azure Files when you need traditional file system semantics (directories, file locking, SMB/NFS mount). Use Blob Storage when you're storing objects accessed via an HTTP API. Blobs are cheaper and scale limitlessly; Files are more compatible with legacy apps.
Protocols
| Protocol | OS | Use When |
|---|---|---|
| SMB 3.0 | Windows, Linux (Samba) | Windows VMs, Windows apps, cross-platform shares |
| NFS 4.1 | Linux (Premium only) | Linux VMs, Linux containers, POSIX workloads |
| REST API | Any | Programmatic access without mounting |
Commands
# Create a file share (5 GB quota) az storage share create \ --account-name mystorageacct \ --name myfileshare \ --quota 5 # Upload a file az storage file upload \ --account-name mystorageacct \ --share-name myfileshare \ --source ./config.yml \ --path config.yml # List files in share az storage file list \ --account-name mystorageacct \ --share-name myfileshare \ --output table # Mount on Linux VM (SMB) # Get storage account key first ACCOUNT_KEY=$(az storage account keys list \ --resource-group rg-storage \ --account-name mystorageacct \ --query "[0].value" --output tsv) sudo mkdir /mnt/myfileshare sudo mount -t cifs \ //mystorageacct.file.core.windows.net/myfileshare \ /mnt/myfileshare \ -o vers=3.0,username=mystorageacct,password=$ACCOUNT_KEY,dir_mode=0777,file_mode=0777 # Make mount persistent (add to /etc/fstab) echo "//mystorageacct.file.core.windows.net/myfileshare /mnt/myfileshare cifs vers=3.0,username=mystorageacct,password=$ACCOUNT_KEY,dir_mode=0777,file_mode=0777" >> /etc/fstab
Azure File Sync
Azure File Sync extends Azure Files to on-premises servers — synchronizing file shares bidirectionally. On-prem servers cache hot files locally; cold files are tiered to the cloud. Great for offices with slow WAN but needing cloud backup.
Hands-on
- Create a file share with 5 GB quota in an existing storage account.
- Upload a sample config file from CLI.
- Mount the share on a Linux VM and verify you can read the file.
- Edit the file from inside the VM and verify the change appears in Portal.
- Explore the "Connect" button in Portal — it auto-generates the mount command for Windows/Linux/macOS.
Debugging Scenario
Issue: SMB mount fails with mount error(13): Permission denied.
- Verify the storage account key is correct and current.
- Check NSG outbound rules — SMB uses port 445, which many ISPs/enterprises block.
- If port 445 is blocked, use Azure File Sync or access via REST API instead.
- For enterprise environments, configure a private endpoint so SMB traffic stays on the VNet (no need for port 445 on public internet).
Interview Questions
Beginner
A fully managed cloud file share service that supports SMB and NFS protocols. You can mount it on VMs, containers, and on-premises machines like a regular network drive.
Intermediate
Many ISPs and firewalls block port 445 as a security measure due to historical SMB exploits. Use a VNet private endpoint to keep traffic private and avoid operating over the public internet.
Azure Files when the app needs filesystem semantics (file locking, directory traversal, mount via SMB/NFS). Blob Storage for HTTP-accessible objects at unlimited scale where filesystem semantics are not needed.
Scenario-based
Create an Azure NFS 4.1 file share (Premium storage account) and mount it on all VMs. They all read/write the same filesystem namespace. Use private endpoint for security.
Summary
Azure Files is the cloud equivalent of an on-premises file server — mountable over SMB or NFS, compatible with legacy apps, and shareable across multiple VMs and containers. For modern apps, prefer Blob Storage; for legacy or lift-and-shift, Azure Files is the right choice.