StorageLesson 8 of 16

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

Azure Files vs Blob Storage

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

ProtocolOSUse When
SMB 3.0Windows, Linux (Samba)Windows VMs, Windows apps, cross-platform shares
NFS 4.1Linux (Premium only)Linux VMs, Linux containers, POSIX workloads
REST APIAnyProgrammatic access without mounting

Commands

Azure CLI
# 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

  1. Create a file share with 5 GB quota in an existing storage account.
  2. Upload a sample config file from CLI.
  3. Mount the share on a Linux VM and verify you can read the file.
  4. Edit the file from inside the VM and verify the change appears in Portal.
  5. 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.

Interview Questions

Beginner

What is Azure Files?

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

Why might SMB 445 not work?

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.

When use Azure Files vs Blob Storage?

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

10 Linux VMs need to share a writable config directory.

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.