Manage Azure File Shares

This document provides guidance on managing Azure File Shares, including operations like creating, deleting, listing, and configuring shares.

Select Language:

Understanding Azure File Shares

Azure Files offers fully managed cloud file shares that are accessible via the industry-standard Server Message Block (SMB) protocol. You can mount these shares simultaneously from cloud or on-premises Windows, macOS, and Linux deployments. Azure Files is often used for:

Key Management Operations

Creating a File Share

File shares are created within a storage account. You can create a file share using the Azure portal, Azure CLI, Azure PowerShell, or the Storage REST API.

Using Azure CLI:


az storage share create \
    --name myfileshare \
    --account-name mystorageaccount \
    --account-key YOUR_ACCOUNT_KEY \
    --quota 1024 \
    --output table
        

Tip: The --quota parameter specifies the maximum size of the share in GiB. Default is 5 TiB.

Listing File Shares

You can retrieve a list of all file shares within a storage account.

Using Azure CLI:


az storage share list \
    --account-name mystorageaccount \
    --account-key YOUR_ACCOUNT_KEY \
    --output table
        

Accessing a File Share

To access files and directories within a share, you'll need to mount the share using SMB. The process varies slightly depending on your operating system.

Mounting with Windows

Use the following PowerShell command:


New-PSDrive -Name Z -PSProvider FileSystem -Root "\\mystorageaccount.file.core.windows.net\myfileshare" -Persist
        

You will be prompted for your storage account name and key.

Mounting with Linux

Install the cifs-utils package and use the mount command:


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

Deleting a File Share

Deleting a file share is a destructive operation. All data within the share will be permanently lost.

Using Azure CLI:


az storage share delete \
    --name myfileshare \
    --account-name mystorageaccount \
    --account-key YOUR_ACCOUNT_KEY
        

Warning: Ensure you have backed up any critical data before deleting a file share.

Advanced Management Features

Setting Share Quotas and Limits

You can configure the maximum size (quota) for a file share. This helps in managing costs and preventing runaway consumption.

When creating or updating a share, use the --quota parameter (in GiB).

Configuring Access Tiers

Azure Files supports standard tiers (transaction optimized, hot, cool) and premium tier. These tiers affect performance and cost. The tier is typically set at the storage account level but can influence share behavior.

Permissions and Access Control

Azure Files supports NTFS ACLs for fine-grained access control within a share. You can manage these permissions using standard Windows tools or programmatically.