0
0
Azurecloud~5 mins

File shares (Azure Files) - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes you need to share files between different computers or services in the cloud. Azure Files lets you create a shared folder in the cloud that many users or apps can access like a normal network drive.
When you want multiple virtual machines to access the same files without copying them.
When you need a simple way to share documents or backups across cloud services.
When you want to replace on-premises file servers with a cloud solution.
When you want to mount a shared folder on Windows, Linux, or macOS machines.
When you need a secure, managed file share accessible over SMB or REST.
Config File - azure-file-share.json
azure-file-share.json
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2022-09-01",
      "name": "examplestorageacct",
      "location": "eastus",
      "sku": {
        "name": "Standard_LRS"
      },
      "kind": "StorageV2",
      "properties": {}
    },
    {
      "type": "Microsoft.Storage/storageAccounts/fileServices/shares",
      "apiVersion": "2022-09-01",
      "name": "examplestorageacct/default/myfileshare",
      "dependsOn": [
        "Microsoft.Storage/storageAccounts/examplestorageacct"
      ],
      "properties": {
        "shareQuota": 100
      }
    }
  ]
}

This JSON is an Azure Resource Manager (ARM) template that creates a storage account named examplestorageacct in the East US region. It uses the Standard_LRS SKU for locally redundant storage. Then it creates a file share named myfileshare inside the default file service of that storage account. The share quota is set to 100 GB, which limits the maximum size of the share.

This template can be deployed to Azure to set up the storage and file share automatically.

Commands
This command creates a new Azure Storage account named examplestorageacct in the example-rg resource group located in East US. The StorageV2 kind supports file shares.
Terminal
az storage account create --name examplestorageacct --resource-group example-rg --location eastus --sku Standard_LRS --kind StorageV2
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/Microsoft.Storage/storageAccounts/examplestorageacct", "location": "eastus", "name": "examplestorageacct", "resourceGroup": "example-rg", "sku": { "name": "Standard_LRS" }, "kind": "StorageV2", "statusOfPrimary": "available" }
--sku - Defines the storage replication type and performance tier
--kind - Specifies the storage account type supporting file shares
This command creates a file share named myfileshare inside the examplestorageacct storage account with a quota of 100 GB.
Terminal
az storage share create --account-name examplestorageacct --name myfileshare --quota 100
Expected OutputExpected
True
--quota - Sets the maximum size of the file share in GB
This command lists all file shares in the examplestorageacct storage account to verify that myfileshare was created.
Terminal
az storage share list --account-name examplestorageacct
Expected OutputExpected
[ { "name": "myfileshare", "properties": { "quota": 100, "lastModified": "2024-06-01T12:00:00Z", "etag": "0x8D123456789ABC" } } ]
This command deletes the myfileshare file share from the storage account when you no longer need it.
Terminal
az storage share delete --account-name examplestorageacct --name myfileshare
Expected OutputExpected
No output (command runs silently)
Key Concept

If you remember nothing else from this pattern, remember: Azure Files lets you create a cloud folder that many machines can use like a shared network drive.

Common Mistakes
Trying to create a file share before the storage account exists
The file share depends on the storage account, so it cannot be created first.
Always create the storage account first, then create the file share inside it.
Not specifying the storage account name correctly in commands
Commands fail because they cannot find the storage account without the exact name.
Use the exact storage account name consistently in all commands.
Setting a quota too small or forgetting to set it
The share might run out of space or default to a small size limiting usage.
Set a quota that fits your expected storage needs when creating the share.
Summary
Create a storage account first to hold your file shares.
Create a file share inside the storage account with a set quota.
List file shares to verify creation and delete when no longer needed.