Reputation: 13
I am new to python and trying to connect azure blob storage via azure automation runbook using below code.But the code fails with below error . I am using python 3 runbook and have all the required modules imported and python package added for azure blob and azure core. Any help for the same will be appreciated. Thanks in Advance
Code
from azure.storage import *
from azure.storage.blob import BlobServiceClient
blob_service = BlobServiceClient(account_name='<added blob storage name>', account_key='<added blob storage key>')
blobs = []
marker = None
while True:
batch = blob_service_client.list_blobs('data', marker=marker)
blobs.extend(batch)
if not batch.next_marker:
break
marker = batch.next_marker
for blob in blobs:
print(blob.name)
Upvotes: 0
Views: 2134
Reputation: 1
Do we just need to upload the whl file as shown in screenshot, i a uskng python 3.8 version and getting error.
Upvotes: 0
Reputation: 23111
If you want to manage Azure blob with python3 in Azure runbook, we need to import package azure.storage.blob
with its dependencies.
For example
pip3 download -d <output dir name> azure-storage-blob==12.8.0
3.Runbook
a.code
from azure.storage.blob import BlobServiceClient
connect_str = ''
blob_service_client = BlobServiceClient.from_connection_string(connect_str)
container_client=blob_service_client.get_container_client('test')
blobs = container_client.list_blobs( )
for blob in blobs:
print(blob.name)
Upvotes: 1