Introduction

In this blog, you will see how to create a file share in Azure Storage Account using PowerShell.

Prerequisites

Install Azure PowerShell Module to run the script.

PowerShell Script

Open Notepad and paste the following script. Save the file as script.ps1.

  1. ################# Azure Blob Storage - PowerShell ####################
  2. ## Input Parameters
  3. $resourceGroupName="azpractice"
  4. $storageAccName="azstorageacc1122020"
  5. $fileShareName="azevents2020"
  6. ## Connect to Azure Account
  7. Connect-AzAccount
  8. ## Function to get all the blobs
  9. Function CreateFileShare
  10. {
  11. Write-Host -ForegroundColor Green "Creating an file Share.."
  12. ## Get the storage account context
  13. $ctx=(Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccName).Context
  14. ## Creates an file share
  15. New-AzStorageShare -Context $ctx -Name $fileShareName
  16. }
  17. CreateFileShare
  18. ## Disconnect from Azure Account
  19. Disconnect-AzAccount

Open the Windows PowerShell window and navigate to the location where the script file was saved.

Run the following command.

.\script.ps1

Result

Reference

https://docs.microsoft.com/en-us/powershell/module/az.storage/new-azstorageshare?view=azps-3.3.0

Summary

In this blog, you saw how to create a file share in Azure Storage Account using PowerShell.