你当前正在访问 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

指示当服务器只能处理下面的部分订阅数时,查询是否应成功

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-First

要返回的最大对象数。 允许的值:1-1000。 默认值为 100。

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ManagementGroup

管理组 (运行查询的) 。

Type:String[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Query

Resource Graph查询。

Type:String
Position:0
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-Skip

忽略第一个 N 对象,然后获取剩余的对象。

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-SkipToken

用于获取下一页结果(如果适用)的跳过令牌。

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Subscription

要对其运行查询的订阅 () 。

Type:String[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-UseTenantScope

跨当前租户中的所有可用订阅运行查询。

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

输入

None

输出

PSResourceGraphResponse<PSObject>[[PSObject]]