The az cli command I’m running is:
az vmss list-instances --resource-group rg-name --name my-vmss-name --output json
returns instances details with osProfile.computerName
for VMSS running in unified orchestration mode.
But in case of flexible orchestration it returns only basic info like instance name, but not computerName
.
How can I query the instance details for VM Scale Set running in flexible orchestration mode?
That is only what I have for the flexible 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": []
}
For the unified vmss I have huge objects with all vm details.
The powerhsell commandlet Get-AzVmssVM also doesn’t return osprofile for running VM instances.
The instanceView=true
option causes 400 error:
Operation 'VirtualMachineScaleSets.virtualMachines.GET' is not allowed on Virtual Machine Scale Set
2
Answers
The
az vmss list-instances
command does not return the instance details withosProfile.computerName
.VMSS Orchestration mode: Flexible
You can use the below command to fetch the computer name for each instance in the VMSS with flexible orchestration.
Output:
Reference: Orchestration modes for Virtual Machine Scale Sets in Azure
To pull the computer name for each of the instances in VMscaleset in flexible orchestration you can leverage the below script.
I have tested and it is working fine in my local environment and refer to the below screenshot for your reference.