Skip to content

Commit f29bb7e

Browse files
author
Yifan Bian
authored
Fix TableServiceClient.AccountName throwing exception when connecting to Azure Storage Emulator with shortcut (Azure#22710)
* Set account name for dev store account
1 parent 2e7e608 commit f29bb7e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

sdk/tables/Azure.Data.Tables/src/TableConnectionString.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ private static TableConnectionString GetDevelopmentStorageAccount(Uri proxyUri)
412412
account.Settings.Add(TableConstants.ConnectionStrings.DevelopmentProxyUriSetting, proxyUri.ToString());
413413
}
414414

415+
account._accountName = credentials.AccountName;
415416
account.IsDevStoreAccount = true;
416417

417418
return account;

sdk/tables/Azure.Data.Tables/tests/TableServiceClientTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ public void ConstructorValidatesArguments()
7171
() => new TableServiceClient(_urlHttp, new TableSharedKeyCredential(_accountName, string.Empty)),
7272
Throws.Nothing,
7373
"The constructor should accept an http url.");
74+
75+
Assert.That(
76+
() => new TableServiceClient((string)null),
77+
Throws.InstanceOf<ArgumentNullException>(),
78+
"The constructor should validate the connectionString");
79+
80+
Assert.That(
81+
() => new TableServiceClient("UseDevelopmentStorage=true"),
82+
Throws.Nothing,
83+
"The constructor should accept a valid connection string");
7484
}
7585

7686
/// <summary>
@@ -88,6 +98,18 @@ public void ServiceMethodsValidateArguments()
8898
Assert.That(async () => await service.DeleteTableAsync(null), Throws.InstanceOf<ArgumentNullException>(), "The method should validate the table name.");
8999
}
90100

101+
[Test]
102+
public void AccountNameCorrectlyReturned()
103+
{
104+
Assert.That(
105+
() => new TableServiceClient(_url, new TableSharedKeyCredential(_accountName, string.Empty)).AccountName,
106+
Is.EqualTo(_accountName));
107+
108+
Assert.That(
109+
() => new TableServiceClient("UseDevelopmentStorage=true").AccountName,
110+
Is.EqualTo("devstoreaccount1"));
111+
}
112+
91113
[Test]
92114
public void GetSasBuilderPopulatesPermissionsAndExpiry()
93115
{

0 commit comments

Comments
 (0)