使用python | List函数获取vnet的所有属性只会给出名称

使用python | List函数获取vnet的所有属性只会给出名称,python,azure,azure-virtual-network,Python,Azure,Azure Virtual Network,提前感谢,我想获得vnet的region属性,但使用list函数它只给出name属性。我们是否必须使用另一个函数来获取完整的细节?目前我不能做区域重建。它只适用于re.name from azure.common.credentials import ServicePrincipalCredentials from azure.mgmt.resource import ResourceManagementClient from azure.mgmt.compute import ComputeM

提前感谢,我想获得vnet的region属性,但使用list函数它只给出name属性。我们是否必须使用另一个函数来获取完整的细节?目前我不能做区域重建。它只适用于re.name

from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.network import NetworkManagementClient
from azure.mgmt.compute.models import DiskCreateOption
from azure.mgmt.network.v2017_03_01.models import NetworkSecurityGroup
from azure.mgmt.network.v2017_03_01.models import SecurityRule
import azure.mgmt.network.models

SUBSCRIPTION_ID = 'xxxx'
GROUP_NAME = 'AQRG'
LOCATION = ''
VM_NAME = 'myVM'
VNET_NAME = ''
SUBNET = ''

def List_VNET(network_client):
    result_create = network_client.virtual_networks.list(
            GROUP_NAME,
        )
    global VNET_NAME
    for re in result_create:
        VNET_NAME = re.name
        Region = re.region // This is not valid
    return VNET_NAME



def get_credentials():
    credentials = ServicePrincipalCredentials(
        client_id = 'xxx',
        secret = 'xxx',
        tenant = 'xxxx'
    )
return credentials


if __name__ == "__main__":
    credentials = get_credentials()

resource_group_client = ResourceManagementClient(
    credentials, 
    SUBSCRIPTION_ID
)
network_client = NetworkManagementClient(
    credentials, 
    SUBSCRIPTION_ID
)
compute_client = ComputeManagementClient(
    credentials, 
    SUBSCRIPTION_ID
)


creation_result_listvnet = List_VNET(network_client)
print("------------------------------------------------------")
print(creation_result_listvnet)
input('Press enter to continue...')

它应该是
re.location
,而不是
re.region

我刚刚发现,您可以使用
print(re)
获取虚拟网络的所有属性。然后可以使用输出中的任何属性


仅供参考:的文档,其中列出了属性。

它应该是
re.location
,而不是
re.region

我刚刚发现,您可以使用
print(re)
获取虚拟网络的所有属性。然后可以使用输出中的任何属性


仅供参考:的文档,其中列出了属性。

azure SDK的相关文档:感谢Ivan和rdas的帮助。我将从azure SDK获取更多相关文档:感谢Ivan和rdas的帮助。我会更进一步