whe*_*ere 4 azure azure-virtual-machine
我有一个 Azure VMSS(虚拟机规模集),其中有几个实例,链接到“图像库”。VMSS 的配置方式是它应该始终从图像库中选择特定图像的最新版本。
如何以及在哪里可以看到特定实例上安装了哪个版本的映像?
如果映像库配置为在新实例上安装最新映像,则映像版本可能会因实例而异。实际安装的映像版本存储在storageProfile.imageReference.exactVersionvmss 对象的属性中。
列出现有规模集中特定计算机的已安装映像版本:
az vmss show --resource-group "<resource group name>" \
--subscription "<subscription name>" \
--name <vmss name> \
--instance-id <instance id> \
--query storageProfile.imageReference.exactVersion
Run Code Online (Sandbox Code Playgroud)
回复与图片库中定义的版本号匹配:
"2021.06.1782103"
Run Code Online (Sandbox Code Playgroud)
如果实例 ID 未知,则可以获取现有规模集的所有实例 ID:
az vmss list-instances --resource-group "<resource group name>" \
--subscription "<subscription name>" \
--name <vmss name> \
--query [].instanceId
Run Code Online (Sandbox Code Playgroud)
[
"1141",
"1142",
"1143"
]
Run Code Online (Sandbox Code Playgroud)
为了进一步简化事情,可以列出现有规模集中每台计算机的已安装映像版本。例如,这允许查看所有实例是否都处于同一版本,或者是否有一个实例被遗漏:
az vmss list-instances --resource-group "<resource group name>" \
--subscription "<subscription name>" \
--name <vmss name> \
--query [].storageProfile.imageReference.exactVersion
Run Code Online (Sandbox Code Playgroud)
在具有 3 个实例的示例中,回复可能表明两台计算机使用的是较新版本 (...03),而一台计算机仍使用的是旧版本映像 (...02):
[
"2021.06.1782102",
"2021.06.1782103",
"2021.06.1782103"
]
Run Code Online (Sandbox Code Playgroud)
最后,结合这个还可以同时查询instanceId和安装的镜像版本:
az vmss list-instances --resource-group "<resource group name>" --subscription "<subscription name>" --name <vmss name> --query "[].[instanceId,storageProfile.imageReference.exactVersion]"
[
[
"1141",
"2021.06.1782102"
],
[
"1142",
"2021.06.1782103"
],
[
"1143",
"2021.06.1782103"
]
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2365 次 |
| 最近记录: |