Skip to content
Latchkey

az group list: List Azure Resource Groups

az group list returns the resource groups in the current subscription, optionally filtered by tag.

Pipelines that create or tear down environments often check whether a group already exists. group list with a JMESPath filter answers that without an error path.

What it does

az group list returns the resource groups in the active subscription, each with name, location, tags, and provisioningState. You can filter server-side by tag or client-side with --query.

Common usage

Terminal
az group list --output table
# groups carrying a specific tag
az group list --tag env=staging -o table
# does a named group exist? (empty result if not)
az group list --query "[?name=='rg-app'].name" -o tsv

Subcommands and flags

FlagWhat it does
--tag <name=value>Filter to groups carrying the given tag
--query <jmespath>Client-side filter or projection
-o tableReadable table output
--subscriptionTarget a subscription other than the default

In CI

To make a "create if missing" step idempotent, query for the group name with -o tsv and branch on whether the output is empty, rather than relying on az group create exit codes. Pair with az group create when absent.

Common errors in CI

"AuthorizationFailed: The client ... does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourcegroups/read'" means the service principal lacks Reader on the subscription. "Please run 'az login'" means no session. A blank list with exit code 0 simply means no groups match the filter.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →