In this article, you will see how to delete 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
Download Blob Contents:
Open a text file. Copy and paste the below script. Save the file as script.ps1.
################# Azure Blob Storage - PowerShell ####################
## Input Parameters
$resourceGroupName="psspschennairg"
$storageAccName="psspschennaistorageacc"
## Connect to Azure Account
Connect-AzAccount
## Function to delete a storage account
Function DeleteStorageAccount
{
Write-Host -ForegroundColor Green "Deleting the storage account and resource group.."
## Check if storage account exists
if(Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccName -ErrorAction SilentlyContinue)
{
## Delete the storage account
Remove-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccName -Force
}
else
{
Write-Host -ForegroundColor Magenta $storageAccName "- storage account does not exist."
}
}
DeleteStorageAccount
## Disconnect from Azure Account
Disconnect-AzAccount
######################################################################
Open Windows PowerShell window and navigate to the location where the script file was saved.
Run the following command.
.\script.ps1
Summary:
Thus in this article you saw how to delete an Azure Storage Account using PowerShell.
Comentários