Azure Resource Graph¶
Azure Resource Graph helps you explore and query your Azure resources efficiently and at scale. This guide covers installation, example queries, and best practices.
Requirements¶
To use Azure Resource Graph, ensure you have the following:
- Azure PowerShell 1.0.0 or higher
- PowerShellGet 2.0.1 or higher
Installation¶
Install the Module¶
Open an administrative terminal and run:
Validate Installation¶
Check that the commands are available:
Example Queries¶
Query All Resources with a CreatedOnDate Tag
Query All Resource Groups with a CreatedOnDate Tag
az graph query -q "ResourceContainers | where type=='microsoft.resources/subscriptions/resourcegroups' | where todatetime(tags.CreatedOnDate) < now(-30d) | project name"
Query Resources with Specific Tag Value
Query All VMs Ordered by Name
Search-AzGraph -Query "Resources | project name, location, type| where type =~ 'Microsoft.Compute/virtualMachines' | order by name desc"