1

I'm trying to find public IP address attached to running Azure VM.

I've tried both answers as per Get IP from VM object using azure sdk in python but I'm not getting required output. Getting Public IP: None

    ...:     for interface in vm.network_profile.network_interfaces:
    ...:         name=" ".join(interface.id.split('/')[-1:])
    ...:         print (name)
    ...:         sub="".join(interface.id.split('/')[4])
    ...:         print (sub)
    ...:         thing = network_client.network_interfaces.get(sub, name).ip_configurations
    ...:         for x in thing:
    ...:             print (x.public_ip_address)
    ...:
xxx
xxx
{'additional_properties': {}, 'id': '/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.Network/publicIPAddresses/Test-ip', 'name': None, 'type': None, 'location': None, 'tags': None, 'sku': None, 'public_ip_allocation_method': None, 'public_ip_address_version': None, 'ip_configuration': None, 'dns_settings': None, 'ddos_settings': None, 'ip_tags': None, 'ip_address': None, 'public_ip_prefix': None, 'idle_timeout_in_minutes': None, 'resource_guid': None, 'provisioning_state': None, 'etag': None, 'zones': None}

whereas using network_client I'm getting output

In [6]: from azure.mgmt.network import NetworkManagementClient
In [21]: for i in network_client.public_ip_addresses.list("xxx"):
    ...:     print (i)

But here I'm getting output for all subscriptions, all resource group which basically I want to filter. Hence I think using custom_headers we may filter, but I'm not getting what would be the exact naming convention of dict I'd create for custom_headers.

  • How can I get full list of available custom_headers ?
  • Also can someone please share some example of listing and getting All Details of running/stopped VM?

1 Answer 1

1

Short version: Your question has been addressed on Github already: https://github.com/Azure/azure-sdk-for-python/issues/897

A few comments though:

(I work at MS in the Python SDK team)

Sign up to request clarification or add additional context in comments.

1 Comment

Laurent Mazuel - Thanks for the detailed reply. Yes this is very helpful info. and solved the issue as well.Thanks again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.