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.
- ################# Azure Blob Storage - PowerShell ####################
-
- ## Input Parameters
- $resourceGroupName="azpractice"
- $storageAccName="azstorageacc1122020"
- $fileShareName="azevents2020"
-
- ## Connect to Azure Account
- Connect-AzAccount
-
- ## Function to get all the blobs
- Function CreateFileShare
- {
- Write-Host -ForegroundColor Green "Creating an file Share.."
- ## Get the storage account context
- $ctx=(Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccName).Context
- ## Creates an file share
- New-AzStorageShare -Context $ctx -Name $fileShareName
- }
-
- CreateFileShare
-
- ## Disconnect from Azure Account
- 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.