Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there an equivalent class or module for powershell AzStorageAccount in azure python SDK?

I’m currently converting powershell scripts to python scripts using azure python sdk.Is there a equivalent class or module to AzStorageAccount to get the list of blob urls using azure python sdk? I check the library azure.mngt.storage doesn’t provide me the info i needed. Thank you

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The package you would want to use to work with data stored in Azure Blob Storage would be azure-storage-blob (https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-python). azure.mngt.storage is the SDK for managing storage account themselves and do not offer data management capabilities.

The code would be something like:

from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient

account_url = "https://<storageaccountname>.blob.core.windows.net"
default_credential = DefaultAzureCredential()

blob_service_client = BlobServiceClient(account_url, credential=default_credential)
container_client = blob_service_client.get_container_client(container_name)
blob_list = container_client.list_blobs()
for blob in blob_list:
    print("\t" + blob.name)

You can find more code samples here: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob/samples.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading