调用Azure Quota Python SDK获取Standard NCASv3_T4配额遇资源名错误
Azure Quota SDK调用
quota.get()时含空格/下划线的资源名称报错问题 - 调用Azure Quota SDK的
quota.get()方法时,无空格或下划线的资源名称(如standardNCFamily)可正常执行,但带有空格和下划线的资源名称Standard NCASv3_T4 Family无法调用,返回如下错误:
azure.core.exceptions.HttpResponseError: (InvalidResourceName) Name %60%60Standard%20NCASv3_T4%20Family%60%60 is not valid resource name. Code: InvalidResourceName Message: Name %60%60Standard%20NCASv3_T4%20Family%60%60 is not valid resource name.
- 已尝试多种命名格式均无效,相关官方文档未提及该问题,寻求解决方法。
参考示例代码
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential from azure.mgmt.quota import AzureQuotaExtensionAPI """ # 前提条件 pip install azure-identity pip install azure-mgmt-quota # 使用方法 python quotas_list_quota_limits_for_compute.py 运行示例前,请将AAD应用的客户端ID、租户ID和客户端密钥设置为环境变量:AZURE_CLIENT_ID、AZURE_TENANT_ID、 AZURE_CLIENT_SECRET。有关如何获取这些值的详细信息,请查看相关文档。 """ def main(): client = AzureQuotaExtensionAPI( credential=DefaultAzureCredential(), ) response = client.quota.list( scope="subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus", ) for item in response: print(item) # x-ms-original-file: specification/quota/resource-manager/Microsoft.Quota/preview/2021-03-15-preview/examples/getComputeQuotaLimits.json if __name__ == "__main__": main()
内容的提问来源于stack exchange,提问作者guidingfox
相关产品推荐
相关产品推荐

