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

Azure Resource Graph KQL查询报错:动态字段无法关联SQLVM与磁盘

解决Azure Resource Graph KQL关联磁盘与SQL虚拟机查询的错误

错误原因:KQL的join操作不支持基于dynamic类型的字段作为关联键,原查询中vmid字段是dynamic类型,必须显式转换为字符串类型才能进行join。

修改后的完整查询:

resources
| where type == "microsoft.sqlvirtualmachine/sqlvirtualmachines"
| project id, vmid=tostring(properties.virtualMachineResourceId), name, img=properties.sqlImageOffer, sqlImgOffered=properties.sqlImageSku, sqlLicense=properties.sqlServerLicenseType
| join (
    resources
    | where type == "microsoft.compute/disks"
    | project managedBy=tostring(managedBy), diskSizeGB=properties.diskSizeGB, tier=properties.tier, diskIOPSRW=properties.diskIOPSReadWrite, diskMBpsReadWrite=properties.diskMBpsReadWrite, diskState=properties.diskState
) on $left.vmid == $right.managedBy

关键修改点:

  • 将SQLVM查询中的vmid=properties.virtualMachineResourceId替换为vmid=tostring(properties.virtualMachineResourceId),把dynamic类型的虚拟机资源ID转为字符串
  • 将磁盘查询中的managedBy替换为managedBy=tostring(managedBy),确保关联字段类型与左侧一致
  • 保留原查询的其余逻辑,包括字段投影和join关联条件

内容的提问来源于stack exchange,提问作者Shamsul Hassan

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.29 08:07:55