Search-AzGraph

Azure Resource Manager によって管理されているリソースに対してクエリを実行します。

構文

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
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

Azure との通信のために使用される資格情報、アカウント、テナント、サブスクリプションです。

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

-First

返されるオブジェクトの最大数。 使用できる値: 1 ~ 1000。 既定値は 100 です。

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

-ManagementGroup

クエリを実行する管理グループ。

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

-Query

Resource Graph クエリ。

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

-Skip

最初の N 個のオブジェクトを無視し、再メインオブジェクトを取得します。

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

-SkipToken

結果の次のページを取得するために使用するスキップ トークン (該当する場合)。

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

-Subscription

クエリを実行するサブスクリプション。

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

-UseTenantScope

現在のテナントで使用可能なすべてのサブスクリプションに対してクエリを実行します。

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

入力

None

出力

PSResourceGraphResponse<PSObject>[[PSObject]]