question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] BlobServiceClient can't parse connection string with custom domain and not port 11002

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
marmothonkscommented, May 6, 2022

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 ?

0reactions
PramodValavala-MSFTcommented, Dec 5, 2022

@liupeirong @marmothonks The work to address this will be tracked in the linked feature request above since inference of path style URIs outside of IP-style hosts is currently not supported.

The workaround in the meantime is to use an alternate constructor which doesn’t require a connection string. Closing this in favor of the feature request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure a connection string - Azure Storage
If you've mapped a storage endpoint to a custom domain and omit that endpoint from a connection string, then you will not be...
Read more >
BlobServiceClient cannot connect by connection string ...
The reason you are running into this error is because you are trying to connect to your Storage account from a JavaScript app...
Read more >
BlobServiceClient making wrong calls when Azurite is not on ...
The issue comes does to how the BlobContainerClient.GetBlobClient() attempts to determine the account name from the URI in Azure.Storage.
Read more >
c# - azure blob storage "No valid combination of account ...
It's kinda strange that this fixes the error. In the end CloudStorageAccount.Parse is called with the same connection string so it should work ......
Read more >
Windows Azure Storage connection strings
Connection strings for Windows Azure Storage. Connect using Windows Azure Storage Client.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found