az graph
Note
This reference is part of the resource-graph extension for the Azure CLI (version 2.22.0 or higher). The extension will automatically install the first time you run an az graph command. Learn more about extensions.
Query the resources managed by Azure Resource Manager.
Run 'az graph query --help' for detailed help.
Commands
Name | Description | Type | Status |
---|---|---|---|
az graph query |
Query the resources managed by Azure Resource Manager. |
Extension | GA |
az graph shared-query |
Manage shared query of Azure resource graph. |
Extension | Experimental |
az graph shared-query create |
Create a shared query. |
Extension | Experimental |
az graph shared-query delete |
Delete a shared query. |
Extension | Experimental |
az graph shared-query list |
List all shared query in a resource group. |
Extension | Experimental |
az graph shared-query show |
Show the properties of a shared query. |
Extension | Experimental |
az graph query
Query the resources managed by Azure Resource Manager.
See https://aka.ms/AzureResourceGraph-QueryLanguage to learn more about query language and browse examples.
az graph query --graph-query
[--allow-partial-scopes {false, true}]
[--first]
[--management-groups]
[--skip]
[--skip-token]
[--subscriptions]
Examples
Query resources requesting a subset of resource fields.
az graph query -q "project id, name, type, location, tags"
Query resources with field selection, filtering and summarizing.
az graph query -q "project id, type, location | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by location | top 3 by count_"
Request a subset of results, skipping 20 items and getting the next 10.
az graph query -q "where type =~ "Microsoft.Compute" | project name, tags" --first 10 --skip 20
Choose subscriptions to query.
az graph query -q "where type =~ "Microsoft.Compute" | project name, tags" --subscriptions 11111111-1111-1111-1111-111111111111 22222222-2222-2222-2222-222222222222
Choose management groups to query.
az graph query -q "where type =~ "Microsoft.Compute" | project name, tags" --management-groups aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb --allow-partial-scopes
Query with the skip token.
az graph query -q "where type =~ "Microsoft.Compute" | project name, tags" --skip-token skip_token_value_from_previous_query_response
Required Parameters
Resource Graph query to execute.
Optional Parameters
Indicates if query should succeed when only partial number of subscription underneath can be processed by server.
The maximum number of objects to return. Accepted range: 1-1000.
List of management groups to run query against.
Ignores the first N objects and then gets the remaining objects.
Skip token to get the next page of the query if applicable.
List of subscriptions to run query against. By default all accessible subscriptions are queried.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
Azure CLI