This post is how to work with tags for Azure resources.
Install Graph Extension
- az extension add --name resource-graph
Tag List
- az tag list --subscription <NAME>
Query for Specific Tag Value
- az graph query -q "project name, resourceGroup, type, tags | where tags.<TAGNAME>=~'<VALUE>'"
Query for Multiple Tags
- az graph query -q "project name, resourceGroup, type, tags | where tags.<TAGNAME>=~'<VALUE>' | where tags.<TAGNAME>=~'<VALUE>'"
Query for Resource Groups
- az graph query -q "ResourceContainers | project name, type, tags | where tags.<TAGNAME>=~'<VALUE>'"
Query For Multiple Resource Types
- az graph query -q "project name, resourceGroup, type, tags | where tags.<TAGNAME>=~'<VALUE>' | where type =~ 'microsoft.sql/servers/databases' or type =~ 'microsoft.storage/storageaccounts'"