How to Create an Azure File Share

Azure File Service offers managed file shares in the cloud that are accessible via the standard Server Message Block (SMB) protocol. This allows you to create one or more files shared in the cloud and use the share as a normal Windows file server. In this post, I want to show you how to create an Azure file share using PowerShell and the Azure CLI.

Common use cases for the Azure file share are:

  • Replace or supplement local file servers.
  • Repository for the application logs.
  • Use Azure File Sync to Replicate data on-premises and the Azure File Service.

Prerequisites

  • This tutorial assumes that you already have a Microsoft Azure account configured.
  • You created a Resource Group for these resources and the new ones deployed in this tutorial will join that group. If you want to know how to create a Resource Group, check out this link.
  • You can use an existing Storage Account, or you can create a new one. If you want to know how to create a Storage Account using PowerShell, check out this link.

Azure PowerShell Workaround

If you want to know how to install the PowerShell Azure module on your machine, check out this link.

The simplest way to get started is to sign in interactively at the command line.

This cmdlet will bring up a dialog box prompting you for your email address and password associated with your Azure account.
If you have more than one subscription associated with your mail account, you can choose the default subscription. To perform this task, we will use the following commands:

Once you set your default subscription, you’re ready to start.

Set the variables

Here, we define the characteristics of our environment and the resource’s properties.

Get-AzStorageAccountKey

To create a share, you should first create an Azure Storage context object using the AzStorageContext cmdlet. This cmdlet requires the name of the storage key and the access key for the storage account.

New-AzStorageContex

and then you must set a name for the share and pass the context object as a parameter in the New-AzureStorageShare cmdlet.

Azure File Share

Azure CLI Workaround

In this case, we will use Azure Cloud Shell, a browser-based shell built into Azure Portal. This allows us to use the Azure command-line tools (Azure CLI and Azure PowerShell) directly from a browser. If you want to know more about Azure Cloud Shell, check out this link

To create an Azure File Share using Azure CLI, you should first retrieve the connection string using the az show-connection-string command.

-n: storage account name.

-g: resource group.

-o : output format.

and then pass the value to the az storage share create command.

–name: File Share name.

–quota: the storage capacity.

Azure File Share

In the next post, I will show you how to connect and mount an Azure File Share from Windows.

If you want to know more about Azure File services, check out this link: https://docs.microsoft.com/en-us/azure/storage/files/storage-files-introduction