你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Search-AzGraph
查询 Azure 资源管理器管理的资源。
语法
Search-AzGraph
[-Query] <String>
[-Subscription <String[]>]
[-First <Int32>]
[-Skip <Int32>]
[-SkipToken <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Search-AzGraph
[-Query] <String>
-ManagementGroup <String[]>
[-AllowPartialScope]
[-First <Int32>]
[-Skip <Int32>]
[-SkipToken <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Search-AzGraph
[-Query] <String>
[-UseTenantScope]
[-AllowPartialScope]
[-First <Int32>]
[-Skip <Int32>]
[-SkipToken <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
说明
在此处详细了解查询语法:https://aka.ms/resource-graph/learntoquery
示例
示例 1
Search-AzGraph "project id, name, type, location, tags" -First 3
id : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/Service-INT-a/providers/Microsoft.Compute/virtualMachineScaleSets/nt
name : nt
type : microsoft.compute/virtualmachinescalesets
location : eastus
tags : @{resourceType=Service Fabric; clusterName=gov-art-int-nt-a}
ResourceId : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/Service-INT-a/providers/Microsoft.Compute/virtualMachineScaleSets/nt
id : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/Service-INT-a/providers/Microsoft.EventGrid/topics/egtopic-1
name : egtopic-1
type : microsoft.eventgrid/topics
location : westus2
tags :
ResourceId : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/Service-INT-a/providers/Microsoft.EventGrid/topics/egtopic-1
请求资源字段子集的简单资源查询。
示例 2
Search-AzGraph "project id, name, type, location | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by location | top 3 by count_"
location count_
-------- ------
eastus 66
westcentralus 32
westus 26
对具有字段选择、筛选和汇总的资源的复杂查询。
示例 3
$response = Search-AzGraph -Query "project id, name, type, location" -First 2
Search-AzGraph -Query "project id, name, type, location" -SkipToken $response.SkipToken
id : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/test/providers/Microsoft.Network/networkInterfaces/17ni
name : 17ni
type : microsoft.network/networkinterfaces
location : westeurope
ResourceId : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/test/providers/Microsoft.Network/networkInterfaces/17ni
id : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/test/providers/Microsoft.Network/networkSecurityGroups/17nsg
name : 17nsg
type : microsoft.network/networksecuritygroups
location : westeurope
ResourceId : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/test/providers/Microsoft.Network/networkSecurityGroups/17nsg
包含从上一查询结果传递的跳过令牌的查询。 请注意,必须在结果中保留 ID 才能返回跳过令牌。
示例 4
Search-AzGraph -Query "project id, name, type, location, tags" -First 2 -ManagementGroup MyManagementGroupId -AllowPartialScope
id : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/Service-INT-a/providers/Microsoft.Compute/virtualMachineScaleSets/nt
name : nt
type : microsoft.compute/virtualmachinescalesets
location : eastus
tags : @{resourceType=Service Fabric; clusterName=gov-art-int-nt-a}
ResourceId : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/Service-INT-a/providers/Microsoft.Compute/virtualMachineScaleSets/nt
id : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/Service-INT-a/providers/Microsoft.EventGrid/topics/egtopic-1
name : egtopic-1
type : microsoft.eventgrid/topics
location : westus2
tags :
ResourceId : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/Service-INT-a/providers/Microsoft.EventGrid/topics/egtopic-1
一个范围限定为管理组的查询,如果 MyManagementGroupId 下面有多个 N 个订阅,则允许查询在部分范围结果中成功。 N 是服务器可处理的最大订阅数。
参数
-AllowPartialScope
指示当服务器只能处理部分订阅数时,查询是否应成功
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-DefaultProfile
用于与 Azure 通信的凭据、帐户、租户和订阅。
类型: | IAzureContextContainer |
别名: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-First
要返回的最大对象数。 允许的值:1-1000。 默认值为 100。
类型: | Int32 |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ManagementGroup
要对其运行查询的管理组(s)。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-Query
Resource Graph 查询。
类型: | String |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-Skip
忽略第一个 N 对象,然后获取其余对象。
类型: | Int32 |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-SkipToken
用于获取下一页结果(如果适用)的跳过令牌。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Subscription
要对其运行查询的订阅(s)。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-UseTenantScope
对当前租户中的所有可用订阅运行查询。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
输入
None