我运行的 az cli 命令是:
az vmss list-instances --resource-group rg-name --name my-vmss-name --output json
使用
osProfile.computerName
返回在统一编排模式下运行的 VMSS 的实例详细信息。
但在灵活编排的情况下,它仅返回实例名称等基本信息,而不返回computerName
。
如何查询灵活编排模式下运行的虚拟机规模集的实例详细信息?
这只是我对灵活的 vmss 的了解:
{
"id": "/subscriptions/xxxxxx",
"instanceId": "my_instance1_fc8548e2",
"location": "northeurope",
"name": "my_instance1_fc8548e2",
"resourceGroup": "my-rg",
"type": "Microsoft.Compute/virtualMachineScaleSets/virtualMachines",
"zones": []
},
{
"id": "/subscriptions/xxxxxxx",
"instanceId": "my_instance1_fda96383",
"location": "northeurope",
"name": "my_instance1_fda96383",
"resourceGroup": "my-rg",
"type": "Microsoft.Compute/virtualMachineScaleSets/virtualMachines",
"zones": []
}
对于统一的 vmss,我有包含所有 vm 详细信息的巨大对象。 powerhsell commandlet Get-AzVmssVM 也不会返回正在运行的 VM 实例的 osprofile。
az vmss list-instances
命令不会返回带有osProfile.computerName
的实例详细信息。
要查询在
flexible编排模式下运行的
VMSS
的实例详细信息,您可以使用 Get-AzVmssVM
cmdlet。
这是获取所有 VMSS
计算机名称的
PowerShell脚本。
$vmss = Get-AzVmss -ResourceGroupName Venkat -VMScaleSetName venkat-vmss -InstanceView:$false -UserData
foreach($vmssnames in $vmss){
$computername = $vmssnames.VirtualMachineProfile.OsProfile.ComputerNamePrefix
Write-Host " VMSS Computer Name $computername"
}
输出: