Azure File Storage Documentation

How to Use Azure File Storage

Azure Files offers fully managed cloud file shares that are accessible via the industry-standard Server Message Block (SMB) protocol. This means you can "lift and shift" legacy applications that rely on file shares to Azure without significant code changes.

Key Features and Benefits

Getting Started with Azure Files

1. Create an Azure Storage Account

A storage account is the fundamental building block for Azure Files. If you don't have one, you can create it through the Azure portal, Azure CLI, or PowerShell.

Using Azure CLI:

az storage account create \
    --name mystorageaccount \
    --resource-group myresourcegroup \
    --location westus \
    --sku Standard_LRS \
    --kind StorageV2
        

2. Create a File Share

Once your storage account is ready, you can create a file share within it. File shares are organized into directories and files.

Using Azure CLI:

az storage share create \
    --name myshare \
    --account-name mystorageaccount \
    --quota 1024 \
    --output none
        

This command creates a file share named myshare with a quota of 1024 GiB.

3. Mount the File Share

Mounting allows you to access the file share from your client machines as if it were a local drive or directory.

Mounting on Windows:

You can mount an Azure File share using the net use command. You'll need your storage account name and one of its access keys.

net use Z: \\mystorageaccount.file.core.windows.net\myshare /u:AZURE\mystorageaccount YourStorageAccountKey
        

Replace Z: with your desired drive letter, mystorageaccount with your storage account name, and YourStorageAccountKey with your storage account key.

Mounting on Linux:

For Linux, you'll typically use the mount command with the cifs-utils package installed.

sudo apt-get update
        sudo apt-get install cifs-utils
        sudo mount -t cifs //mystorageaccount.file.core.windows.net/myshare /mnt/myshare -o vers=3.0,username=mystorageaccount,password=YourStorageAccountKey,dir_mode=0777,file_mode=0777,serverino
        

Ensure you have a mount point directory (e.g., /mnt/myshare) created.

Mounting on macOS:

Similar to Windows, macOS can mount SMB shares.

open smb://mystorageaccount.file.core.windows.net/myshare
        

You will be prompted for credentials.

4. Upload and Download Files

Once mounted, you can interact with the file share using standard file operations (copy, move, delete, etc.).

Using Azure CLI:

az storage file upload \
    --share-name myshare \
    --account-name mystorageaccount \
    --source /path/to/local/file.txt \
    --path /remote/path/file.txt
        
az storage file download \
    --share-name myshare \
    --account-name mystorageaccount \
    --name /remote/path/file.txt \
    --file /path/to/save/file.txt
        

Advanced Concepts

Explore the full range of Azure Files capabilities.

View API Reference