如何查询Azure VMSS实例计算机名称以进行灵活编排

问题描述 投票:0回答:1

我运行的 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。

azure azure-cli azure-vm-scale-set
1个回答
0
投票

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"
    }

输出:

enter image description here

参考: Azure 中虚拟机规模集的编排模式

© www.soinside.com 2019 - 2024. All rights reserved.