[英]Python code to connect azure blob storage via azure automation runbook
我是 python 的新手,並嘗試使用以下代碼通過 azure 自動化運行手冊連接 azure blob 存儲。但代碼失敗並出現以下錯誤。 I am using python 3 runbook and have all the required modules imported and python package added for azure blob and azure core. 任何相同的幫助將不勝感激。 提前致謝
代碼
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)
If you want to manage Azure blob with python3 in Azure runbook, we need to import package azure.storage.blob
with its dependencies.
例如
pip3 download -d <output dir name> azure-storage-blob==12.8.0
3.運行手冊
a.代碼
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.