Finding the azure account key with Blob Service Client fails
See original GitHub issueI am using Name: azure-mgmt-storage Version: 16.0.0 Summary: Microsoft Azure Storage Management Client Library for Python python version:3.8.0 Operating System: Windows
for generating a report to find the storage container size. The snippet of my code that I am using is as below
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()
When I evaluate expression blob_service_client.credential, value is
<azure.identity._credentials.client_secret.ClientSecretCredential object at 0x05747E98>
blob_service_client.api_version evaluates to 2020-02-10.
And blob_service_client.credential.account_key or blob_service_client.credential.account_key() evaluates to {AttributeError}'ClientSecretCredential' object has no attribute 'account_key'
or even when I try blob_service_client.credential.keys() I get {AttributeError}'ClientSecretCredential' object has no attribute 'keys' error
Any Azure expert can help me out here? Also connnection strings are another way to approach this problem where I can use:
BlobServiceClient.from_connection_string(connection_string)
for which I am also required to generate the connection_string dynamically, which I am unable to
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)

Top Related StackOverflow Question
Yes @lmazuel , the keys got generated & the
key1.I used it with the container client to list blobs and find out the size. Hence closing this issueNo worries, please just let me know if the code I gave you is enough. Thanks!