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?