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] Not overwrite in updateasync #44200

Open eramireziceibm opened 5 months ago

eramireziceibm commented 5 months ago

Library name and version

Azure.Storage.Blobs (version unknown)

Describe the bug

When attempting to update a document using the overwrite: true parameter as per the documentation, the content of the document does not get updated. The response code returned is 201, which is expected, but the changes are not reflected in the blob's content. Upon further inspection of the response, the following error is encountered: ((Azure.Core.Pipeline.HttpClientTransport.PipelineResponse)(new Azure.ResponseDebugView<Azure.Storage.Blobs.Models.BlobContentInfo>(responseBlob).GetRawResponse)).ContentStream.ReadTimeout' threw an exception of type 'System.InvalidOperationException

Expected behavior

The document content should be updated successfully when the overwrite: true parameter is used, and the changes should be reflected in the blob.

Actual behavior

Provide a description of the actual behavior observed. If applicable, please include any error messages, exception stacktraces, or memory dumps: Actual behavior: The document content is not updated despite receiving a 201 response code.

Reproduction Steps

Please include minimal steps to reproduce the problem if possible. E.g., the smallest possible code snippet; or a small project, with steps to run it. If possible, include text as text rather than screenshots (so it shows up in searches):

public async Task<bool> UpdateFileAsync(IVsFile file, string filename, CancellationToken cancellationToken)
{
    if (file == null)
    {
        return false;
    }

    BlobContainerClient container = await GetContainerAsync(_connectionKey, _containerName);
    try
    {
        BlobClient _blobClient = container.GetBlobClient(filename);
        Response<BlobContentInfo> responseBlob = await _blobClient.UploadAsync(file.Stream, overwrite: true, cancellationToken);
        file.LastModified = responseBlob.Value.LastModified;
        return true;
    }
    catch
    {
        return false;
    }
}

// Sample usage
var file = new VsFile
{
    Stream = new MemoryStream(Encoding.UTF8.GetBytes("Updated content"))
};

var result = await UpdateFileAsync(file, "testfile.txt", CancellationToken.None);
Console.WriteLine(result); // Should be true if the update is successful

Environment

.NET SDK: Version: 7.0.409 Commit: 0c6be68fc5

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

Host: Version: 7.0.19 Architecture: x64 Commit: 19f489b8b4

.NET SDKs installed: 3.1.426 [C:\Program Files\dotnet\sdk] 5.0.416 [C:\Program Files\dotnet\sdk] 6.0.422 [C:\Program Files\dotnet\sdk] 7.0.409 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download Other packages in use:

github-actions[bot] commented 5 months ago

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