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] UploadAsync with BlobRequestConditions fails criteria if providing a RetriableStreamImpl

See original GitHub issue

Describe the bug

Demonstration @ https://github.com/seankearney/azure-storage-sdk-tag-conditions-bug

When a blob is downloaded from storage and then that Stream (Azure.Core.Pipeline.RetriableStream.RetriableStreamImpl) is provided to a subsequent Upload call, the upload will fail if there are BlobRequestConditions.

We’ve discovered a work around where if we copy the Azure.Core.Pipeline.RetriableStream.RetriableStreamImpl to a MemoryStream it will work as expected.

Expected behavior

In this scenario, where we don’t have an existing blob, I would expect to be able to have the blob created given a Stream from a previous DownloadAsync call.

Actual behavior (include Exception or Stack Trace)

Azure.RequestFailedException : The condition specified using HTTP conditional header(s) is not met.
...
Status: 412 (The condition specified using HTTP conditional header(s) is not met.)
ErrorCode: ConditionNotMet

To Reproduce

See provided tests @ https://github.com/seankearney/azure-storage-sdk-tag-conditions-bug

  1. Download a blob from storage
  2. Use that resulting stream as the content of a new blob. As part of the upload, provide BlobUploadOptions that contains a BlobRequestConditions
  3. You should notice that the blob fails to meet the conditions and isn’t persisted

Found Work Around

If the RetryableStreamImpl is copied to a MemoryStream the conditions are satisfied and the blob is persisted.

Environment:

  • Visual Studio 16.9.4
  • Azure.Storage.Blobs 12.8.3
.NET SDK (reflecting any global.json):
Version:   5.0.202
Commit:    db7cc87d51

Runtime Environment:
OS Name:     Windows
OS Version:  10.0.19042
OS Platform: Windows
RID:         win10-x64
Base Path:   C:\Program Files\dotnet\sdk\5.0.202\

Host (useful for support):
 Version: 5.0.5
 Commit:  2f740adc14

.NET SDKs installed:
 5.0.202 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
 Microsoft.AspNetCore.All 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
 Microsoft.AspNetCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
 Microsoft.AspNetCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
 Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
 Microsoft.NETCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
 Microsoft.NETCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
 Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
 Microsoft.WindowsDesktop.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
 Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
amnguyecommented, Jun 14, 2021

Sorry I should have been more specific. In order to do a one shot upload the InitialTransferSize and MaximumTransferSize should be equal to or more than the size of the blob. Or else the blob will be uploaded in multiple blocks and this error will occur.

0reactions
amishra-devcommented, Mar 1, 2022

@amnguye any updates?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Concurrent uploading files may cause System.Net. ...
Actual behavior. Uploading randomly fails (maybe in 1/10 uploading sessions) with the stack trace given in the description.
Read more >
Managing concurrency in Blob storage - Azure
This error indicates to the client that another process has updated the blob since the client first retrieved it.
Read more >
How do I allow the overwriting of blobs from my ASP.NET ...
UploadAsync function overload which takes BlobUploadOptions overwrites the blob. You've to set condition in options if you wish to not overwrite ...
Read more >
Modify Block Blob with Pessimistic Concurrency approach Azure
The Pessimistic Concurrency approach takes a Lease on a Blob Client and allows overwrite only if the Lease is not expired else it'll...
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