Azure Resource Lookup
Find Azure resources efficiently across subscriptions and return concise, actionable metadata.
Use This Skill When
- The user cannot find a resource in Azure
- The user needs inventory by type, region, tag, or naming pattern
- The user needs configuration details before making changes
- The user needs to verify resource existence or validate naming conventions
Context: Lookup Maturity
Immature: Manual searches in portal, incomplete knowledge of resources
Developing: CLI queries, some automation of common lookups
Managed: Scripted queries with filtering, tags for organization → Target
Optimized: Auto-indexing, graph-based discovery, dependency visualization
Required Inputs
- Scope: Management group, subscription, resource group, or single app name?
- Resource type: Specific type (VMs, databases) or keyword search?
- Filters: Region, environment tag, owner, creation date range?
- Required fields: Basic (id, name, location) or detailed (config, cost, status)?
- Output format: Table, JSON, or filtered list?
Decision Tree
What are you looking for?
├─ Specific resource by name → Direct query: az resource show --name
├─ All resources of one type → Type filter: az resource list --resource-type
├─ Resources in a region → Location filter: az resource list --location
├─ Resources by tag → Tag filter: az resource list --query "[?tags.Environment=='Prod']"
└─ Unknown (keyword search) → Graph query with semantic search
How broad is the scope?
├─ Single resource group → Query is fast
├─ Single subscription → Query takes 5-10 seconds
├─ Multiple subscriptions → Use Azure Resource Graph (optimized)
└─ Entire organization → Use Azure Resource Graph with batch mode
Do you need real-time status or historical data?
├─ Real-time → CLI query (az resource list)
├─ Historical → Query resource logs (Activity logs)
├─ Cost-related → Query Cost Management API
Workflow
Phase 1: Query Resources
Find by name:
# Exact match
az resource show --name "myappdb" --resource-type "Microsoft.Sql/servers/databases"
# Output
{
"id": "/subscriptions/abc123/resourceGroups/prod-rg/providers/Microsoft.Sql/servers/myserver/databases/myappdb",
"name": "myappdb",
"type": "Microsoft.Sql/servers/databases",
"location": "eastus",
"properties": {
"status": "Online",
"edition": "Standard",
"serviceLevelObjective": "S0"
}
}
Find by type (all VMs in subscription):
az resource list --resource-type "Microsoft.Compute/virtualMachines" \
--query "[].{name:name, group:resourceGroup, location:location, vmSize:properties.hardwareProfile.vmSize}" \
-o table
# Output
Name Group Location VmSize
vm-prod-1 prod-rg eastus Standard_D2s_v3
vm-prod-2 prod-rg eastus Standard_D2s_v3
vm-dev-1 dev-rg eastus Standard_B2s
Find by tag (all prod resources):
az resource list --query "[?tags.Environment=='Prod']" \
--query "[].{name:name, type:type, group:resourceGroup}" \
-o table
Find by region:
az resource list --location "eastus" \
--query "[].{name:name, type:type, sku:sku.name}" \
-o table
Find by naming pattern:
# All resources starting with "api-"
az graph query -q "resources | where name startswith 'api-'" \
-o table
Phase 2: Azure Resource Graph (advanced queries)
Why Resource Graph? Fast, parallel queries across subscriptions without hitting throttle limits.
Query all subscriptions (as organization admin):
# All databases across subscriptions
az graph query -q "resources | where type == 'microsoft.sql/servers/databases' | project name, resourceGroup, location, properties.status"
Find resources by partial name (fuzzy search):
az graph query -q "resources | where name contains 'prod' and type contains 'compute'"
Find orphaned resources (no tags, old creation date):
az graph query -q "resources | where tags == '{}' and tostring(properties.timeCreated) < '2023-01-01'"
Find underutilized resources (check costs):
# App Service plans with low CPU
az graph query -q "resources | where type == 'microsoft.web/serverfarms' | project name, resourceGroup, properties.workerCount, properties.sku"
Phase 3: Extract Configuration Details
Database configuration:
az sql db show --resource-group prod-rg --server myserver --name myappdb \
--query "{name:name, status:status, tier:edition, slo:serviceLevelObjective, backupRetention:longTermRetentionBackupResourceId}"
VM configuration:
az vm show --resource-group prod-rg --name vm-prod-1 \
--query "{name:name, vmSize:hardwareProfile.vmSize, osType:osProfile.osType, imageId:storageProfile.imageReference.id, powerState:powerState}"
App Service configuration:
az webapp config show --resource-group prod-rg --name myapp \
--query "{runtime:properties.runtime, ftpEnabled:properties.ftpsState, http20Enabled:properties.http20Enabled, minTlsVersion:properties.minTlsVersion}"
Network configuration:
az network nsg show --resource-group prod-rg --name prod-nsg \
--query "securityRules[].{name:name, protocol:protocol, sourcePort:sourcePortRange, destPort:destinationPortRange, access:access, direction:direction}"
Phase 4: Cost & Metrics Lookup
Estimated monthly cost:
# App Service pricing
az vm show --resource-group prod-rg --name vm-prod-1 \
--query "hardwareProfile.vmSize" | xargs -I {} \
az vm list-prices --location eastus --vmImage UbuntuLTS --query "[?name=='{}'].prices[].value" -o table
Resource usage metrics (for decisions):
# Last 7 days average CPU
az monitor metrics list --resource-group prod-rg --resource-type virtualMachines \
--name vm-prod-1 --metric Percentage\ CPU --start-time 2024-04-16T00:00:00Z \
--aggregation Average --interval PT1H
Phase 5: Validate & Deep Inspect
Checklist before changes:
Resource: myappdb (SQL Database)
✓ Exists in: prod-rg / eastus
✓ Status: Online
✓ Backups enabled: Yes (35-day retention)
✓ Access: Private endpoint configured
✓ Monitoring: Application Insights connected
✓ Owner tag: team-database (found)
Safe to modify: YES (all prerequisites met)
Dependencies (what breaks if we change this?):
# Find all app services using this database
az graph query -q "resources | where properties.connectionStrings contains 'myappdb'"
# Find who has access
az role assignment list --resource-group prod-rg --resource-name myappdb
Recent changes (who touched this?):
az monitor activity-log list --resource-group prod-rg \
--query "[?resourceId contains 'myappdb']" \
--query "[].{time:eventTimestamp, caller:caller, operationName:operationName.value}" \
-o table
Output Contract
Query Summary
- What was searched?
- How many results?
- Time taken?
Resource Table (matching results)
- Name, Type, Location, Status
- Resource Group, Tags
- Relevant config fields
Notable Findings
- ⚠️ Untagged resources
- ⚠️ Old/orphaned resources
- ⚠️ Non-standard configurations
- ✓ Best practices followed
Configuration Details (if requested)
- Current settings
- Recent changes (Activity Log)
- Dependencies (what uses this?)
Suggested Next Steps
- Inspect related resources
- Check cost/metrics
- Validate before changes
Guardrails
- Always confirm scope before broad queries: Querying entire org can take time.
- Check access first: Ensure you have permissions to view resources.
- Avoid destructive commands in lookup workflows: This skill is read-only.
- Mark stale data: If discovery is incomplete, flag assumptions.
- Use Resource Graph for scale: CLI is faster for single subscriptions; Graph for multi-subscription.
- Protect sensitive output: Don't expose API keys or connection strings from config lookups.
- Validate query results: Don't assume 0 results = resource doesn't exist (could be permissions issue).
1---2name: azure-resource-lookup3description: Locate and summarize Azure resources quickly across scopes using consistent query patterns. Use this skill when users ask where resources are, what they are configured as, or need inventory by type, region, or tag.4---56# Azure Resource Lookup78Find Azure resources efficiently across subscriptions and return concise, actionable metadata.910## Use This Skill When1112- The user cannot find a resource in Azure13- The user needs inventory by type, region, tag, or naming pattern14- The user needs configuration details before making changes15- The user needs to verify resource existence or validate naming conventions1617## Context: Lookup Maturity1819**Immature**: Manual searches in portal, incomplete knowledge of resources 20**Developing**: CLI queries, some automation of common lookups 21**Managed**: Scripted queries with filtering, tags for organization → **Target** 22**Optimized**: Auto-indexing, graph-based discovery, dependency visualization2324## Required Inputs2526- **Scope**: Management group, subscription, resource group, or single app name?27- **Resource type**: Specific type (VMs, databases) or keyword search?28- **Filters**: Region, environment tag, owner, creation date range?29- **Required fields**: Basic (id, name, location) or detailed (config, cost, status)?30- **Output format**: Table, JSON, or filtered list?3132## Decision Tree3334```35What are you looking for?36├─ Specific resource by name → Direct query: az resource show --name37├─ All resources of one type → Type filter: az resource list --resource-type38├─ Resources in a region → Location filter: az resource list --location39├─ Resources by tag → Tag filter: az resource list --query "[?tags.Environment=='Prod']"40└─ Unknown (keyword search) → Graph query with semantic search4142How broad is the scope?43├─ Single resource group → Query is fast44├─ Single subscription → Query takes 5-10 seconds45├─ Multiple subscriptions → Use Azure Resource Graph (optimized)46└─ Entire organization → Use Azure Resource Graph with batch mode4748Do you need real-time status or historical data?49├─ Real-time → CLI query (az resource list)50├─ Historical → Query resource logs (Activity logs)51├─ Cost-related → Query Cost Management API52```5354## Workflow5556### Phase 1: Query Resources57581. **Find by name**:59 ```bash60 # Exact match61 az resource show --name "myappdb" --resource-type "Microsoft.Sql/servers/databases"62 63 # Output64 {65 "id": "/subscriptions/abc123/resourceGroups/prod-rg/providers/Microsoft.Sql/servers/myserver/databases/myappdb",66 "name": "myappdb",67 "type": "Microsoft.Sql/servers/databases",68 "location": "eastus",69 "properties": {70 "status": "Online",71 "edition": "Standard",72 "serviceLevelObjective": "S0"73 }74 }75 ```76772. **Find by type** (all VMs in subscription):78 ```bash79 az resource list --resource-type "Microsoft.Compute/virtualMachines" \80 --query "[].{name:name, group:resourceGroup, location:location, vmSize:properties.hardwareProfile.vmSize}" \81 -o table82 83 # Output84 Name Group Location VmSize85 vm-prod-1 prod-rg eastus Standard_D2s_v386 vm-prod-2 prod-rg eastus Standard_D2s_v387 vm-dev-1 dev-rg eastus Standard_B2s88 ```89903. **Find by tag** (all prod resources):91 ```bash92 az resource list --query "[?tags.Environment=='Prod']" \93 --query "[].{name:name, type:type, group:resourceGroup}" \94 -o table95 ```96974. **Find by region**:98 ```bash99 az resource list --location "eastus" \100 --query "[].{name:name, type:type, sku:sku.name}" \101 -o table102 ```1031045. **Find by naming pattern**:105 ```bash106 # All resources starting with "api-"107 az graph query -q "resources | where name startswith 'api-'" \108 -o table109 ```110111### Phase 2: Azure Resource Graph (advanced queries)112113**Why Resource Graph?** Fast, parallel queries across subscriptions without hitting throttle limits.1141151. **Query all subscriptions** (as organization admin):116 ```bash117 # All databases across subscriptions118 az graph query -q "resources | where type == 'microsoft.sql/servers/databases' | project name, resourceGroup, location, properties.status"119 ```1201212. **Find resources by partial name** (fuzzy search):122 ```bash123 az graph query -q "resources | where name contains 'prod' and type contains 'compute'"124 ```1251263. **Find orphaned resources** (no tags, old creation date):127 ```bash128 az graph query -q "resources | where tags == '{}' and tostring(properties.timeCreated) < '2023-01-01'"129 ```1301314. **Find underutilized resources** (check costs):132 ```bash133 # App Service plans with low CPU134 az graph query -q "resources | where type == 'microsoft.web/serverfarms' | project name, resourceGroup, properties.workerCount, properties.sku"135 ```136137### Phase 3: Extract Configuration Details1381391. **Database configuration**:140 ```bash141 az sql db show --resource-group prod-rg --server myserver --name myappdb \142 --query "{name:name, status:status, tier:edition, slo:serviceLevelObjective, backupRetention:longTermRetentionBackupResourceId}"143 ```1441452. **VM configuration**:146 ```bash147 az vm show --resource-group prod-rg --name vm-prod-1 \148 --query "{name:name, vmSize:hardwareProfile.vmSize, osType:osProfile.osType, imageId:storageProfile.imageReference.id, powerState:powerState}"149 ```1501513. **App Service configuration**:152 ```bash153 az webapp config show --resource-group prod-rg --name myapp \154 --query "{runtime:properties.runtime, ftpEnabled:properties.ftpsState, http20Enabled:properties.http20Enabled, minTlsVersion:properties.minTlsVersion}"155 ```1561574. **Network configuration**:158 ```bash159 az network nsg show --resource-group prod-rg --name prod-nsg \160 --query "securityRules[].{name:name, protocol:protocol, sourcePort:sourcePortRange, destPort:destinationPortRange, access:access, direction:direction}"161 ```162163### Phase 4: Cost & Metrics Lookup1641651. **Estimated monthly cost**:166 ```bash167 # App Service pricing168 az vm show --resource-group prod-rg --name vm-prod-1 \169 --query "hardwareProfile.vmSize" | xargs -I {} \170 az vm list-prices --location eastus --vmImage UbuntuLTS --query "[?name=='{}'].prices[].value" -o table171 ```1721732. **Resource usage metrics** (for decisions):174 ```bash175 # Last 7 days average CPU176 az monitor metrics list --resource-group prod-rg --resource-type virtualMachines \177 --name vm-prod-1 --metric Percentage\ CPU --start-time 2024-04-16T00:00:00Z \178 --aggregation Average --interval PT1H179 ```180181### Phase 5: Validate & Deep Inspect1821831. **Checklist before changes**:184 ```185 Resource: myappdb (SQL Database)186 ✓ Exists in: prod-rg / eastus187 ✓ Status: Online188 ✓ Backups enabled: Yes (35-day retention)189 ✓ Access: Private endpoint configured190 ✓ Monitoring: Application Insights connected191 ✓ Owner tag: team-database (found)192 193 Safe to modify: YES (all prerequisites met)194 ```1951962. **Dependencies** (what breaks if we change this?):197 ```bash198 # Find all app services using this database199 az graph query -q "resources | where properties.connectionStrings contains 'myappdb'"200 201 # Find who has access202 az role assignment list --resource-group prod-rg --resource-name myappdb203 ```2042053. **Recent changes** (who touched this?):206 ```bash207 az monitor activity-log list --resource-group prod-rg \208 --query "[?resourceId contains 'myappdb']" \209 --query "[].{time:eventTimestamp, caller:caller, operationName:operationName.value}" \210 -o table211 ```212213## Output Contract2142151. **Query Summary**216 - What was searched?217 - How many results?218 - Time taken?2192202. **Resource Table** (matching results)221 - Name, Type, Location, Status222 - Resource Group, Tags223 - Relevant config fields2242253. **Notable Findings**226 - ⚠️ Untagged resources227 - ⚠️ Old/orphaned resources228 - ⚠️ Non-standard configurations229 - ✓ Best practices followed2302314. **Configuration Details** (if requested)232 - Current settings233 - Recent changes (Activity Log)234 - Dependencies (what uses this?)2352365. **Suggested Next Steps**237 - Inspect related resources238 - Check cost/metrics239 - Validate before changes240241## Guardrails242243- **Always confirm scope before broad queries**: Querying entire org can take time.244- **Check access first**: Ensure you have permissions to view resources.245- **Avoid destructive commands in lookup workflows**: This skill is read-only.246- **Mark stale data**: If discovery is incomplete, flag assumptions.247- **Use Resource Graph for scale**: CLI is faster for single subscriptions; Graph for multi-subscription.248- **Protect sensitive output**: Don't expose API keys or connection strings from config lookups.249- **Validate query results**: Don't assume 0 results = resource doesn't exist (could be permissions issue).