0

I have an existing code that uses Microsoft.Azure.Storage.Blob library to upload the blob in Azure Storage and provide a SAS url to the client. But, we have to change that to read the content of the blob using C# code to do further processing.

I have seen various code to download the file using fileName but none with url. Can someone point me to the code that can read the blob from a url?

This is the code that we use to upload the data.

CloudBlobContainer cloudBlobContainer = _blobStorageHelper.CreateCloudBlobContainer(Id);
CloudBlockBlob cloudBlockBlob = _blobStorageHelper.CreateCloudBlockBlob(cloudBlobContainer, localFileName);
cloudBlockBlob.Properties.ContentType = "application/fhir+ndjson";
cloudBlockBlob.UploadFromFile(localFileName);

Now, to download I see that CloudBlockBlob has a method DownloadText() but not sure how can I use it or any other method to read the content from a URL?

0

1 Answer 1

1

You can use CloudBlockBlob(Uri) constructor to create an instance of CloudBlockBlob using a SAS URL. The Uri parameter is the SAS URL.

Other option would be to use CloudBlockBlob(Uri, StorageCredentials) where the Uri parameter is the Blob URL and StorageCredentials is constructed using SAS token.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.