Skip to main content

How to List Resource Groups in Azure CLI (az group list)

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

The command is az group list. Add --output table and you get a clean, readable list instead of a wall of JSON. Everything else on this page is a variation on that one command.

The Short Answer

Terminal
az group list --output table

That is it. If you just wanted the command, you can stop reading. The rest of this page covers filtering, counting, and the flags that save you time.

Before You Start

  • Azure CLI installed. Check with az version.
  • Logged in. Run az login if you are not. It opens a browser window.

If you have more than one subscription, the CLI uses your default. Check which one you are on:

Terminal
az account show --output table

List All Resource Groups

This is the command you will use most:

Terminal
az group list --output table

You get three columns — name, location, and status:

Output
Name Location Status
-------------------------- ------------ ---------
rg-web-prod centralindia Succeeded
rg-web-dev centralindia Succeeded
rg-data-prod eastus Succeeded
rg-analytics-dev eastus Succeeded
DefaultResourceGroup-CID centralindia Succeeded
NetworkWatcherRG centralindia Succeeded

Ubuntu terminal showing the az group list --output table command and its three-column output of resource group names, locations, and provisioning status

note

The resource group names above are examples. You will see your own. Groups like NetworkWatcherRG and DefaultResourceGroup-CID are created by Azure automatically — you did not make them, and you should leave them alone.

Just the Names

When you want to pipe the output into another command, drop everything except the names:

Terminal
az group list --query "[].name" --output tsv

tsv means tab-separated values. No headers, no quotes, no brackets — just one name per line, ready for a loop or a grep.

Pick Your Output Format

--output (short form -o) accepts four formats:

FormatCommandUse it when
tableaz group list -o tableYou are reading it yourself
tsvaz group list -o tsvYou are piping into another command or a script
jsonaz group list -o jsonYou need the full detail, including tags and IDs
yamlaz group list -o yamlYou prefer YAML to JSON

json is the default if you do not pass --output at all.

Filter by Location

Only want the groups in one region?

Terminal
az group list --query "[?location=='eastus'].name" --output tsv

Note the quotes: double quotes around the whole query, single quotes around eastus inside it. Get that backwards and your shell will eat the query.

Filter by Name

To find every group whose name starts with rg-:

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

Swap starts_with for contains to search anywhere in the name:

Terminal
az group list --query "[?contains(name,'prod')].name" --output tsv

Filter by Tag

If you tag your resource groups, the CLI has a dedicated flag — no query needed:

Terminal
az group list --tag Environment=Production --output table

You can also match on the tag key alone, ignoring its value:

Terminal
az group list --tag Environment --output table
warning

--tag accepts one tag only. There is no way to pass two tags to this flag. If you need to match on two tags at once, use --query on the tags object instead.

Count Them

Terminal
az group list --query "length(@)"

@ means "everything you just got back", so length(@) is simply "how many". It prints a bare number.

Ubuntu terminal showing az group list filtered by location with a JMESPath query, and a second command counting the total number of resource groups

Sort the List

Azure returns groups in no particular order. Sort them by name:

Terminal
az group list --query "sort_by([].{Name:name,Location:location}, &Name)" --output table

The {Name:name,Location:location} part picks which columns you want. The &Name says sort on that column. Change it to &Location to group by region instead.

Check If a Resource Group Exists

Useful in scripts, before you try to create or deploy something:

Terminal
az group exists --name rg-web-prod

It prints true or false and nothing else.

Look Inside a Resource Group

Listing the groups is one thing; seeing what is in one is another command:

Terminal
az resource list --resource-group rg-web-prod --query "[].{Name:name,Type:type}" --output table

For the group's own details rather than its contents:

Terminal
az group show --name rg-web-prod --output table

List Groups in a Different Subscription

Add --subscription to any of the commands above:

Terminal
az group list --subscription "My Subscription" --output table

Or switch your default first, so you do not have to repeat the flag:

Terminal
az account set --subscription "My Subscription"
az group list --output table

Cheat Sheet

What you wantCommand
Readable listaz group list -o table
Names onlyaz group list --query "[].name" -o tsv
One regionaz group list --query "[?location=='eastus'].name" -o tsv
Name searchaz group list --query "[?contains(name,'prod')].name" -o tsv
By tagaz group list --tag Environment=Production -o table
How manyaz group list --query "length(@)"
Sortedaz group list --query "sort_by([].{Name:name,Location:location}, &Name)" -o table
Does it existaz group exists --name rg-web-prod
What is insideaz resource list -g rg-web-prod -o table

Common Mistakes

MistakeWhat happensFix
az list resource groupsERROR: 'list' is misspelled or not recognized by the system.The command is az group list — noun first, then verb
Single quotes around the whole --queryYour shell strips the inner quotes and the query failsDouble quotes outside, single quotes inside
Passing two tags to --tagOnly one is usedUse --query on the tags object instead
Expecting alphabetical orderAzure returns them unorderedAdd sort_by(...)
Forgetting --output tableA long wall of JSONAdd -o table, or set a default with az configure
Wrong subscriptionYou see the wrong groups, or noneRun az account show first

Troubleshooting

SymptomCauseFix
Please run 'az login' to setup accountNot signed in, or the token expiredRun az login again
Empty list, no errorYou are on a subscription with no resource groupsaz account show, then az account set --subscription "..."
The subscription is not registeredThe subscription is disabled or expiredCheck it in the Azure portal
--query returns []The filter matched nothing, often a case mismatchLocation values are lowercase with no spaces: eastus, not East US
Quoting errors in PowerShellPowerShell parses quotes differently from BashUse the same command in Bash, or see Microsoft's PowerShell quoting notes linked below
az not foundThe CLI is not installed or not on your PATHInstall it, then re-open your terminal

Frequently Asked Questions

What is the command to list resource groups in Azure CLI?

az group list. Add --output table for a readable list.

Why does az list resource groups not work?

Azure CLI commands are noun-then-verb. The group is az group and the action is list, so it is az group list. The same pattern applies everywhere: az vm list, az storage account list, az webapp list.

How do I list resource groups in a specific region?

Terminal
az group list --query "[?location=='eastus'].name" --output tsv

Location values are lowercase and unspaced. Run az account list-locations --query "[].name" -o tsv to see the valid values.

How do I count my resource groups?

az group list --query "length(@)" prints the number on its own.

Can I list resource groups across all my subscriptions at once?

Not with az group list — it works on one subscription at a time. Loop over your subscriptions:

Terminal
for sub in $(az account list --query "[].id" -o tsv); do
echo "== $sub"
az group list --subscription "$sub" --output table
done

Does listing resource groups cost anything?

No. Read operations against Azure Resource Manager are free.

Conclusion

az group list --output table covers the everyday case. When you need more, --query does the filtering, --output picks the shape, and --tag handles tags without any query syntax at all.

If you do not have a resource group yet, start with How to Create a Resource Group in Microsoft Azure using Azure CLI — then come back here to list what you made.

Additional Resources

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.