question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Finding the azure account key with Blob Service Client fails

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
smoolya17commented, Nov 13, 2020

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 issue

1reaction
lmazuelcommented, Nov 13, 2020

No worries, please just let me know if the code I gave you is enough. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Finding the azure account key with Blob Service Client fails ...
Thank you for the answer. I got access to the keys with storage_client.storage_account.list_keys(resource_group_name, account_name). keys. The ...
Read more >
Cannot access the storage account with the given account key ...
Hi Azure ML Users, my model fails on the 2nd module with the error: AzureMLCompute job failed. BFSMountError: Unable to mount blob fuse...
Read more >
Monitor and troubleshoot Azure Storage (classic logs & metrics)
Use features like storage analytics, client-side logging, and other third-party tools to identify, diagnose, and troubleshoot Azure ...
Read more >
Manage storage account access keys - Azure - Microsoft Learn
View account access keys · In the Azure portal, go to your storage account. · Under Security + networking, select Access keys. ·...
Read more >
Choose how to authorize access to blob data in the Azure portal
Notice that no blobs appear in the list if your Azure AD account lacks permissions to view them. Click on the Switch to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found