azure-resource-lookup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Azure Resource Lookup

Azure资源查询

List, find, and discover Azure resources of any type across subscriptions and resource groups. Use Azure Resource Graph (ARG) for fast, cross-cutting queries when dedicated MCP tools don't cover the resource type.
跨订阅和资源组列出、查找和发现任意类型的Azure资源。当专用MCP工具不支持该资源类型时,可使用Azure Resource Graph(ARG)进行快速的跨领域查询。

When to Use This Skill

何时使用此技能

Use this skill when the user wants to:
  • List resources of any type (VMs, web apps, storage accounts, container apps, databases, etc.)
  • Show resources in a specific subscription or resource group
  • Query resources across multiple subscriptions or resource types
  • Find orphaned resources (unattached disks, unused NICs, idle IPs)
  • Discover resources missing required tags or configurations
  • Get a resource inventory spanning multiple types
  • Find resources in a specific state (unhealthy, failed provisioning, stopped)
  • Answer "what resources do I have?" or "show me my Azure resources"
💡 Tip: For single-resource-type queries, first check if a dedicated MCP tool can handle it (see routing table below). If none exists, use Azure Resource Graph.
当用户需要以下操作时,使用此技能:
  • 列出任意类型的资源(VM、Web应用、存储账户、容器应用、数据库等)
  • 展示特定订阅或资源组中的资源
  • 跨多个订阅或资源类型查询资源
  • 查找孤立资源(未附加磁盘、未使用的NIC、闲置IP)
  • 发现缺少必要标签或配置的资源
  • 获取涵盖多种类型的资源清单
  • 查找处于特定状态的资源(不健康、部署失败、已停止)
  • 解答“我有哪些资源?”或“展示我的Azure资源”这类问题
💡 提示: 对于单一资源类型的查询,请先检查是否有专用MCP工具可以处理(见下方路由表)。如果没有,再使用Azure Resource Graph。

Quick Reference

快速参考

PropertyValue
Query LanguageKQL (Kusto Query Language subset)
CLI Command
az graph query -q "<KQL>" -o table
Extension
az extension add --name resource-graph
MCP Tool
extension_cli_generate
with intent for
az graph query
Best ForCross-subscription queries, orphaned resources, tag audits
属性
查询语言KQL(Kusto Query Language子集)
CLI命令
az graph query -q "<KQL>" -o table
扩展
az extension add --name resource-graph
MCP工具
extension_cli_generate
,用于生成
az graph query
命令
最佳适用场景跨订阅查询、孤立资源查找、标签审计

MCP Tools

MCP工具

ToolPurposeWhen to Use
extension_cli_generate
Generate
az graph query
commands
Primary tool — generate ARG queries from user intent
mcp_azure_mcp_subscription_list
List available subscriptionsDiscover subscription scope before querying
mcp_azure_mcp_group_list
List resource groupsNarrow query scope
工具用途使用时机
extension_cli_generate
生成
az graph query
命令
主要工具——根据用户意图生成ARG查询
mcp_azure_mcp_subscription_list
列出可用订阅在查询前发现订阅范围
mcp_azure_mcp_group_list
列出资源组缩小查询范围

Workflow

工作流程

Step 1: Check for a Dedicated MCP Tool

步骤1:检查是否有专用MCP工具

