I have looked at the azure cli and tried everything under 'azure vmss' that I could find. I used the armclient and tried different REST request to determine the list. I see several requests in the cli asks for the vmInstanceID for example 'azure vmss restart', 'azure vmss update' and others. My hope is that this will lead to the hostnames of the VMs behind the scale set, or is there another way to get the hostnames.
Asked
Active
Viewed 1,519 times
2 Answers
2
You can use CLI to get the VMSS VM's hostname:
C:>azure vmssvm list -g vmss -n vmss
info: Executing command vmssvm list
data: ResourceGroupName Name ProvisioningState Location
data: ----------------- ------ ----------------- --------
data: VMSS vmss_0 Succeeded eastus
info: vmssvm list command OK
Also you can use PowerShell to get the hostname and instance id:
PS > Get-AzureRmVmssvm -ResourceGroupName "vmss" -VMScaleSetName "vmss"
ResourceGroupName Name Location Sku Capacity InstanceID ProvisioningState
----------------- ---- -------- --- -------- ---------- -----------------
VMSS vmss_0 eastus Standard_A1 0 Succeeded
VMSS vmss_2 eastus Standard_A1 2 Deleting

Jason Ye
- 13,710
- 2
- 16
- 25
0
instance_id=$(az vmss nic list -g $resource_group --vmss-name $vmss_name --query "[?ipConfigurations[0].privateIpAddress == '$current_ipaddr'].virtualMachine.id" -o tsv | awk -F'/' '{print $11}')

Grigory Zhadko
- 1,484
- 1
- 19
- 33
-
2Please explain your answer. – Venkataraman R Jul 20 '21 at 06:14