Create an Azure File Share
Learn how to create an Azure File share using the Azure portal, Azure CLI, or PowerShell.
Introduction
Azure Files offers fully managed cloud file shares that are accessible via the industry-standard Server Message Block (SMB) protocol. You can mount one or more of these shares to your cloud or on-premises applications. Azure Files is designed for cloud scenarios and can be used for:
- Replacing or supplementing on-premises file servers.
- Enabling lift-and-shift application scenarios.
- Providing configuration file shares for cloud applications.
Prerequisites
Before you begin, you need:
- An Azure subscription. If you don't have one, create a free account.
- A storage account. If you don't have one, you can create one through the Azure portal, Azure CLI, or PowerShell.
Steps to Create a File Share
Method 1: Using the Azure Portal
The Azure portal provides a user-friendly graphical interface for managing Azure resources.
- Sign in to the Azure portal.
- In the portal, navigate to your storage account. You can search for "Storage accounts" in the search bar at the top and select your storage account from the list.
- In the storage account menu, under Data storage, select File shares.
- Click the + File share button at the top of the File shares blade.
- A pane will appear. Enter a Name for your file share. Share names must be lowercase letters or numbers, and must start with a letter.
- Specify the Tier for your file share (e.g., Transaction optimized, Hot, Cool).
- Optionally, configure Quota (in GiB) for the share.
- Click Create to create the file share.
Tip
Azure Files shares are created within a storage account. Ensure you select the correct storage account where you want to create the share.
Method 2: Using Azure CLI
The Azure Command-Line Interface (CLI) is a powerful tool for managing Azure resources from the command line.
First, ensure you have the Azure CLI installed and are logged in:
az login
Then, use the following command to create a file share:
az storage share create --name <share-name> --account-name <storage-account-name> --account-key <storage-account-key> --quota <quota-in-gib> --tier <tier-name>
Replace the placeholders:
<share-name>: The name of your file share (e.g.,myshare).<storage-account-name>: The name of your storage account.<storage-account-key>: Your storage account key. You can retrieve this from the Azure portal under your storage account's "Access keys".<quota-in-gib>: The quota for the share in GiB (optional).<tier-name>: The tier for the share (e.g.,TransactionOptimized,Hot,Cool).
Example:
az storage share create --name myfileshare --account-name mystorageaccount --account-key "YOUR_STORAGE_ACCOUNT_KEY" --quota 1024 --tier TransactionOptimized
Note
For security reasons, it's recommended to use managed identities or service principals for authentication in production environments instead of account keys directly in scripts.
Method 3: Using Azure PowerShell
Azure PowerShell provides cmdlets for managing Azure resources.
First, ensure you have the Az PowerShell module installed and are connected to your Azure account:
Connect-AzAccount
Then, use the following cmdlet to create a file share:
New-AzRmStorageShare -ResourceGroupName <resource-group-name> -StorageAccountName <storage-account-name> -Name <share-name> -EnabledProtocol SMB -QuotaGiB <quota-in-gib> -AccessTier <tier-name>
Replace the placeholders:
<resource-group-name>: The name of the resource group your storage account is in.<storage-account-name>: The name of your storage account.<share-name>: The name of your file share (e.g.,myshare).<quota-in-gib>: The quota for the share in GiB (optional).<tier-name>: The tier for the share (e.g.,TransactionOptimized,Hot,Cool).
Example:
New-AzRmStorageShare -ResourceGroupName "myResourceGroup" -StorageAccountName "mystorageaccount" -Name "mypsfileshare" -EnabledProtocol SMB -QuotaGiB 2048 -AccessTier Hot
Next Steps
Once your file share is created, you can:
- Mount the share to your client machines (Windows, Linux, macOS).
- Upload files to the share.
- Configure access tiers and other settings.