Last active
January 16, 2022 21:31
-
-
Save RachidAZ/7d2d9946cb4ac4d62a4db05560e71051 to your computer and use it in GitHub Desktop.
Get azure blob as stream using SAS key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Azure.Storage.Blobs; | |
using System.IO; | |
static internal MemoryStream GetBlobStreamUsingSAS(string AccountName , string SAS, string Container, string blobName) | |
{ | |
Uri uriAddress = new Uri("https://"+AccountName+ ".blob.core.windows.net/" + SAS); | |
var newurl = uriAddress.Scheme + "://" + uriAddress.Host + "/" + Container + "/" + blobName + uriAddress.Query; | |
BlobClient blobClient = new BlobClient(new Uri(newurl), null); | |
var memoryStream = new MemoryStream(); | |
var downloadBlob=blobClient.DownloadToAsync(memoryStream); | |
var prop=blobClient.GetProperties().Value; | |
var sizeBlob = prop.ContentLength; | |
var t=Task.Factory.StartNew(() => ReportProgressAsnyc(memoryStream.Length, sizeBlob) ); | |
downloadBlob.Wait(); | |
t.Wait(); | |
return memoryStream; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment