Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload a large file in chunks with parallelism in Azure SDK v12?

In Azure SDK v11, we had the option to specify the ParallelOperationThreadCount through the BlobRequestOptions. In Azure SDK v12, I see that the BlobClientOptions does not have this, and the BlockBlobClient (previously CloudBlockBlob in Azure SDK v11), there is only mention of parallelism in the download methods.

We have three files: one 200MB, one 150MB, and one 20MB. For each file, we want the file to be split into blocks and have those uploaded in parallel. Is this automatically done by the BlockBlobClient? If possible, we would like to do these operations for the 3 files in parallel as well.


1 Answers

You also can take use of StorageTransferOptions in v12.

The sample code below:

   BlobServiceClient blobServiceClient = new BlobServiceClient(conn_str);
   BlobContainerClient containerClient= blobServiceClient.GetBlobContainerClient("xxx"); 
   BlobClient blobClient = containerClient.GetBlobClient("xxx");

   //set it here.
   StorageTransferOptions transferOptions = new StorageTransferOptions();
   //transferOptions.MaximumConcurrency or other settings.       

   blobClient.Upload("xxx", transferOptions:transferOptions);

By the way, for uploading large files, you can also use Microsoft Azure Storage Data Movement Library for better performance.

like image 145
Ivan Yang Avatar answered Oct 22 '25 05:10

Ivan Yang