question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

As of v12, what is the recommended API to use for downloading Block Blob files?

See original GitHub issue

Query/Question What is THE way someone should be downloading files from Azure Blob Storage (block blobs) using the .NET SDK as of v12.9, in an asynchronous fashion, if the goal is to “stream” it down thru, for example, an ASP.NET controller action (REST endpoint) to a client like a browser, etc. (NOT save to a local file on server)?

There seems to be several available “download” APIs on the BlobClient, but their docs are somewhat vague or ambiguous and the MS Docs don’t seem to clarify any further:

  • DownloadAsync() - marked as not browsable, but de facto way, based on all samples/blogs
  • DownloadStreamingAsync()
  • DownloadContentAsync()
  • DownloadToAsync()
  • OpenReadAsync()

When I looked at the decompiled source for BlobBaseClient.DownloadAsync() method, I see that it is decorated with [EditorBrowsable(EditorBrowsableState.Never)], implying that this API might slowly be on its way out, but without breaking existing code or marking as Obsolete?

I have production code that uses the BlobClient.DownloadAsync() method to download a file from Azure Blob Storage using the Azure.Storage.Blobs nuget package v12.8, and it seems to be working just fine. However, I just upgraded the nuget package and was about to write some new code to deal with extracting zip files stored in Azure Blob…but noticed the above mentioned changes in the latest APIs of the Storage SDK.

Additionally, if trying to do some other operation that is not downloading to a browser client via a REST API, for example, if you’re unzipping a blob file and the extracted files are also going into blob storage, would one be better not downloading but instead opening it via OpenReadAsync()?

I posted similar question on Stack Overflow and was encouraged to raise this as a question/issue here: https://stackoverflow.com/questions/68070143/azure-blob-storage-sdk-v12-blobclient-downloadasync-gone

Environment:

  • Name and version of the Library package used: Azure.Storage.Blobs 12.9.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
kasobol-msftcommented, Jun 28, 2021

@tafs7 The DownloadStreamingAsync is replacement for DownloadAsync. Except slightly different return type please think about this as a rename or new alias for the same functionality. We’ve introduced DownloadContentAsync for scenarios where small sized blobs are used for formats supported by BinaryData type (e.g. json files) thus we wanted to rename existing API to make the download family less ambiguous.

The difference between DownloadStreamingAsync and OpenReadAsync is that the former gives you a network stream (wrapped with few layers but effectively think about it as network stream) which holds on to single connection, the later on the other hand fetches payload in chunks and buffers issuing multiple requests to fetch content. Picking one over the other one depends on the scenario, i.e. if the consuming code is fast and you have good broad network link to storage account then former might be better choice as you avoid multiple req-res exchanges but if the consumer is slow then later might be a good idea as it releases a connection back to the pool right after reading and buffering next chunk. We recommend to perf test your app with both to reveal which is best choice if it’s not obvious.

0reactions
billticommented, Feb 5, 2022

I just spent quite a while working though the blob APIs and options here to stream blobs through Azure Front Door (via ASP.NET Core) which requires range-request support. I wrote up what I think is the best solution at https://ticehurst.com/2022/01/30/blob-streaming.html (final code at the end of the article).

This did take way more research and experimenting than I expected, so if anyone can give it a quick read for any errors or misunderstandings I’d appreciate it. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quickstart: Azure Blob Storage client library for .NET
In this quickstart, you will learn how to use the Azure Blob Storage client library for .NET to create a container and a...
Read more >
Azure Blob Storage SDK v12 - BlobClient DownloadAsync ...
I have production code that uses the BlobClient.DownloadAsync() method to download a file from Azure Blob Storage using the Azure.Storage.Blobs ...
Read more >
Azure Blob Storage using a .NET Core Console Application
This solution is optimized for storing massive amounts of unstructed data (pictures, files or docs for example). You can create containers, upload blobs...
Read more >
FetchAzureBlobStorage_v12
Retrieves the specified blob from Azure Blob Storage and writes its content to the content of the FlowFile. The processor uses Azure Blob...
Read more >
Azure.Storage.Blobs 12.17.0
This client library enables working with the Microsoft Azure Storage Blob service for storing binary and text data. For this release see notes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found