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.
2 minute read
Azure Resource Graph is an Azure service designed to extend Azure Resource Management by providing efficient and performant resource exploration with the ability to query at scale across a given set of subscriptions so that you can effectively govern your environment.
Requirements
To use Azure Resource Graph, ensure you have the following:
- Azure PowerShell 1.0.0 or higher
- PowerShellGet 2.0.1 or higher Let’s create a cleaner and more organized version of this page. Here’s a proposed layout:
Installation
Install the Module
Open an administrative terminal and run:
Install-Module -Name Az.ResourceGraph
Validate Installation
Check that the commands are available:
Get-Command -Module 'Az.ResourceGraph' -CommandType 'Cmdlet'
Example Queries
Query All Resources with a CreatedOnDate Tag
az graph query -q "Resources | where todatetime(tags.CreatedOnDate) < now(-30d) | project name"
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
Search-AzGraph -Query "Resources | where tags.environment=~'internal' | project name"
Query All VMs Ordered by Name
Search-AzGraph -Query "Resources | project name, location, type| where type =~ 'Microsoft.Compute/virtualMachines' | order by name desc"
References
- Azure Resource Graph Documentation
- First Query with Azure Resource Graph using PowerShell
- Azure Resource Graph: Zero to Hero
- Azure Resource Graph Query Examples
- Install Azure PowerShell
- Install PowerShellGet
Feedback
Was this page helpful?
Glad to hear it!
Sorry to hear that.