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)
CodePudding user response:
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: