我正在尝试创建一个脚本,它将检索Azure中特定VNET的所有细节。下面是我的python脚本:
from azure.identity import AzureCliCredential
from azure.mgmt.network import NetworkManagementClient
subscription_id = input("Enter the subscription ID where VNET is located: ")
rg_name = input("Enter the resource group where VNET is located: ")
vnet_name = input("Enter the VNET name: ")
credential = AzureCliCredential()
network_client = NetworkManagementClient(credential, subscription_id)
vnet = network_client.virtual_networks.get(rg_name, vnet_name)
print(vnet)以下是产出:
{'additional_properties': {},'id': 'XXXXXXXXX', 'name': 'XXXXXXXXX', 'type': 'Microsoft.Network/virtualNetworks', 'location': 'southeastasia', 'tags': {'owner': 'test', 'dept': 'test-dept'}, 'extended_location': None, 'etag': 'XXXXXXXXX', 'address_space': <azure.mgmt.network.v2021_02_01.models._models_py3.AddressSpace object at 0x000002BC6E1F3C40>, 'dhcp_options': None, 'flow_timeout_in_minutes': None, 'subnets': [<azure.mgmt.network.v2021_02_01.models._models_py3.Subnet object at 0x000002BC6E1F3C70>, <azure.mgmt.network.v2021_02_01.models._models_py3.Subnet object at 0x000002BC6E1F3CA0>, <azure.mgmt.network.v2021_02_01.models._models_py3.Subnet object at 0x000002BC6E1F3CD0>], 'virtual_network_peerings': [], 'resource_guid': 'XXXXXXXXX', 'provisioning_state': 'Succeeded', 'enable_ddos_protection': False, 'enable_vm_protection': None, 'ddos_protection_plan': None, 'bgp_communities': None, 'ip_allocations': None}如您所见,它显示的是_space’:0x000002BC6E1F3C40>上的对象,而不是IP地址。
我尝试使用以下方法导入AddressSpace:
from azure.mgmt.network.v2021_02_01.models._models_py3 import AddressSpace但我似乎搞不懂它是怎么工作的。
发布于 2021-05-27 14:19:39
我认为我们只需要玩Apex传奇和达到捕食者的等级,在那之后,这个代码将工作。
https://stackoverflow.com/questions/67723905
复制相似问题