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.37k stars 4.79k forks source link

[BUG] Cannot connect to Blob Container after Update to new sdk version (InvalidOperationException) #45071

Closed JulianSchmidtke closed 3 months ago

JulianSchmidtke commented 3 months ago

Library name and version

Azure.Storage.Blobs 12.21.0

Describe the bug

After the Update from 12.20.0 to 12.21.0: When connecting to azurite blob emulator i got an InvalidOperationException. Could not connect to real container either.

Expected behavior

The snippet should connect to my account and create the container

Actual behavior

Invalid OperationException

2024-07-18 10:19:25 Unhandled exception. System.InvalidOperationException: Failed to compare two elements in the array.
2024-07-18 10:19:25  ---> System.TypeInitializationException: The type initializer for 'Azure.Storage.StorageSharedKeyPipelinePolicy' threw an exception.
2024-07-18 10:19:25  ---> System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
2024-07-18 10:19:25 en-US is an invalid culture identifier.
2024-07-18 10:19:25    at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
2024-07-18 10:19:25    at Azure.Storage.StorageSharedKeyPipelinePolicy..cctor()
2024-07-18 10:19:25    --- End of inner exception stack trace ---
2024-07-18 10:19:25    at Azure.Storage.StorageSharedKeyPipelinePolicy.<>c.<BuildCanonicalizedHeaders>b__6_0(HttpHeader x, HttpHeader y)
2024-07-18 10:19:25    at System.Collections.Generic.ArraySortHelper`1.InsertionSort(Span`1 keys, Comparison`1 comparer)
2024-07-18 10:19:25    at System.Collections.Generic.ArraySortHelper`1.IntroSort(Span`1 keys, Int32 depthLimit, Comparison`1 comparer)
2024-07-18 10:19:25    at System.Collections.Generic.ArraySortHelper`1.IntrospectiveSort(Span`1 keys, Comparison`1 comparer)
2024-07-18 10:19:25    at System.Collections.Generic.ArraySortHelper`1.Sort(Span`1 keys, Comparison`1 comparer)
2024-07-18 10:19:25    --- End of inner exception stack trace ---
2024-07-18 10:19:25    at System.Collections.Generic.ArraySortHelper`1.Sort(Span`1 keys, Comparison`1 comparer)
2024-07-18 10:19:25    at System.Collections.Generic.List`1.Sort(Comparison`1 comparison)
2024-07-18 10:19:25    at Azure.Storage.StorageSharedKeyPipelinePolicy.BuildCanonicalizedHeaders(StringBuilder stringBuilder, HttpMessage message)
2024-07-18 10:19:25    at Azure.Storage.StorageSharedKeyPipelinePolicy.BuildStringToSign(HttpMessage message)
2024-07-18 10:19:25    at Azure.Storage.StorageSharedKeyPipelinePolicy.OnSendingRequest(HttpMessage message)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.RedirectPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
2024-07-18 10:19:25    at Azure.Core.Pipeline.TaskExtensions.EnsureCompleted(ValueTask task)
2024-07-18 10:19:25    at Azure.Core.Pipeline.RedirectPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.RetryPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
2024-07-18 10:19:25    at Azure.Core.Pipeline.RetryPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
2024-07-18 10:19:25    at Azure.Core.Pipeline.TaskExtensions.EnsureCompleted(ValueTask task)
2024-07-18 10:19:25    at Azure.Core.Pipeline.RetryPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline)
2024-07-18 10:19:25    at Azure.Core.Pipeline.HttpPipeline.Send(HttpMessage message, CancellationToken cancellationToken)
2024-07-18 10:19:25    at Azure.Storage.Blobs.ContainerRestClient.Create(Nullable`1 timeout, IDictionary`2 metadata, Nullable`1 access, String defaultEncryptionScope, Nullable`1 preventEncryptionScopeOverride, CancellationToken cancellationToken)
2024-07-18 10:19:25    at Azure.Storage.Blobs.BlobContainerClient.CreateInternal(PublicAccessType publicAccessType, IDictionary`2 metadata, BlobContainerEncryptionScopeOptions encryptionScopeOptions, Boolean async, CancellationToken cancellationToken, String operationName)
2024-07-18 10:19:25    at Azure.Storage.Blobs.BlobContainerClient.CreateIfNotExistsInternal(PublicAccessType publicAccessType, IDictionary`2 metadata, BlobContainerEncryptionScopeOptions encryptionScopeOptions, Boolean async, CancellationToken cancellationToken)
2024-07-18 10:19:25    at Azure.Core.Pipeline.TaskExtensions.EnsureCompleted[T](Task`1 task)
2024-07-18 10:19:25    at Azure.Storage.Blobs.BlobContainerClient.CreateIfNotExists(PublicAccessType publicAccessType, IDictionary`2 metadata, BlobContainerEncryptionScopeOptions encryptionScopeOptions, CancellationToken cancellationToken)
2024-07-18 10:19:25    at Program.<Main>$(String[] args) in /src/Program.cs:line 23

Reproduction Steps

BlobServiceClient blobServiceClient = new("DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;");
BlobContainerClient blobContainer = blobServiceClient.GetBlobContainerClient("mycontainer");
blobContainer.CreateIfNotExists();

Works with 12.20.0, fails with 12.21.0

Environment

.Net 8.0 Linux Docker Container latest azurite docker image

github-actions[bot] commented 3 months ago

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

JulianSchmidtke commented 3 months ago

Duplicate of #45052

amnguye commented 2 months ago

We released a patch release to fix this issue. Please upgrade accordingly.

https://www.nuget.org/packages/Azure.Storage.Common/12.20.1 https://www.nuget.org/packages/Azure.Storage.Blobs/12.21.1 https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.19.1 https://www.nuget.org/packages/Azure.Storage.Queues/12.19.1 https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.19.1