You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure资源图查询报错:查找使用特定存储账户的资源失败

解决KQL查找使用特定存储账户的Azure资源问题

错误原因分析

  • resourcecontainers表不存在你指定的ResourceId、ResourceName等列,该表标准列名为id(资源容器ID)、name(资源容器名称)、resourceGroup等,列名不匹配导致报错。
  • 查询逻辑有误:关联resourcecontainers仅能获取存储账户所在的资源组,无法定位到实际使用该存储账户的其他Azure资源。

正确查询思路与示例

要找到使用特定存储账户的资源,核心是扫描所有资源的配置属性,识别出引用了目标存储账户ID或名称的资源。

方法1:查找指定存储账户的关联资源

// 替换为你的目标存储账户名称
let targetStorageAccount = "your-storage-account-name";
// 获取目标存储账户的唯一ID
let storageAccountId = resources
| where type == "Microsoft.Storage/storageAccounts" and name == targetStorageAccount
| project id
| take 1;
// 检索所有引用该存储账户ID的资源
resources
| where properties contains storageAccountId
| project 
    使用存储账户的资源名称 = name,
    资源类型 = type,
    资源组 = resourceGroup,
    关联存储账户 = targetStorageAccount

方法2:批量查找所有存储账户的关联资源

如果需要查看所有存储账户对应的使用资源,可使用以下查询:

// 先获取所有存储账户的基本信息
resources
| where type == "Microsoft.Storage/storageAccounts"
| project 
    存储账户名称 = name,
    存储账户ID = id,
    存储账户资源组 = resourceGroup
| join kind=leftouter (
    // 扫描非存储账户类型的资源,提取其引用的存储账户名称
    resources
    | where type != "Microsoft.Storage/storageAccounts"
    | extend 引用的存储账户列表 = extract_all(@"Microsoft.Storage/storageAccounts/[^""]+", tostring(properties))
    | mv-expand 引用的存储账户列表 to typeof(string)
    | extend 存储账户名称 = substring(引用的存储账户列表, indexof(引用的存储账户列表, "/") + 1)
    | project 
        资源名称 = name,
        资源类型 = type,
        资源组 = resourceGroup,
        存储账户名称
) on 存储账户名称
| where isnotempty(资源名称) // 过滤无关联资源的存储账户
| project 
    存储账户名称,
    存储账户资源组,
    使用资源名称 = 资源名称,
    使用资源类型 = 资源类型,
    使用资源组 = 资源组

注意事项

  • 不同Azure资源引用存储账户的字段格式不同,部分资源可能在properties的特定子字段(如storageAccountId、connectionString)中存储引用,若通用查询有遗漏,可针对特定资源类型调整过滤条件。
  • 确保你拥有足够的RBAC权限,能读取Azure资源图中的所有资源配置信息。

内容的提问来源于stack exchange,提问作者Marius Løkken

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 20:53:13