How to create Azure Storage Account using PowerShell

In this article, you will see how to create an Azure Storage Account using PowerShell.


Install the Azure PowerShell Module:

Open Windows PowerShell window and run the below command.


Install-Module -Name Az –AllowClobber

Create Azure Storage Account:

Open a text file. Copy and paste the below script. Save the file as script.ps1.


################# Azure Blob Storage - PowerShell ####################


## Input Parameters

$location="eastus" ## Get all the locations for your Azure Subscription: Get-AzLocation | select Location

$resourceGroupName="psspschennairg"

$storageAccName="psspschennaistorageacc"


## Connect to Azure Account

Connect-AzAccount


## Function to create Azure Storage Account

Function CreateAzStorageAcc

{

## Check if resource group exists

if(Get-AzResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinue)

{

Write-Host -ForegroundColor Magenta $resourceGroupName "- resource group already exists."

}

else

{

Write-Host -ForegroundColor Magenta $resourceGroupName "- resource group does not exist."