Cheat Sheet - Azure CLI

Querying for resources

Get a list of resources without a tag

az resource list --query "[?tags == null].{Name:name, Type:type}" --output table

Get a list of resources with a specific tag

az resource list --query "[$tags.environment = 'development'].{Name:name, Type:type}" --output table

Get a list of resources without a specific tag and exclude resources with missing tags

az resource list --query "[?tags.environment != 'development' && not_null(tags)]"

Setting defaults

Set default resource group

az config set defaults.group=<resource-group>

Set default subscription

az account set --subscription <subscription>