For single-resource-type queries, check if a dedicated MCP tool can handle it:
Resource TypeMCP ToolCoverage
Virtual Machines
compute
✅ Full — list, details, sizes
Storage Accounts
storage
✅ Full — accounts, blobs, tables
Cosmos DB
cosmos
✅ Full — accounts, databases, queries
Key Vault
keyvault
⚠️ Partial — secrets/keys only, no vault listing
SQL Databases
sql
⚠️ Partial — requires resource group name
Container Registries
acr
✅ Full — list registries
Kubernetes (AKS)
aks
✅ Full — clusters, node pools
App Service / Web Apps
appservice
❌ No list command — use ARG
Container Apps❌ No MCP tool — use ARG
Event Hubs
eventhubs
✅ Full — namespaces, hubs
Service Bus
servicebus
✅ Full — queues, topics
If a dedicated tool is available with full coverage, use it. Otherwise proceed to Step 2.
对于单一资源类型的查询,检查是否有专用MCP工具可以处理:
资源类型MCP工具覆盖范围
虚拟机
compute
✅ 完整——列出、详情、规格
存储账户
storage
✅ 完整——账户、Blob、表
Cosmos DB
cosmos
✅ 完整——账户、数据库、查询
Key Vault
keyvault
⚠️ 部分——仅支持密钥/机密,不支持列出Vault
SQL数据库
sql
⚠️ 部分——需要资源组名称
容器注册表
acr
✅ 完整——列出注册表
Kubernetes(AKS)
aks
✅ 完整——集群、节点池
应用服务/Web应用
appservice
❌ 无列出命令——请使用ARG
容器应用❌ 无MCP工具——请使用ARG
事件中心
eventhubs
✅ 完整——命名空间、中心
服务总线
servicebus
✅ 完整——队列、主题
如果有覆盖完整的专用工具,请使用该工具。否则进入步骤2。

Step 2: Generate the ARG Query

步骤2:生成ARG查询

Use
extension_cli_generate
to build the
az graph query
command:
yaml
mcp_azure_mcp_extension_cli_generate
  intent: "query Azure Resource Graph to <user's request>"
  cli-type: "az"
See Azure Resource Graph Query Patterns for common KQL patterns.
使用
extension_cli_generate
构建
az graph query
命令:
yaml
mcp_azure_mcp_extension_cli_generate
  intent: "query Azure Resource Graph to <user's request>"
  cli-type: "az"
常见KQL模式请参考Azure Resource Graph查询模式

Step 3: Execute and Format Results

步骤3:执行并格式化结果

Run the generated command. Use
--query
(JMESPath) to shape output:
bash
az graph query -q "<KQL>" --query "data[].{name:name, type:type, rg:resourceGroup}" -o table
Use
--first N
to limit results. Use
--subscriptions
to scope.
运行生成的命令。使用
--query
(JMESPath)调整输出格式:
bash
az graph query -q "<KQL>" --query "data[].{name:name, type:type, rg:resourceGroup}" -o table
使用
--first N
限制结果数量。使用
--subscriptions
指定查询范围。

Error Handling

错误处理

ErrorCauseFix
resource-graph extension not found
Extension not installed
az extension add --name resource-graph
AuthorizationFailed
No read access to subscriptionCheck RBAC — need Reader role
BadRequest
on query
Invalid KQL syntaxVerify table/column names; use
=~
for case-insensitive type matching
Empty resultsNo matching resources or wrong scopeCheck
--subscriptions
flag; verify resource type spelling
错误原因修复方案
resource-graph extension not found
未安装扩展执行
az extension add --name resource-graph
AuthorizationFailed
无订阅读取权限检查RBAC——需要Reader角色
查询时出现
BadRequest
KQL语法无效验证表/列名称;使用
=~
进行不区分大小写的类型匹配
结果为空无匹配资源或范围错误检查
--subscriptions
参数;验证资源类型拼写

Constraints

约束条件

  • Always use
    =~
    for case-insensitive type matching (types are lowercase)
  • Always scope queries with
    --subscriptions
    or
    --first
    for large tenants
  • Prefer dedicated MCP tools for single-resource-type queries
  • Never use ARG for real-time monitoring (data has slight delay)
  • Never attempt mutations through ARG (read-only)
  • 始终使用
    =~
    进行不区分大小写的类型匹配(资源类型为小写)
  • 始终使用
    --subscriptions
    --first
    限制大型租户的查询范围
  • 优先使用专用MCP工具处理单一资源类型的查询
  • 切勿使用ARG进行实时监控(数据存在轻微延迟)
  • 切勿尝试通过ARG修改资源(仅支持只读操作)