az graph
Note
此参考是 Azure CLI 的资源 图 扩展(版本 2.22.0 或更高版本)的一部分。 该扩展将在首次运行 az graph 命令时自动安装。 了解更多关于扩展的信息。
查询 Azure 资源管理器管理的资源。
运行“az graph query --help”获取详细帮助。
命令
名称 | 说明 | 类型 | Status |
---|---|---|---|
az graph query |
查询 Azure 资源管理器管理的资源。 |
Extension | GA |
az graph shared-query |
管理 Azure 资源图的共享查询。 |
Extension | Experimental |
az graph shared-query create |
创建共享查询。 |
Extension | Experimental |
az graph shared-query delete |
删除共享查询。 |
Extension | Experimental |
az graph shared-query list |
列出资源组中的所有共享查询。 |
Extension | Experimental |
az graph shared-query show |
显示共享查询的属性。 |
Extension | Experimental |
az graph query
查询 Azure 资源管理器管理的资源。
请参阅 https://aka.ms/AzureResourceGraph-QueryLanguage 了解有关查询语言和浏览示例的详细信息。
az graph query --graph-query --q
[--allow-partial-scopes {false, true}]
[--first]
[--management-groups]
[--skip]
[--skip-token]
[--subscriptions]
示例
查询请求资源字段子集的资源。
az graph query -q "project id, name, type, location, tags"
使用字段选择、筛选和汇总查询资源。
az graph query -q "project id, type, location | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by location | top 3 by count_"
请求结果的子集,跳过 20 个项目并获取下一个 10 项。
az graph query -q "where type =~ "Microsoft.Compute" | project name, tags" --first 10 --skip 20
选择要查询的订阅。
az graph query -q "where type =~ "Microsoft.Compute" | project name, tags" --subscriptions 11111111-1111-1111-1111-111111111111 22222222-2222-2222-2222-222222222222
选择要查询的管理组。
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
使用跳过令牌进行查询。
az graph query -q "where type =~ "Microsoft.Compute" | project name, tags" --skip-token skip_token_value_from_previous_query_response
必需参数
要执行的 Resource Graph 查询。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
指示当服务器只能处理部分订阅数时,查询是否应成功。
属性 | 值 |
---|---|
默认值: | False |
接受的值: | false, true |
要返回的最大对象数。 接受的范围:1-1000。
要对其运行查询的管理组列表。
忽略第一个 N 对象,然后获取其余对象。
跳过令牌以获取查询的下一页(如果适用)。
要对其运行查询的订阅列表。 默认情况下,查询所有可访问的订阅。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
输出格式。
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |