Azure Storage Documentation

Comprehensive guides and API references for Azure Storage services.

Azure Files Operations

This document details common operations and best practices when working with Azure Files, a fully managed cloud file share service that is accessible via the industry-standard Server Message Block (SMB) protocol and Network File System (NFS) protocol.

Understanding Azure Files Shares

Azure Files offers fully managed cloud file shares that are accessible from multiple cloud or on-premises deployments. The files shares can be mounted concurrently by the cloud or on-premises Windows, Linux, and macOS operating systems. You can also use Azure File Sync to cache frequently accessed files on-premises for faster local access.

Key Concepts:

Common Operations

Creating a File Share

You can create a file share using the Azure portal, Azure CLI, Azure PowerShell, or client libraries.

Using Azure CLI:
# Create a storage account if you don't have one
az storage account create \
    --name mystorageaccount \
    --resource-group myresourcegroup \
    --sku Standard_LRS \
    --kind StorageV2

# Create a file share
az storage share create \
    --name myshare \
    --account-name mystorageaccount \
    --quota 1024 # in GiB

Mounting a File Share

Mounting allows you to access the file share as a local drive or directory.

Mounting with SMB (Windows):

Use the net use command with your storage account name and a generated access key. The access key can be found in the Azure portal under your storage account's "Access keys" section.

net use Z: \\mystorageaccount.file.core.windows.net\myshare /u:Azure\YourStorageAccountName YourStorageAccountKey
Mounting with SMB (Linux):

Install the cifs-utils package and then use the mount command.

sudo apt-get update && sudo apt-get install cifs-utils
sudo mount -t cifs \\YourStorageAccountName.file.core.windows.net\YourShareName /mnt/mymountpoint -o vers=3.0,username=YourStorageAccountName,password=YourStorageAccountKey,dir_mode=0777,file_mode=0777,serverino
Mounting with NFS (Linux):

Ensure your storage account has an NFSv4.1-enabled premium file share. You will need the NFS client installed.

sudo mount -o sec=sys,vers=4.1 YourStorageAccountName.nfs.core.windows.net:/YourStorageAccountName/YourShareName /mnt/mynfsmountpoint

Managing Files and Directories

Standard file system operations like creating, copying, moving, and deleting files and directories are supported.

Using Azure CLI:
# List files
az storage blob list \
    --account-name mystorageaccount \
    --share-name myshare \
    --output table

# Upload a file
az storage blob upload \
    --account-name mystorageaccount \
    --share-name myshare \
    --file /path/to/local/file.txt \
    --name remote/file.txt

# Download a file
az storage blob download \
    --account-name mystorageaccount \
    --share-name myshare \
    --name remote/file.txt \
    --file /path/to/download/file.txt

Permissions and Access Control

Azure Files supports several methods for securing access:

Note: For production environments, it is highly recommended to use Azure AD integration for SMB access and restrict network access using firewalls or private endpoints instead of relying solely on storage account access keys.

Performance Considerations

The performance of your Azure Files shares depends on several factors, including:

Best Practices for Performance:

Integration with Azure File Sync

Azure File Sync enables you to centralize your organization's file shares in Azure Files while keeping the flexibility, performance, and compatibility of an on-premises file server. It transforms Windows Servers into a fast cache of your cloud data.

Key Features of Azure File Sync:

Tip: For workloads requiring local caching and distributed access, consider integrating Azure Files with Azure File Sync.

Monitoring and Troubleshooting

Azure Monitor provides comprehensive metrics and logs for your Azure Files shares. You can track IOPS, throughput, latency, and error rates. For troubleshooting, review these metrics and consider enabling diagnostic logs.

Common Issues:

Warning: Incorrectly configured network security rules can prevent access to your file shares. Always test connectivity after making changes.

Next Steps

Explore the following resources to deepen your understanding and implementation of Azure Files: