I'm trying to download the blob files from Azure using the below code

Download Method :

private static async Task<string> GetPriceString(int seriesId) {
    var maxRetries = 15;
    var storage = CloudStorageAccount.Parse("Storage Account Connection String");
    var blob = storage.CreateCloudBlobClient().GetContainerReference("Container Name")

    var priceString = await Policy.Handle<Exception>()
        .WaitAndRetryAsync(maxRetries, attempt => TimeSpan.FromSeconds(attempt * 0.5))
        .ExecuteAsync(async () => await blob.DownloadTextAsync());
    return priceString;

Calling Code :

int[] seriesIds = { 10, 100 };
List<Task<string>> tasks = new List<Task<string>>();
foreach(var seriesId in seriesIds) {

await Task.WhenAll(tasks);

It works, but the problem is it takes around 30 seconds to read 100 blob files(each files size is around 200kb). Considering the size of the files, the reading speed is very slow.

Is there any better alternative to download the files in parallel, like some native Azure code instead of we manually calling it in parallel ?

0 Answers