小编Mar*_*ark的帖子

在python中使用azure sdk从VM对象获取IP

我正在尝试从 azure 订阅获取所有 IP(附加到虚拟机)。

我已经使用以下命令拉取了所有虚拟机

compute_client = ComputeManagementClient(credentials, subscription_id)
network_client = NetworkManagementClient(credentials,subscription_id)


 for vm in compute_client.virtual_machines.list_all():
      print(vm.network_profile.network_interface)
Run Code Online (Sandbox Code Playgroud)

但network_profile对象似乎只是一个指针,我已通读文档,但无法弄清楚如何将每个虚拟机链接到其附加的IP地址

我遇到了这个:Is there any python API that can get the IP address (internal or external) of Virtual machine in Azure

但似乎有些事情发生了变化。

仅当我知道 Public_IP 地址对象的名称(并非所有机器都有公共 IP)时,我才能解析机器的 IP。

我需要能够获取此网络接口并解析其上的 IP

python cloud azure

4
推荐指数
1
解决办法
6509
查看次数

标签 统计

azure ×1

cloud ×1

python ×1