如何通过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
相关产品推荐
相关产品推荐

