We've created a folder structure on Azure Storage like below:
parentcontainer -> childcontainer -> {pdffiles are uploaded here}
We have the URL of the stored .pdf
files. We don't want to hard code any container name, just download the file using its URL.
Our current attempt at doing this:
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(StorageConnectionString);
CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer cloudBlobContainer = blobClient.GetRootContainerReference();
CloudBlockBlob blockBlob = cloudBlobContainer.GetBlockBlobReference(pdfFileUrl);
var blobRequestOptions = new BlobRequestOptions
{
RetryPolicy = new NoRetry()
};
// Read content
using (MemoryStream ms = new MemoryStream())
{
blockBlob.DownloadToStream(ms, null, blobRequestOptions);
var array = ms.ToArray();
return ms.ToArray();
}
But we're getting a "400 Bad Request" here:
blockBlob.DownloadToStream(ms, null, blobRequestOptions);
How can we download an Azure BLOB Storage file using only its URL?