【问题标题】:Get available locations for a service in Azure subscription获取 Azure 订阅中服务的可用位置
【发布时间】:2020-10-12 06:15:24
【问题描述】:

我在 python 中编写代码,我需要找到一种方法来获取特定服务的所有可用位置的列表。 例如,我可以创建存储帐户、SQL 服务器等的所有位置。 有没有办法在 python 中以编程方式实现它?

【问题讨论】:

  • 我可以给你指点 REST API 文档和 Python SDK 中的等效类吗?
  • 理想情况下,我正在寻找可以做到这一点的 python 代码,但这也会有所帮助,是一个很好的开始!
  • 不幸的是对python不太熟悉。虽然提供了答案。希望这会有所帮助。

标签: python azure azure-sql-database azure-storage azure-blob-storage


【解决方案1】:

Azure 中的每个资源都有一个资源提供者(例如,对于存储帐户,提供者是 Microsoft.Storage)。资源提供者 REST API 公开了可以在资源提供者中创建某种资源的位置列表。

您可以在此处阅读有关 API 的更多信息:https://docs.microsoft.com/en-us/rest/api/resources/providers/get(在此页面上查找 ProviderResourceType 部分)。

当我针对我的订阅和 Microsoft.Storage 资源提供程序运行上述 REST API 时,我收到了针对 storageAccounts 资源类型和位置的以下响应:

  "resourceTypes": [
    {
      "resourceType": "storageAccounts",
      "locations": [
        "East US", "East US 2", "West US", "West Europe",
        "East Asia", "Southeast Asia", "Japan East",
        "Japan West", "North Central US", "South Central US",
        "Central US", "North Europe", "Brazil South",
        "Australia East", "Australia Southeast", "South India",
        "Central India", "West India", "Canada East",
        "Canada Central", "West US 2", "West Central US",
        "UK South", "UK West", "Korea Central", "Korea South",
        "France Central", "Australia Central", "South Africa North",
        "UAE North", "Switzerland North", "Germany West Central",
        "Norway East"
      ],

我不熟悉 Python SDK,但我相信与此等效的类是 ProviderResourceType 类。

【讨论】:

  • 不完全是我想要的。这给了我所有 33 个位置,但对于 SQL,例如,我只能在 17 个位置创建服务器。其他 16 个只是抛出一个异常,我目前无法在该区域创建服务器。
  • The other 16 just throws an exception that I can't create servers in this region at this moment. - 这可能是因为 Azure 运行时为紧急服务预留了一些容量。我见过很多用户无法创建资源的问题。不过,这是暂时的情况。
猜你喜欢
  • 1970-01-01
  • 2018-07-21
  • 2020-03-28
  • 1970-01-01
  • 2020-12-26
  • 1970-01-01
  • 2014-02-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多