For system, network and cloud administrators

How to view an Azure resource group’s location using Azure CLI

In order to view a particular Azure resource group’s location, type in your shell:

az group show --resource-group yourresourcegroup --query location

How to delete all Azure managed disks that start with a pattern using Azure PowerShell

In order to remove all Azure managed disks that start with the name disk, in your PowerShell session type:

Get-AzDisk -ResourceGroupName yourgroupresource -Name 'disk*' | Remove-AzDisk -Force -Verbose


How to update Azure disk performance SKU using Azure CLI

In order to update a current Azure disk performance SKU, from Standard_LRS to Premium_LRS, for example, type:

az disk update --name yourdiskname --resource-group yourresourcegroup --sku Premium_LRS

How to delete all Azure managed disks that start with a pattern using Azure CLI and Bash shell

In order to be able to delete all Azure managed disks that start with mydisk, for example, you’ll first need to run the Azure Bash shell instead of PowerShell and then type:

az disk list --query "[?starts_with(name,'mydisk')].[name]" | xargs -L1 bash -c 'az disk delete --resource-group yourresourcegroup --name $0 --yes'


How to delete all Azure storage accounts that start with a pattern using Azure CLI and Bash shell

In order to delete all Azure storage accounts that start with mystorage, for example, you’ll first need to run a Bash shell instead of PowerShell. Then, type:

az storage account list --query "[?starts_with(name,'mystorage')].[name]" --output tsv | xargs -L1 bash -c 'az storage account delete --name $0 --yes'