I’m new to Python programming and I’m trying to create a script that interacts with my Azure Blob storage account. I followed the instruction on the Azure Portal to get the required credentials, and then used the Azure SDK for ...Read more
I’m new to Python programming and I’m trying to create a script that interacts with my Azure Blob storage account. I followed the instruction on the Azure Portal to get the required credentials, and then used the Azure SDK for Python to write some code to perform actions such as listing blobs, uploading and downloading blobs, etc. However, when I try to import the `BlockBlobService` class from the `azure.storage.blob` module, I encounter the error “Cannot import name ‘BlockBlobService'”. I am not sure what’s going on, and I’ve searched through several websites and documentation to try to fix it to no avail.
Here’s my code:
“`python
from azure.storage.blob import BlockBlobService
account_name = ‘myaccountname’
account_key = ‘myaccountkey’
container_name = ‘mycontainername’
block_blob_service = BlockBlobService(account_name=account_name, account_key=account_key)
blobs = block_blob_service.list_blobs(container_name)
for blob in blobs:
print(blob.name)
“`
When I run this script, I get the error message “Cannot import name ‘BlockBlobService'”. I am not sure what the issue is, and I’ve checked that I have installed the `azure-storage-blob` module using pip. I’m also certain that my credentials are correct because I can see the blobs in my container when I use the Azure Portal dashboard. Can anyone please tell me what I’m doing wrong and how I can retrieve the blobs using this script? Your help would be greatly appreciated.
Explore the significant historical events that shaped Turkey on our website. It's a journey into the past.
Explore the significant historical events that shaped Turkey on our website. It’s a journey into the past.
See less