question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] using OpenWriteAsync with BlockBlobClient does not seems to reuse the BlobClientOptions.Retry options

See original GitHub issue

Library name and version

Azure.Storage.Blobs 12.13.0

Describe the bug

I’m using BlobClientOptions to add a different retry. It does not seem to be applied to the BlockBlobClient.

public async Task UploadToBlobAsync(string blobSasUrl, Stream sourceStream, CancellationToken cancellationToken)
        {
            BlockBlobClient blob = new(new Uri(blobSasUrl), new BlobClientOptions
            {
                Retry =
                {
                    Mode = RetryMode.Fixed,
                    MaxRetries = 120,
                    Delay = TimeSpan.FromMilliseconds(500),
                    MaxDelay = TimeSpan.FromMilliseconds(5000)
                }
            });
            using Stream blobStream = await blob.OpenWriteAsync(true, null, cancellationToken);

            await sourceStream.CopyToAsync(blobStream, cancellationToken);
        }

Expected behavior

I would expect to have 120 retries in the log and to have 500 ms between them.

Actual behavior

It seems to have only 4 retries with a very short period of time.

Storageissue

Reproduction Steps

I created a URL with Sas token and I’m trying to upload it. (Not the same service as the one creating it)

Environment

Dotnet 6.0, in a container

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
miaoosscommented, Oct 11, 2022

Is there any way to just override the stream return to retry on this specific error?

2reactions
christianh25commented, Oct 18, 2022

amnguye

I would also recommend waiting for the policy sas token to become valid before attempting to upload, instead of retrying until the policy becomes valid. Just to clarifiy, it’s a Stored Access Policy ?

How do you detect that the policy is now valid without blindly waiting 30 seconds?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implement a retry policy using the Azure Storage client ...
In this code example for blob storage, we'll configure the retry options in the Retry property of the BlobClientOptions class. Then, we'll ...
Read more >
BlockBlobClient.OpenWriteAsync Method - Storage
Opens a stream for writing to the blob. If the blob exists, it will be overwritten.
Read more >
Azure Storage SDK for .NET: How to set RetryPolicy on ...
One set the retry policy when creating BlobServiceClient : var blobServiceClient = new BlobServiceClient (connectionString: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found