Skip to main content

Configuring Azure Files for Shared Network Storage

Create an Azure Files share, mount it over SMB on two Linux VMs, and prove both see the same file. Covers port 445, keys, and quota.

Overview and What You Will Learn

Azure Files provides fully managed file shares that many machines can mount at the same time over the standard SMB or NFS protocols, just like a traditional network drive. In this lab, you will create a share, mount it over SMB on two Linux VMs, write a file from one VM, and confirm the other VM sees the same file.

Why This Matters in Production

A shared mount gives every server one authoritative copy of the files they all need. An engineering team at Swiggy might have several application servers reading the same configuration files, and copying those files onto each VM's local disk is error-prone. One server gets the update, another does not, and the two start behaving differently. Azure Files gives every VM a single location to read and write.

Core Principles

A file share lives inside a storage account, not on any single VM, so it outlives the machines that mount it. Existing applications that expect a mapped drive usually need no code changes, because SMB is the same protocol an on-premises file server uses.

flowchart TD A[VM A
writes config] -->|SMB 445| S[(Azure Files share
shared-configs)] B[VM B
reads config] -->|SMB 445| S S --- ACC[Storage account
stfileslabrahul2026] classDef vm fill:#326CE5,color:#FFFFFF classDef share fill:#10B981,color:#FFFFFF classDef acct fill:#475569,color:#FFFFFF class A,B vm class S share class ACC acct

Choose the storage type by how it will be accessed:

Option Mounted by many VMs? Access method
Azure Files Yes SMB or NFS
Blob Storage Only via BlobFuse or NFS 3.0 REST object API
Managed Disk One VM by default Block device
Remember

SMB uses TCP port 445. Azure VMs can reach it freely, but many home and corporate networks block outbound 445, so mounting from outside Azure needs a VPN, ExpressRoute, or Azure File Sync.

Detailed Step-by-Step Practical Lab

How to Create the Storage Account and File Share

Storage account names are globally unique, so change the suffix if yours is taken. The share is created through Azure Resource Manager, so no key is needed for this step.

Bash
export RG="rg-files-lab-mumbai"
export SA="stfileslabrahul2026"
az group create --name $RG --location centralindia
az storage account create \
--name $SA \
--resource-group $RG \
--location centralindia \
--sku Standard_LRS \
--min-tls-version TLS1_2
az storage share-rm create \
--storage-account $SA \
--resource-group $RG \
--name shared-configs \
--quota 10

How to Create Two Linux VMs

The mount commands run on VMs, so create two small ones. The --nsg-rule NONE flag skips the default SSH rule, because you will drive the VMs with az vm run-command and never need inbound access.

Bash
for n in a b; do
az vm create \
--resource-group $RG \
--name vm-files-$n \
--image Ubuntu2204 \
--size Standard_B1s \
--admin-username azureadmin \
--generate-ssh-keys \
--nsg-rule NONE \
--output none
done

How to Mount an Azure Files Share over SMB

Fetch the storage account key and build a mount script. The script stores the credentials in a root-only file, so the key does not appear on the mount command line.

Bash
KEY=$(az storage account keys list \
--account-name $SA \
--resource-group $RG \
--query "[0].value" --output tsv)
MOUNT_SCRIPT="cloud-init status --wait || true
apt-get update -y && apt-get install -y cifs-utils
mkdir -p /mnt/shared-configs /etc/smbcredentials
printf 'username=$SA\npassword=$KEY\n' > /etc/smbcredentials/$SA.cred
chmod 600 /etc/smbcredentials/$SA.cred
mount -t cifs //$SA.file.core.windows.net/shared-configs /mnt/shared-configs \
-o credentials=/etc/smbcredentials/$SA.cred,vers=3.1.1,serverino,file_mode=0664,dir_mode=0775
df -h /mnt/shared-configs"
for n in a b; do
az vm run-command invoke \
--resource-group $RG \
--name vm-files-$n \
--command-id RunShellScript \
--scripts "$MOUNT_SCRIPT" \
--query "value[0].message" --output tsv
done
Security

az vm run-command leaves the script, including the key, on the VM's disk. That is acceptable for a throwaway lab, but never do it for real servers. Use Azure Key Vault to hold the key, or switch to identity-based authentication.

How to Write From One VM and Read From Another

Write a file from VM A, then read it from VM B, which mounted the same share separately.

Bash
az vm run-command invoke \
--resource-group $RG \
--name vm-files-a \
--command-id RunShellScript \
--scripts "echo 'shared config value' | tee /mnt/shared-configs/app-config.txt" \
--query "value[0].message" --output tsv
az vm run-command invoke \
--resource-group $RG \
--name vm-files-b \
--command-id RunShellScript \
--scripts "cat /mnt/shared-configs/app-config.txt" \
--query "value[0].message" --output tsv

How to Verify the File From Outside the VMs

List the share's contents directly from Cloud Shell to prove the file lives in the share, not on either VM's disk.

Bash
az storage file list \
--account-name $SA \
--account-key "$KEY" \
--share-name shared-configs \
--output table

How to Clean Up

Deleting the resource group removes the VMs, their disks, and the storage account together.

Bash
az group delete --name $RG --yes --no-wait

Production Best Practices & Common Pitfalls

Common Mistake

Trying to give many VMs shared access through Blob Storage when the requirement is a real mountable file share. Blob Storage is an object store, and Azure Files exists for exactly this shared-mount case.

Tip

Never put the storage key on a command line or in a script that lands in shell history. Keep it in Azure Key Vault and fetch it at mount time, and use a root-only credentials file with chmod 600 as in this lab.

  • Use Azure Files for multi-reader, multi-writer data. If only one VM ever touches the data, a Managed Disk is usually simpler and cheaper.
  • Mount with vers=3.1.1 or vers=3.0. SMB 3.x encrypts data in transit, and Azure rejects unencrypted mounts when secure transfer is required.
  • Add nofail for persistent mounts. When you copy this mount into /etc/fstab, include nofail so a temporary storage problem does not stop the VM from booting.
  • Plan the quota, but know what it costs. On Standard shares you pay for used capacity, so the quota is only a ceiling that you can raise later. On Premium shares you pay for the provisioned size instead.
  • Expect a short metadata cache. Clients cache file attributes briefly, so a file written on one VM can take a moment to show up on another.
  • Restrict network access. Use a private endpoint or service endpoint so only your VNet can reach the share, and prefer identity-based authentication for SMB where your setup supports it.

Quick Reference & Troubleshooting Commands

Command Description
az storage share-rm create Create a share through Resource Manager
az storage share-rm list --storage-account NAME List shares on an account
az storage account keys list Retrieve a key for mounting
mount -t cifs //ACCOUNT.file.core.windows.net/SHARE /mnt/PATH Mount the share over SMB on Linux
az storage file list --share-name SHARE List files in a share from outside the VMs
az vm run-command invoke --command-id RunShellScript Run a script on a VM without SSH

Explore More in Azure Storage Solutions

All 6 Topics

Frequently Asked Questions

Is Configuring Azure Files for Shared Network Storage free to learn on DevOps Network?

Yes - this topic, like everything on DevOps Network, is 100% free with no paywall or sign-up gate.

What does the Configuring Azure Files for Shared Network Storage topic cover?

Create an Azure Files share, mount it over SMB on two Linux VMs, and prove both see the same file. Covers port 445, keys, and quota.

Found a mistake, an outdated step or a broken link?