Home > Asp.net > Download file from Azure Blob Storage to local folder in C#

Download file from Azure Blob Storage to local folder in C#

This post was most recently updated on May 7th, 2019

In this article, we are going to demonstrate how to download a file from Azure Blob Storage.
Since Blob resides inside the container and the container resides inside Azure Storage Account, we need to have access to an Azure Storage Account.
It can be done by getting the Storage Account as the connection string. We can retrieve Azure Storage Account connection string, using Azure Storage Account class.

Install following NuGet packages in your project:
1. Install-Package WindowsAzure.Storage -Version 9.3.3
2. Install-Package Microsoft.Azure.Storage.Blob -Version 10.0.1

Add following namespace to work with Azure Storage:
1. using Microsoft.Azure;
2. using Microsoft.WindowsAzure.Storage;
3. using Microsoft.WindowsAzure.Storage.Blob;

Create connection in web config:

To download from Blob follow following steps:

1. Create a connection to storage account.
2. Create Blob client to retrieve containers and Blobs in the storage.
3. Download file from blob to the local machine.

Code:

Look into Microsoft Azure Storage Explorer for Container and Connection string:

 

This Article is TAGGED in , . BOOKMARK THE permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">