I am updating my C # solution to use the new Azure SDK 2.0 libraries. I made minor changes to accounting for breaking changes in libraries 2.0, but other than that, this is the same code. I tested against my local storage and everything works fine, but when I test the storage with Azure storage, it takes too long to check if the blob element exists. It literally takes a minute, if not more, to simply return a boolean value indicating whether the element exists or not.
In the code example below, a line that takes a very long time should be "if (! Blob.Exists ())".
public byte[] GetBlobContent(string blobName) { if (blobName == "") return null; var blobClient = _storageAccount.CreateCloudBlobClient(); var container = blobClient.GetContainerReference(_containerName); var blob = container.GetBlockBlobReference(blobName); if (!blob.Exists()) { return null; } byte[] buffer; using (var ms = new MemoryStream()) { blob.DownloadToStream(ms); buffer = ms.ToArray(); } return buffer; }
Are there any additional changes I need to make to my code to make it work the way it was used?
source share