I would like to retrieve the public IP address associated with a given network interface. I need to do something like
client = NetworkManagementClient(...)
interface = client.network_interfaces.get('rg', 'nic-name')
ip_config_id = interface[0].public_ip_address.id
ip_config = some_magic(ip_config_id) # What goes here?
return ip_config.ip_address
This question suggests that in order to implement the some_magic
routine, I should parse the ID (by splitting on slashes) and call client.public_ip_addresses.get()
. This question indicates that I can call resource_client.resources.get_by_uid
, but that doesn't return a PublicIPAddress
object (I know I can call as_dict
on it and get the data that way).
Is there a way to get an object of the appropriate type (in this case PublicIPAddress
) from an object's ID in Azure (without manually parsing the ID)?