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!
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With