[BUG] BlobServiceClient can't parse connection string with custom domain and not port 11002
See original GitHub issueLibrary 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:
- Created 2 years ago
- Comments:15 (8 by maintainers)
Top GitHub 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
However when I remove the port number, the value of blobServiceClient.AccountName is empty :
Is this the intended behaviour ?
@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.