Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Storage, using BlobRequestOptions without CloudBlobClient

The app I'm building downloads and uploads some blockblobs on azure. I'm currently using the v6.1 and everything works fine. But i cannot upgrade to v7 because of the following issue :

I'm maybe totally wrong, but I decided not to have a CloudBlobClient in my application because I don't want it to store the connection string. Instead, the container from which I will upload / download is initiated through a SAS URI provided by a web service so my actual (and shortened) download workflow is the following :

//jsonstring contains a SAS URI provided by a web service
var jsonString = await Response.Response.Content.ReadAsStringAsync();
CloudBlobContainer cloudContainer = new CloudBlobContainer(new Uri(jsonString.Replace('"', ' ').Trim()));

ICloudBlob blob = cloudContainer.GetBlockBlobReference(item.blobName);
await blob.FetchAttributesAsync();
blob.ServiceClient.ParallelOperationThreadCount = 10;

asyncresult = m_Blob.BeginDownloadToStream(pstream, blobTransferCompletedCallback, new BlobTransferAsyncState(m_Blob, pstream));

This works very well, but blob.ServiceClient.ParallelOperationThreadCount = 10; is deprecated and from what I've seen yet the supersceding item BlobRequestOptions can only be defined on a CloudBlobClient which I decided (maybe for bad reasons) not to use.

I was considering my various options and was looking for some advices on which one should be the best : 1- A miracle happens and I can use BlobRequestOptions without CloudBlobClient 2- I stay on Azure Storage API v6.1 3- I get a CLoudBLobClient from my MVC web service and I use it 4- Having a connection string in the app is not a security leak so I can use a CloudBlobClient as everyone does on the net

Thanks !

like image 203
mickael ponsot Avatar asked Nov 28 '25 08:11

mickael ponsot


1 Answers

Every method call which can trigger request in Azure Storage Client Library has an overload accepting RequestOption. For example, CloudBlob.BeginDownloadToStream has the overload: CloudBlob.BeginDownloadToStream Method (Stream, AccessCondition, BlobRequestOptions, OperationContext, AsyncCallback, Object).

like image 169
Zhaoxing Lu Avatar answered Nov 29 '25 21:11

Zhaoxing Lu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!