0

I am using the following azurerm function in my code:

public_ips = azurerm.get_vmss_public_ips(access_token, SUBSCRIPTION_ID, 
GROUP_NAME, CUScaleSet)

print(public_ips)

I am getting the following output:

{u'error': {u'message': u"No registered resource provider found for location 'eastus' and API version '2019-03-01' for type 'virtualMachineScaleSets/publicIPAddresses'. The supported api-versions are '2017-03-30, 2017-12-01, 2018-04-01, 2018-06-01, 2018-10-01'. The supported locations are 'eastus, eastus2, westus, centralus, northcentralus, southcentralus, northeurope, westeurope, eastasia, southeastasia, japaneast, japanwest, australiaeast, australiasoutheast, australiacentral, brazilsouth, southindia, centralindia, westindia, canadacentral, canadaeast, westus2, westcentralus, uksouth, ukwest, koreacentral, koreasouth, francecentral, southafricanorth, uaenorth'.", u'code': u'NoRegisteredProviderFound'}}

NOTE: The same piece of code was running a few days ago.

Bhargavi Annadevara
  • 4,923
  • 2
  • 13
  • 30
New_to_work
  • 253
  • 2
  • 5
  • 16
  • I see that you want to get the public ip of your VM's .You can try something like here : https://stackoverflow.com/questions/40728871/get-ip-from-vm-object-using-azure-sdk-in-python Also check this https://github.com/Azure/azure-sdk-for-python/issues/897 – Mohit Verma Aug 22 '19 at 07:09
  • 1
    I will suggest you use the official Azure SDK for python of VMSS [here](https://learn.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2019_03_01.operations.virtualmachinescalesetsoperations?view=azure-python). – Charles Xu Aug 22 '19 at 07:49
  • I want to get IP of the VM in a Virtual Machine Scale Set. Not the VM in a Resource Group. – New_to_work Aug 23 '19 at 07:17

1 Answers1

1

If the requirement is to fetch all the IPs of the VMs in the VMSS instance, you can use the official Azure SDK for Python as follows:

# Imports
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.network import NetworkManagementClient

# Set subscription ID
SUBSCRIPTION_ID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'


def get_credentials():
    credentials = ServicePrincipalCredentials(
        client_id='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
        secret='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
        tenant='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
    )

    return credentials


# Get credentials
credentials = get_credentials()


# Initialize management client
network_client = NetworkManagementClient(
    credentials,
    SUBSCRIPTION_ID
)


def get_vmss_vm_ips():

    # List all network interfaces of the VMSS instance
    vmss_nics = network_client.network_interfaces.list_virtual_machine_scale_set_network_interfaces(
        "<VMSS Resource group name>", "<VMSS instance name>")

    niclist = [nic.serialize() for nic in vmss_nics]

    print "IP addresses in the given VM Scale Set:"

    for nic in niclist:
        ipconf = nic['properties']['ipConfigurations']

        for ip in ipconf:
            print ip['properties']['privateIPAddress']


# Get all IPs of VMs in VMSS
get_vmss_vm_ips()

References:

Hope this helps!

Bhargavi Annadevara
  • 4,923
  • 2
  • 13
  • 30