【发布时间】:2021-02-24 14:02:35
【问题描述】:
我正在使用 名称:天蓝色管理存储 版本:16.0.0 摘要:适用于 Python 的 Microsoft Azure 存储管理客户端库 主页:https://github.com/Azure/azure-sdk-for-python
用于生成报告以查找存储容器大小。 我正在使用的代码的 sn-p 如下
from azure.mgmt.storage import StorageManagementClient
subscription_client = Subscription(tenant=tenant_id, client_id=client_id, secret=client_secret)
service_principals = subscription_client.credentials
subscription_id = subscription_client.find_subscription_id()
storage_client = StorageManagementClient(credential=service_principals, subscription_id=subscription_id)
storage_account_list = storage_client.storage_accounts.list()
for storage_account in storage_account_list:
blob_service_client = BlobServiceClient(account_url=storage_account.primary_endpoints.blob,credential=service_principals)
account_info = blob_service_client.get_service_properties()
keys = blob_service_client.credential.keys()
当我评估表达式 blob_service_client.credential 时,值为
<azure.identity._credentials.client_secret.ClientSecretCredential object at 0x05747E98>
-
blob_service_client.api_version计算结果为2020-02-10。 -
而
blob_service_client.credential.account_key或blob_service_client.credential.account_key()的计算结果为{AttributeError}'ClientSecretCredential' object has no attribute 'account_key' -
甚至当我尝试
blob_service_client.credential.keys()时,我得到{AttributeError}'ClientSecretCredential' object has no attribute 'keys'错误
有任何 Azure 专家可以帮助我吗?连接字符串也是解决此问题的另一种方法,我可以使用:
BlobServiceClient.from_connection_string(connection_string)
我还需要动态生成connection_string,但我无法做到。
【问题讨论】:
标签: python-3.x azure rest azure-storage azure-sdk-python