Skip to content

Commit 3de2d5f

Browse files
authored
Extract some hardcoded strings to constants
Extract some hardcoded strings to constants
1 parent 2e20664 commit 3de2d5f

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/ResourceManager/Sql/Commands.Sql/Common/AzureEndpointsCommunicator.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ private async Task<Dictionary<StorageKeyKind, string>> RetrieveStorageKeysAsync(
264264
StringBuilder uriBuilder = new StringBuilder(Context.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ResourceManager).ToString());
265265
uriBuilder.AppendFormat("{0}/listKeys?api-version={1}",
266266
storageAccountId,
267-
isClassicStorage ? "2016-11-01" : "2017-06-01");
267+
isClassicStorage ? ClassicStorageListKeysApiVersion : NonClassicStorageListKeysApiVersion);
268268

269269
// Define an exception to be thrown on failure.
270270
//
@@ -281,8 +281,8 @@ private async Task<Dictionary<StorageKeyKind, string>> RetrieveStorageKeysAsync(
281281
string secondaryKey = null;
282282
if (isClassicStorage)
283283
{
284-
primaryKey = (string)storageAccountKeysResponse["primaryKey"];
285-
secondaryKey = (string)storageAccountKeysResponse["secondaryKey"];
284+
primaryKey = (string)storageAccountKeysResponse[PrimaryKey];
285+
secondaryKey = (string)storageAccountKeysResponse[SecondaryKey];
286286
}
287287
else
288288
{
@@ -367,5 +367,19 @@ private async Task<JToken> SendAsync(string url, HttpMethod method, Exception ex
367367

368368
return JToken.Parse(await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false));
369369
}
370+
371+
/// <summary>
372+
/// Verson of classic storage listKeys REST-API.
373+
/// </summary>
374+
private const string ClassicStorageListKeysApiVersion = "2016-11-01";
375+
376+
/// <summary>
377+
/// Verson of non classic storage listKeys REST-API.
378+
/// </summary>
379+
private const string NonClassicStorageListKeysApiVersion = "2017-06-01";
380+
381+
private const string PrimaryKey = "primaryKey";
382+
383+
private const string SecondaryKey = "secondaryKey";
370384
}
371385
}

0 commit comments

Comments
 (0)