Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.47k stars 4.8k forks source link

[BUG] UploadAsync does not respect the "overwrite" parameter #39473

Open dougwaldron opened 1 year ago

dougwaldron commented 1 year ago

Library name and version

Azure.Storage.Blobs 12.18.0

Describe the bug

The documentation for UploadAsync states: "The UploadAsync(Stream, Boolean, CancellationToken) operation creates a new block blob or throws if the blob already exists. Setting overwrite to true allows updating the content of an existing block blob." This is confusing and self-contradictory, but the docs go on to define the "overwrite" parameter:

overwrite: Whether the upload should overwrite any existing blobs. The default value is false.

This leads me to believe I should be able to overwrite an existing blob, by setting "overwrite" is set to true, but it returns an exception instead.

Expected behavior

When I call the method with overwrite equal to true: I expect to be able to overwrite an existing blob.

Actual behavior

Even with "overwrite" set to true, I get an exception:

Unhandled exception. Azure.RequestFailedException: The specified blob already exists.

Reproduction Steps

Run this with the file name for an existing blob:

var blobClient = _containerClient.GetBlobClient(fileName);
await blobClient.UploadAsync(stream, overwrite: true, token);

The code should succeed, but returns an exception.

Environment

No response

github-actions[bot] commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

eramireziceibm commented 5 months ago

what is exception ?

dougwaldron commented 5 months ago

what is exception ?

Azure.RequestFailedException: The specified blob already exists.

eramireziceibm commented 5 months ago

I when trying to replace the file, since when trying with UploadAsync with the overwrite parameter the changes are never reflected

returns 201 and a problem with the Strem of the file, in the writetime and readtime fields.