Search-AzGraph
Queries the resources managed by Azure Resource Manager.
Syntax
Search-AzGraph
[-Query] <String>
[-Subscription <String[]>]
[-First <Int32>]
[-Skip <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
Learn more about the query syntax here: https://aka.ms/resource-graph/learntoquery
Examples
Example 1
PS C:\> 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}
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 :
Simple resources query requesting a subset of resource fields.
Example 2
PS C:\> 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
A complex query on resources featuring field selection, filtering and summarizing.
Example 3
PS C:\> Search-AzGraph -Include DisplayName -Query 'where type =~ "Microsoft.Compute/virtualMachines"| where properties.storageProfile.osDisk.managedDisk == "" | project name, resourceGroup, subscriptionDisplayName'
name resourceGroup subscriptionDisplayName
---- ------------- -----------------------
ContosoVM RG-Contoso Contoso Production Subscription
A query featuring all virtual machines which are not using Managed Disks and includes subscription display names.
Example 4
PS C:\> Search-AzGraph -Include DisplayName -Query 'summarize count() by tenantDisplayName, subscriptionDisplayName'
tenantDisplayName subscriptionDisplayName count_
----------------- ----------------------- ------
ContosoTenant Contoso Production Subscription 118
A query displaying the count of resources by tenant and subscription display names.
Parameters
The credentials, account, tenant, and subscription used for communication with Azure.
Type: | Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
The maximum number of objects to return. Allowed values: 1-5000. Default value is 100.
Type: | Int32 |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Resource Graph query.
Type: | String |
Position: | 0 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Ignores the first N objects and then gets the remaining objects.
Type: | Int32 |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Subscription(s) to run query against.
Type: | String[] |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
None