如何判断我的 VM 是 Azure 中的 Gen1 还是 Gen2?
How to tell if my VM is Gen1 or Gen2 in Azure?
我想知道我的 Azure VM (Windows + Linux) 是 Gen1 还是 Gen2。理想情况下,我想让它通过 az cli
或从实际服务器本身运行。我试过 az vm list -g RG-Name -d
但它并没有真正显示此信息。有谁知道如何获得这个?
好问题。 VM 的实例视图信息中的 hyperVgeneration 属性 公开了有关 VM 的详细信息,其中 V1 表示第 1 代 VM, V2 表示第 2 代 VM。
使用az vm get-instance-view,您可以尝试:
az vm get-instance-view -g <rg-name> -n <vm-name>
并在响应中查找 hyperVgeneration
属性:
{
...
"instanceView": {
"maintenanceRedeployStatus": null,
"computerName": "gen2-BA",
...
"hyperVgeneration": "V2",
...
"osName": "Windows Server 2019 Datacenter",
"osVersion": "Microsoft Windows NT 10.0.17763.0",
},
...
}
向前迈出一步,如果你想为 Gen1/Gen2 个 VM 查询你的订阅,你可以执行以下 Azure CLI 命令:
az vm get-instance-view --ids $(az vm list --query "[].id" -o tsv) --query '[].{VMName:name, OS:storageProfile.osDisk.osType, SKU:storageProfile.imageReference.sku, HyperVgeneration:instanceView.hyperVgeneration}' -o table
响应类似于:
尽管 Gen2 VM 的 SKU 名称也暗示了 Gen1 与 Gen2 的区别,hyperVgeneration
应该是要寻找的 属性。
我想知道我的 Azure VM (Windows + Linux) 是 Gen1 还是 Gen2。理想情况下,我想让它通过 az cli
或从实际服务器本身运行。我试过 az vm list -g RG-Name -d
但它并没有真正显示此信息。有谁知道如何获得这个?
好问题。 VM 的实例视图信息中的 hyperVgeneration 属性 公开了有关 VM 的详细信息,其中 V1 表示第 1 代 VM, V2 表示第 2 代 VM。
使用az vm get-instance-view,您可以尝试:
az vm get-instance-view -g <rg-name> -n <vm-name>
并在响应中查找 hyperVgeneration
属性:
{
...
"instanceView": {
"maintenanceRedeployStatus": null,
"computerName": "gen2-BA",
...
"hyperVgeneration": "V2",
...
"osName": "Windows Server 2019 Datacenter",
"osVersion": "Microsoft Windows NT 10.0.17763.0",
},
...
}
向前迈出一步,如果你想为 Gen1/Gen2 个 VM 查询你的订阅,你可以执行以下 Azure CLI 命令:
az vm get-instance-view --ids $(az vm list --query "[].id" -o tsv) --query '[].{VMName:name, OS:storageProfile.osDisk.osType, SKU:storageProfile.imageReference.sku, HyperVgeneration:instanceView.hyperVgeneration}' -o table
响应类似于:
尽管 Gen2 VM 的 SKU 名称也暗示了 Gen1 与 Gen2 的区别,hyperVgeneration
应该是要寻找的 属性。