Downloading and Saving a File from Windows Azure BLOB Storage

In this post I will show you to download a file from Azure BLOB.

Set the Connection String as below,

Downloading and saving a File from Windows Azure BLOB storage

Function to download and save file is below,

public void  DownloadFileFromBlob(string fileName, string containerName,string storageConnectionString)

            account = CloudStorageAccount.Parse(RoleEnvironment.


            blobClient = account.CreateCloudBlobClient();

            container = blobClient.GetContainerReference(containerName);

            blob = container.GetBlobReference(fileName);

            MemoryStream memStream = new MemoryStream();


            Response.ContentType = blob.Properties.ContentType;

            Response.AddHeader("Content-Disposition", "Attachment; filename=" + fileName.ToString());

            Response.AddHeader("Content-Length", blob.Properties.Length.ToString());



You need to pass the BLOB name as filename, containerName and connection string to download the file.

Thanks for reading. I hope this post was useful. :)

Up Next
    Ebook Download
    View all
    View all