I'm trying to get a list of private IP addresses for all VMs in a Scale Set (none of the VMs deliberately has any public IP addresses). I've found how to get this from az cli
as follows:
az vmss nic list -g ResourceGroup --vmss-name ScaleSetName --query [].{ip:ipConfigurations[0].privateIpAddress} -o tsv
However I'm unable to get the same output using Python SDK. I am using the following basic code:
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.compute import ComputeManagementClient
credentials = ServicePrincipalCredentials(client_id = CLIENT, secret = KEY, tenant = TENANT)
compute_client = ComputeManagementClient(credentials, SUBSCRIPTION)
vmss = compute_client.virtual_machine_scale_sets.get(RG, SC)
print(vmss.virtual_machine_profile.network_profile.network_interface_configurations[0].ip_configurations[0])
Is this the right place in the SDK object model to look for them? From what I understand, the network properties should be at the Scale Set level, and that's the only place in the API where I see anything network-related. However, I only see 'private IP version' in the subsequent properties, and since there are no public IPs, that portion of the properties is blank.