azure-resource-lookup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAzure 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
快速参考
| Property | Value |
|---|---|
| Query Language | KQL (Kusto Query Language subset) |
| CLI Command | |
| Extension | |
| MCP Tool | |
| Best For | Cross-subscription queries, orphaned resources, tag audits |
| 属性 | 值 |
|---|---|
| 查询语言 | KQL(Kusto Query Language子集) |
| CLI命令 | |
| 扩展 | |
| MCP工具 | |
| 最佳适用场景 | 跨订阅查询、孤立资源查找、标签审计 |
MCP Tools
MCP工具
| Tool | Purpose | When to Use |
|---|---|---|
| Generate | Primary tool — generate ARG queries from user intent |
| List available subscriptions | Discover subscription scope before querying |
| List resource groups | Narrow query scope |
| 工具 | 用途 | 使用时机 |
|---|---|---|
| 生成 | 主要工具——根据用户意图生成ARG查询 |
| 列出可用订阅 | 在查询前发现订阅范围 |
| 列出资源组 | 缩小查询范围 |
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 Type | MCP Tool | Coverage |
|---|---|---|
| Virtual Machines | | ✅ Full — list, details, sizes |
| Storage Accounts | | ✅ Full — accounts, blobs, tables |
| Cosmos DB | | ✅ Full — accounts, databases, queries |
| Key Vault | | ⚠️ Partial — secrets/keys only, no vault listing |
| SQL Databases | | ⚠️ Partial — requires resource group name |
| Container Registries | | ✅ Full — list registries |
| Kubernetes (AKS) | | ✅ Full — clusters, node pools |
| App Service / Web Apps | | ❌ No list command — use ARG |
| Container Apps | — | ❌ No MCP tool — use ARG |
| Event Hubs | | ✅ Full — namespaces, hubs |
| Service Bus | | ✅ Full — queues, topics |
If a dedicated tool is available with full coverage, use it. Otherwise proceed to Step 2.
对于单一资源类型的查询,检查是否有专用MCP工具可以处理:
| 资源类型 | MCP工具 | 覆盖范围 |
|---|---|---|
| 虚拟机 | | ✅ 完整——列出、详情、规格 |
| 存储账户 | | ✅ 完整——账户、Blob、表 |
| Cosmos DB | | ✅ 完整——账户、数据库、查询 |
| Key Vault | | ⚠️ 部分——仅支持密钥/机密,不支持列出Vault |
| SQL数据库 | | ⚠️ 部分——需要资源组名称 |
| 容器注册表 | | ✅ 完整——列出注册表 |
| Kubernetes(AKS) | | ✅ 完整——集群、节点池 |
| 应用服务/Web应用 | | ❌ 无列出命令——请使用ARG |
| 容器应用 | — | ❌ 无MCP工具——请使用ARG |
| 事件中心 | | ✅ 完整——命名空间、中心 |
| 服务总线 | | ✅ 完整——队列、主题 |
如果有覆盖完整的专用工具,请使用该工具。否则进入步骤2。
Step 2: Generate the ARG Query
步骤2:生成ARG查询
Use to build the command:
extension_cli_generateaz graph queryyaml
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_generateaz graph queryyaml
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 (JMESPath) to shape output:
--querybash
az graph query -q "<KQL>" --query "data[].{name:name, type:type, rg:resourceGroup}" -o tableUse to limit results. Use to scope.
--first N--subscriptions运行生成的命令。使用(JMESPath)调整输出格式:
--querybash
az graph query -q "<KQL>" --query "data[].{name:name, type:type, rg:resourceGroup}" -o table使用限制结果数量。使用指定查询范围。
--first N--subscriptionsError Handling
错误处理
| Error | Cause | Fix |
|---|---|---|
| Extension not installed | |
| No read access to subscription | Check RBAC — need Reader role |
| Invalid KQL syntax | Verify table/column names; use |
| Empty results | No matching resources or wrong scope | Check |
| 错误 | 原因 | 修复方案 |
|---|---|---|
| 未安装扩展 | 执行 |
| 无订阅读取权限 | 检查RBAC——需要Reader角色 |
查询时出现 | KQL语法无效 | 验证表/列名称;使用 |
| 结果为空 | 无匹配资源或范围错误 | 检查 |
Constraints
约束条件
- ✅ Always use for case-insensitive type matching (types are lowercase)
=~ - ✅ Always scope queries with or
--subscriptionsfor large tenants--first - ✅ 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修改资源(仅支持只读操作)