请检查 Python SDK 的版本。
我正在使用Python v12 SDK将 blob 上传到 Azure blob 存储,它运行良好。
这是我的python代码:
import os, uuid
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient, __version__
try:
print("Azure Blob storage v" + __version__ + " - Python quickstart sample")
# Quick start code goes here
# Create the BlobServiceClient object which will be used to create a container client
connect_str = os.getenv('AZURE_STORAGE_CONNECTION_STRING')
blob_service_client = BlobServiceClient.from_connection_string(connect_str)
# Get container
container_name = "test"
print(container_name)
# Create the container
container_client = blob_service_client.get_container_client(container_name)
# Create a file in local data directory to upload and download
local_path = "./data"
local_file_name = "Test.csv"
upload_file_path = os.path.join(local_path, local_file_name)
print(upload_file_path)
# Create a blob client using the local file name as the name for the blob
blob_client = blob_service_client.get_blob_client(container=container_name, blob=local_file_name)
print("\nUploading to Azure Storage as blob:\n\t" + local_file_name)
# Upload the file
with open(upload_file_path, "rb") as data:
blob_client.upload_blob(data)
except Exception as ex:
print('Exception:')
print(ex)
当我使用 python 将 csv 文件上传到 Azure blob 存储时,事件触发器触发了管道运行并且运行良好: