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
The az vmss list-instances
command does not return the instance details with osProfile.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.
vmlist=$(az vmss list-instances --resource-group <RG_name> --name <VMSS_Name> --query [].name -o tsv)
for item in $vmlist
do
computer_name=$(az vm show -n $item -g <RG_name> --query osProfile.computerName -o tsv)
echo "The VMSS instance computer name: $computer_name"
done
Output:
Reference: Orchestration modes for Virtual Machine Scale Sets in Azure