Skip to content

Commit 1bca62d

Browse files
author
Luis Cabrera
committed
2 parents 47019d8 + 69c18fe commit 1bca62d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

02 - Web UI Template/CognitiveSearch.UI/Controllers/HomeController.cs

+13-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public class HomeController : Controller
2626
private static string[] containerAddresses = null;
2727
private static string[] tokens = null;
2828

29+
// this should match the default value used in appsettings.json.
30+
private static string defaultContainerUriValue = "https://{storage-account-name}.blob.core.windows.net/{container-name}";
31+
2932
public HomeController(IConfiguration configuration)
3033
{
3134
_configuration = configuration;
@@ -278,13 +281,19 @@ private string[] GetContainerSasUris()
278281

279282
// Get token for second indexer data source
280283
containerAddresses[1] = _configuration.GetSection("StorageContainerAddress2")?.Value.ToLower();
281-
CloudBlobContainer container2 = new CloudBlobContainer(new Uri(containerAddresses[1]), new StorageCredentials(accountName, accountKey));
282-
tokens[1] = container2.GetSharedAccessSignature(adHocPolicy, null);
284+
if (!String.Equals(containerAddresses[1], defaultContainerUriValue))
285+
{
286+
CloudBlobContainer container2 = new CloudBlobContainer(new Uri(containerAddresses[1]), new StorageCredentials(accountName, accountKey));
287+
tokens[1] = container2.GetSharedAccessSignature(adHocPolicy, null);
288+
}
283289

284290
// Get token for third indexer data source
285291
containerAddresses[2] = _configuration.GetSection("StorageContainerAddress3")?.Value.ToLower();
286-
CloudBlobContainer container3 = new CloudBlobContainer(new Uri(containerAddresses[2]), new StorageCredentials(accountName, accountKey));
287-
tokens[2] = container3.GetSharedAccessSignature(adHocPolicy, null);
292+
if (!String.Equals(containerAddresses[2], defaultContainerUriValue))
293+
{
294+
CloudBlobContainer container3 = new CloudBlobContainer(new Uri(containerAddresses[2]), new StorageCredentials(accountName, accountKey));
295+
tokens[2] = container3.GetSharedAccessSignature(adHocPolicy, null);
296+
}
288297
}
289298

290299
return tokens;

0 commit comments

Comments
 (0)