gpt4 book ai didi

azure - azure python sdk方法中的custom_headers是什么?

转载 作者:行者123 更新时间:2023-12-03 02:49:13 25 4
gpt4 key购买 nike

我正在尝试查找附加到正在运行的 Azure VM 的公共(public) IP 地址。

我已经按照 Get IP from VM object using azure sdk in python 尝试了两个答案但我没有得到所需的输出。获取公共(public)IP:无

    ...:     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}

而使用network_client我得到输出

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

但在这里我得到了所有订阅、所有资源组的输出,基本上我想过滤它们。因此,我认为使用 custom_headers 我们可以进行过滤,但我没有得到我为 custom_headers 创建的 dict 的确切命名约定。

  • 如何获取可用的 custom_headers 的完整列表?
  • 有人可以分享一些列出并获取正在运行/已停止的虚拟机的所有详细信息的示例吗?

最佳答案

简短版本:您的问题已在 Github 上得到解决: https://github.com/Azure/azure-sdk-for-python/issues/897

一些评论:

(我在 MS 的 Python SDK 团队工作)

关于azure - azure python sdk方法中的custom_headers是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56985572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com