<p>根据我的理解,我认为您应该使用azuresdkforpython获取azurevm的公共和私有ip地址。在</p>
<p>要获取这些ip地址(内部和外部),请参阅下面的代码。在</p>
<pre><code>from azure.mgmt.network import NetworkManagementClient, NetworkManagementClientConfiguration
subscription_id = '33333333-3333-3333-3333-333333333333'
credentials = ...
network_client = NetworkManagementClient(
NetworkManagementClientConfiguration(
credentials,
subscription_id
)
)
GROUP_NAME = 'XXX'
VM_NAME = 'xxx'
PUBLIC_IP_NAME = VM_NAME
public_ip_address = network_client.public_ip_addresses.get(GROUP_NAME, PUBLIC_IP_NAME)
print(public_ip_address.ip_address)
print(public_ip_address.ip_configuration.private_ip_address)
</code></pre>
<p>作为参考,您可以参考下面的文档来了解上面代码的详细信息。在</p>
<ol>
<li><a href="http://azure-sdk-for-python.readthedocs.io/en/latest/resourcemanagementauthentication.html" rel="noreferrer">Resource Management Authentication</a>使用Python作为变量{<cd1>}。在</li>
<li><a href="http://azure-sdk-for-python.readthedocs.io/en/latest/resourcemanagementcomputenetwork.html#create-the-management-client" rel="noreferrer">Create the management client</a>表示变量{<cd2>}。在</li>
<li>有关<code>azure.mgmt.network</code>包的详细信息,请参阅<a href="http://azure-sdk-for-python.readthedocs.io/en/latest/ref/azure.mgmt.network.html" rel="noreferrer">http://azure-sdk-for-python.readthedocs.io/en/latest/ref/azure.mgmt.network.html</a>。在</li>
</ol>