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

如何通过Azure KQL获取虚拟机规模集的具体OS名称与版本?

调整Azure KQL查询获取VMSS的具体操作系统名称和版本

你当前的查询尝试从osDisk字段提取OS名称和版本,但这些字段通常不会返回具体的发行版信息——VMSS的操作系统详情实际存储在properties.virtualMachineProfile.storageProfile.imageReference字段中。

以下是调整后的查询语句,可提取具体的OS发行商、名称、版本信息:

resources
| where type == "microsoft.compute/virtualmachinescalesets"
| extend
    extensions = properties.virtualMachineProfile.extensionProfile.extensions,
    osType = properties.virtualMachineProfile.storageProfile.osDisk.osType,
    // 从镜像引用字段提取OS详情
    osPublisher = properties.virtualMachineProfile.storageProfile.imageReference.publisher,
    osOffer = properties.virtualMachineProfile.storageProfile.imageReference.offer,
    osSku = properties.virtualMachineProfile.storageProfile.imageReference.sku,
    osImageVersion = properties.virtualMachineProfile.storageProfile.imageReference.version
| project
    name,
    osType,
    osPublisher,
    osOffer,
    osSku,
    osImageVersion,
    // 组合为易读的完整OS名称
    osFullName = strcat(osOffer, " ", osSku)

字段说明:

  • osPublisher:操作系统发行商(例如Canonical、RedHat)
  • osOffer:OS产品名称(例如UbuntuServer、RHEL)
  • osSku:具体版本分支(例如18.04-LTS、7.9)
  • osImageVersion:镜像的具体版本号
  • osFullName:组合后的完整操作系统名称,例如UbuntuServer 18.04-LTS

注:如果VMSS使用的是自定义镜像,imageReference字段的信息可能不完整,此时需要结合自定义镜像的元数据来补充OS详情。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.25 10:45:44