简体   繁体   中英

ConditionNotMet error while trying to download azure blob using python

I was trying to download azure blob from python using the azure.storage.blob BlobServiceClient. There are various blobs inside the containers which are big in size, the error happens when the code is trying to download files around 100mb or higher.

The code works fine for small blobs, only the bigger blobs are throwing an error: error message:- 在此处输入图像描述

Error while trying to download a 700mb+ blob enter image description here

I have also tried download_to_stream, readinto and other methods in the MS documentation, but everything returns with same error.

My code:-

with open(path, "wb") as file:
    data = blobclient.download_blob()
    for stream in data.chunks():
        file.write(stream)

trying to download files around 100mb or higher

I have reproduced in my environment. and got expected results by using below code:

Blob in Storage Account:

在此处输入图像描述

from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient    
blob_service_client = BlobServiceClient.from_connection_string('DefaultEndpointsProtocol=https;AccountNam8zxS3g==;EndpointSuffix=core.windows.net')   
container_name = 'pool'   
container_client = blob_service_client.get_container_client(container_name)   
print(container_client.download_blob("100MB (1).bin").readall())

在此处输入图像描述

I have got 100mb file downloaded in my environment. Here i used print(container_client.download_blob("100MB (1).bin").readall()) to show the file content.

References taken from:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM