For system, network and cloud administrators

How to list all Azure storage accounts using Azure CLI

In order to view all Azure storage accounts, type:

az storage account list --output tsv


How to delete all Azure resource groups that start with a pattern using Azure CLI and Azure Bash shell

In order to delete all resource groups that start with project01, for example, you’ll first need to make sure you’re in a Bash shell and not PowerShell. Then, type:

az group list --query "[?starts_with(name,'project01')].[name]" --output tsv | xargs -L1 bash -c 'az group delete --name $0 --no-wait --yes' 


How to list all Azure managed disks that start with a pattern using Azure CLI

In order to view all managed disks that start with the disk name, type:

az disk list --query "[?starts_with(name,'disk')].name" --output tsv

How to list all Azure resource groups that start with a pattern using Azure CLI

In order to list all resource groups that start with rg, for example, type:

az group list --query "[?starts_with(name,'rg')].name" --output tsv

How to view disk size of an Azure managed disk using Azure CLI

In order to check the size of the managed disk in Azure, type:

az disk show --resource-group yourresourcegroup --name yourdiskname --query diskSizeGb