Microsoft Docs has an article on Use an Azure File Share with Windows. However, this article is using the old PowerShell module for Azure, Az.
At first, I was tempted to submit a pull request for the whole article, but reading the Install Azure PowerShell module, I realized Az is still required. So instead, I am providing steps for setting up Azure File Share with Windows using the AzureRM module here.
The original article also missed recommendations for setting up an Azure account and subscription. This can be overlooked by new on comers to Azure.
# Step 1: Get the Azure Account (Az equivalent Get-AzAccount).
Add-AzureRMAccount
# Step 2: Get the list of all the subscriptions under the current account. Copy the subscription id GUID. (Az equivalent Get-AzSubscription).
Get-AzureRmSubscription
# Step 3: Set the current context. This allows you to set which subscription and account to use for all commands in current session. (Az equivalent Get-AzSubscription -SubscriptionID xxxx | Set-AzContext)
Get-AzureRmSubscription -SubscriptionID xxxx | Set-AzureRmContext
# Step 4 : Execute the following to get all the active storage accounts in the current context.
Get-AzureRmStorageAccount | SELECT StorageAccountName, ResourceGroupName | Out-GridView
# Step 5 : Get storage, update the xxxx with the storage account name and resource group name from Step #4.
$AzStorageAcct = Get-AzureRmStorageAccount -ResourceGroupName "xxxxxx" -Name "xxxxxx"
# Step 6 : Get Storage Keys
$AzStorageKeys = $AzStorageAcct | Get-AzureRmStorageAccountKey
# Step 7 : Get list of shares configured in Azure
$AzStorageAcct | Get-AzureStorageShare
# Step 8 : Get file share. Replace the xxxx with your share name.
$AzFileShare = $AzStg | Get-AzureStorageShare -Name xxxx
# Step 9 : Mount the Share
$password = ConvertTo-SecureString -String $AzStorageKeys[0].Value -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential -ArgumentList "AZURE\$($AzStorageAcct.StorageAccountName)", $password
New-PSDrive -Name <desired-drive-letter> -PSProvider FileSystem -Root "\\$($AzFileShare.StorageUri.PrimaryUri.Host)\$($AzFileShare.Name)" -Credential $credential -Persist
Azure PowerShell is frustrating because you are not sure of the commands. Some commands are *-Az*, Some are *-Azure*, and some are *-AzureRm*. Depends on the module you are using! Have fun :).