簡體   English   中英

python azure sdk - 列出存儲帳戶 SKU

[英]python azure sdk - To list storage account SKU

我正在為 azure 使用 Python3 SDK。 這是當前安裝的所有模塊的版本詳細信息。 我想使用 SDK 列出存儲帳戶類型/SKU。 不知道該怎么做。

azure-common (1.1.26)
azure-core (1.10.0)
azure-identity (1.5.0)
azure-keyvault-secrets (4.2.0)
azure-mgmt-compute (18.2.0)
azure-mgmt-core (1.2.2)
azure-mgmt-resource (15.0.0)
azure-mgmt-storage (16.0.0)
azure-storage-blob (12.7.1)
msrestazure (0.6.4)

這是來自 Azure 的官方鏈接。 但我想通過代碼列出這些信息。

azure-mgmt-storage==16.0.0SkuOperations class 中有一個list()方法。 由於該方法將為每個可用的區域和存儲類型返回多個 sku,因此您可以使用集合來刪除重復的 SKU 名稱。

from azure.mgmt.storage import StorageManagementClient
from azure.identity import DefaultAzureCredential

storage_client = StorageManagementClient(
    credential=DefaultAzureCredential(),
    subscription_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
)

skus = {sku.name for sku in storage_client.skus.list()}

print(skus)

輸出以下集合:

{'Standard_GZRS', 'Standard_GRS', 'Standard_ZRS', 'Standard_RAGZRS', 'Premium_LRS', 'Premium_ZRS', 'Standard_LRS', 'Standard_RAGRS'}

如果您只是想列出這些 skus,那么您可以迭代該集合:

for sku in skus:
    print(sku)

它在換行符上輸出 SKU,如下所示:

Premium_LRS
Standard_GRS
Standard_GZRS
Premium_ZRS
Standard_LRS
Standard_RAGRS
Standard_RAGZRS
Standard_ZRS

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM