Rob Bagby
Rob Bagby

Reputation: 139

Uploading Azure Blob(s) Async : BeginUploadFromStream vs. BackgroundWorker

I am uploading blobs asynchronously to Azure Blob Storage. I can use CloudBlockBlob.BeginUploadFromStream or I could call the synchronous Upload methods (like UploadFile or PutBlock) with a BackgroundWorker. I am looking for some opinions on the pros and cons of either approach.

I'll get the ball rolling. It appears much easier to report progress back with the BackgroundWorker approach.

Thanks!

Upvotes: 3

Views: 4855

Answers (3)

kwill
kwill

Reputation: 11008

I am updating this old question because I still get a lot of blog hits from noir's post. Please note that there is a new version of my blog post using the *FromStream methods in Azure Storage Client library 2.0. This new code is more performant and more reliable, and still provides all of the progress reporting.

Asynchronous Parallel Block Blob Transfers with Progress Change Notification 2.0

Upvotes: 2

noir
noir

Reputation: 566

Please take a look at this article here.

It describes how to upload blobs using parallel upload for blocks, as well as report progress and parallel upload of blobs themselves.

It also links to this nice article which you might find useful if you don't want to do parallel block uploads.

Upvotes: 1

Drew Marsh
Drew Marsh

Reputation: 33379

BeginUploadFromStream will be more efficient because it uses the asynchronous programming model which will not use up CPU resources while I/O is occurring. If you spin up a BackgroundWorker and call any of the non-APM methods your essentially wasting that thread while things like reading from disk and writing to the network are occuring.

In .NET, you pretty much always want to use the APM model when it's available for maximum efficiency.

Upvotes: 3

Related Questions