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.35k stars 4.66k forks source link

[BUG] Blobs with names containing nameless virtual folders are not handled consistently in the SDK #45156

Open aalte opened 2 months ago

aalte commented 2 months ago

Library name and version

Azure.Storage.Blobs 12.21.0

Describe the bug

I have blobs where the name contains nameless directories like //somename/file.txt. When trying to read these I get different behaviors depending on that method I use.

Method 1:

var blobClient = blobContainerClient.GetBlobClient(blobItem.Name);
var tags = await blobClient.GetTagsAsync();

Method 2:

 var blobClient = new BlobClient(connString, blobContainerClient.Name, blobItem.Name);
 var tags = await blobClient.GetTagsAsync();

Method 3:

var blobUri = new Uri($"{blobContainerClient.Uri}/{blobItem.Name}");
var blobClient = new BlobClient(blobUri, new StorageSharedKeyCredential("account-name", "account-key"));
var tags = await blobClient.GetTagsAsync();

See also stack overflow post here: Can not read blobs through BlobContainerClient for blobs with empty folder prefixes

Expected behavior

All methods should work and fetch the tags for the blob.

Actual behavior

Only method 3 work, the two other gives me a RequestFailedException. The resulting request paths are:

Method 1: https://myaccount.blob.core.windows.net/mycontainer/somename/file.txt?comp=tags Method 2: https://myaccount.blob.core.windows.net/mycontainer/somename/file.txt?comp=tags Method 3: https://myaccount.blob.core.windows.net/mycontainer///somename/file.txt?comp=tags

Reproduction Steps

See code examples in description.

Environment

No response

github-actions[bot] commented 2 months ago

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