Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Visualize Azure resource relationships, dependencies, and topology as diagrams
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/azure-resource-graph.md
1# Azure Resource Graph Queries for Resource Discovery23Azure Resource Graph (ARG) enables fast, cross-subscription resource querying using KQL via `az graph query`. Use it for bulk resource discovery and relationship mapping.45## How to Query67Use the `extension_cli_generate` MCP tool to generate `az graph query` commands:89```yaml10mcp_azure_mcp_extension_cli_generate11intent: "query Azure Resource Graph to <describe what you want to find>"12cli-type: "az"13```1415Or construct directly:1617```bash18az graph query -q "<KQL>" --query "data[].{name:name, type:type}" -o table19```2021> ⚠️ **Prerequisite:** `az extension add --name resource-graph`2223## Key Tables2425| Table | Contains |26|-------|----------|27| `Resources` | All ARM resource instances (name, type, location, properties, tags) |28| `ResourceContainers` | Subscriptions, resource groups, management groups |2930## Resource Discovery Patterns3132**List all resources by type:**3334```kql35Resources | summarize count() by type | order by count_ desc36```3738**Inventory by location and type:**3940```kql41Resources | summarize count() by type, location | order by type asc42```4344**List all resources in a resource group with details:**4546```kql47Resources48| where resourceGroup =~ '<rg-name>'49| project name, type, location, sku.name, kind50```5152**Cross-subscription resource inventory with subscription names:**5354```kql55Resources56| join kind=leftouter (57ResourceContainers58| where type == 'microsoft.resources/subscriptions'59| project subscriptionId, subscriptionName=name60) on subscriptionId61| project name, type, location, resourceGroup, subscriptionName62```6364**Discover network relationships (VNets, subnets, NICs):**6566```kql67Resources68| where type =~ 'microsoft.network/virtualnetworks'69| mv-expand subnet=properties.subnets70| project vnetName=name, subnetName=subnet.name, addressPrefix=subnet.properties.addressPrefix, resourceGroup71```7273**Find App Services and their plans:**7475```kql76Resources77| where type =~ 'microsoft.web/sites'78| project name, kind, location, serverFarmId=properties.serverFarmId, resourceGroup79```8081## Tips8283- Use `=~` for case-insensitive type matching (resource types are lowercase)84- Navigate properties with `properties.fieldName`85- Use `--first N` to limit result count86- Use `--subscriptions` to scope to specific subscriptions87- Use `mv-expand` to flatten arrays (e.g., subnets, IP configurations)88