azure-sdk-for-net: [BUG] BlobServiceClient can't parse connection string with custom domain and not port 11002

Library name and version

Azure.Storage.Blobs 12.10.0

Describe the bug

When using a custom domain in the blob connection string, for example, https://www.mydomain.com/myaccount, BlobServiceClient(connectionstring) or BlobServiceClient(serviceUri, credential) can’t parse the account name correctly. Account name in BlobServiceClient appears empty after the constructor runs.

Expected behavior

AccountName in BlobServiceClient should be “myaccount” in this example.

Actual behavior

AccountName in BlobServiceClient is “”, causing the subsequent calls to fail.

Reproduction Steps

string cxnString = "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=redacted;BlobEndpoint=https://www.mydomain.com/myaccount;"
BlobServiceClient service = new BlobServiceClient(cxnString);
await service.GetPropertiesAsync(); //throws exception because AccountName in service is empty

Changing the connection string as following works:

string cxnString = "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=redacted;BlobEndpoint=https://www.mydomain.com:11002/myaccount;"
BlobServiceClient service = new BlobServiceClient(cxnString);
await service.GetPropertiesAsync(); //AccountName is correctly parsed

The following code using a different constructor has the same behaviour:

Uri uri = new Uri("https://www.mydomain.com/myaccount");
//Uri uri1 = new Uri("https://www.mydomain.com:11002/myaccount");
StorageSharedKeyCredential credential = new StorageSharedKeyCredential("myaccount", "redacted");
BlobServiceClient service = new BlobServiceClient(serviceUri, credential);
await service.GetPropertiesAsync(); // throws exception with uri, works with uri1

Environment

.NET SDK (reflecting any global.json): Version: 5.0.405 Commit: 63325e1c7d

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

Host (useful for support): Version: 5.0.14 Commit: d5b56c6327

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

.NET runtimes installed: Microsoft.AspNetCore.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

VSCode 1.64.2 C# Extension v1.24.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Hi, not sure this is relevant but I seem to run into a similar issue when using package v12.12.0

The following code seems to run fine

var connectionString = "DefaultEndpointsProtocol=https;AccountName=<accountName>;AccountKey=<accountKey>;BlobEndpoint=https://<myurl>:10000/<accountName>";
var blobServiceClient = new BlobServiceClient(connectionString);

However when I remove the port number, the value of blobServiceClient.AccountName is empty :

var connectionString = "DefaultEndpointsProtocol=https;AccountName=<accountName>;AccountKey=<accountKey>;BlobEndpoint=https://<myurl>/<accountName>";
var blobServiceClient = new BlobServiceClient(connectionString);

Is this the intended behaviour ?