简体   繁体   English

无法使用 python 获取 azure 的 su.net id

[英]Can't get the subnet id of azure using python

I want to get the resource id of a su.net in a virtual.network in azure using python, the command i have used is this line: su.nets.network_client.su.nets.get(resource_group,'XXX','XXX')我想使用 python 在 azure 中的 virtual.network 中获取 su.net 的资源 ID,我使用的命令是这一行:su.nets.network_client.su.nets.get(resource_group,'XXX',' XXX')

But what I get is an error: HttpResponseError: (InvalidApiVersionParameter) The api-version '2021-02-01' is invalid.但我得到的是一个错误:HttpResponseError: (InvalidApiVersionParameter) The api-version '2021-02-01' is invalid。 The supported versions are '2021-04-01,2021-01-01,2020-10-01,2020-09-01,2020-08-01,2020-07-01,2020-06-01,2020-05-01,2020-01-01,2019-11-01,2019-10-01,2019-09-01,2019-08-01,2019-07-01,2019-06-01,2019-05-10,2019-05-01,2019-03-01,2018-11-01,2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'.支持的版本是'2021-04-01,2021-01-01,2020-10-01,2020-09-01,2020-08-01,2020-07-01,2020-06-01,2020-05 -01,2020-01-01,2019-11-01,2019-10-01,2019-09-01,2019-08-01,2019-07-01,2019-06-01,2019-05-10 ,2019-05-01,2019-03-01,2018-11-01,2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018 -02-01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09 -01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-预览,2014-04-01,2014-01 -01,2013-03-01,2014-02-26,2014-04'。 I have tried different api versions but it's getting me errors.Any idea please?我尝试了不同的 api 版本,但它让我出错。有什么想法吗? The version of azure-mgmt.network I used is 19.0.0我使用的azure-mgmt.network版本是19.0.0

Please make sure that you have the below two models installed first before executing the script:请确保在执行脚本之前先安装了以下两个模型:

  1. pip install azure-mgmt.network

  2. pip install azure-identity

Then use the below script to get the su.net-id of specific su.net present in your subscription:然后使用以下脚本获取订阅中存在的特定 su.net 的su.net-id

from azure.identity import AzureCliCredential
from azure.mgmt.network import NetworkManagementClient
credential = AzureCliCredential()
subscription_id = "948d4068-xxxx-xxxx-xxxx-e00a844e059b"
network_client = NetworkManagementClient(credential, subscription_id)
resource_group_name = "ansumantest"
location = "West US 2"
virtual_network_name = "ansuman-vnet"
subnet_name = "acisubnet"
Subnet=network_client.subnets.get(resource_group_name, virtual_network_name, subnet_name)
print(Subnet.id)

Output: Output:

在此处输入图像描述

Note: I am using pip version pip 21.2.4 and (python 3.9) .注意:我使用的是 pip 版本pip 21.2.4 and (python 3.9) The pip models version that I am using are as below:我使用的pip型号版本如下:

在此处输入图像描述

I am using the same.network model version as you.我使用的是和你一样的.network model 版本。 But if you are still facing the issue then trying installing the new one ie 19.1.0 .但是,如果您仍然面临问题,请尝试安装新版本,即19.1.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在cloudformation中获取现有vpc su.net的su.net id - How to get the subnet id for existing vpc subnet in cloudformation 我们如何增加 Azure 中的 su.net 大小? - How can we increase the subnet size in Azure? azure terraform su.net = var.XXXXXXX 和 su.net_id = "{${var.XXXXXXX}"" 有什么区别 - azure terraform What is the difference between subnet = var.XXXXXXX versus subnet_id = "{${var.XXXXXXX}"" 通过 Azure 资源图查询获取 Azure 与某个 su.net 关联的资源 - Get Azure resources associated with a subnet through Azure Resource Graph Query 您能否通过 web 请求使用用户名和密码而不使用 client_id 获得 Azure 的访问令牌? - Can you get an access token for Azure with a username and password and without using a client_id via web request? Azure 虚拟网络 Su.net - Azure Virtual Network Subnet 使用默认 VPC id 检索 terraform 中的特定 su.net 不起作用 - Using default VPC id to retrieve specific subnet in terraform not working 如何将 aws_su.net.prod_su.net.*.id 与 aws_su.net.prod2_su.net.*.id 组合成一个列表 - How to combine aws_subnet.prod_subnet.*.id with aws_subnet.prod2_subnet.*.id into a single list 在 azure 中创建多个 su.net - Creating Multiple subnet in azure AWS 将 su.net 查询限制为单个 su.net ID - AWS limit subnet query to a single subnet ID
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM