Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 405a11a

Browse files
fixing bugs in deployment script
1 parent 45bafe6 commit 405a11a

File tree

3 files changed

+40
-45
lines changed

3 files changed

+40
-45
lines changed

00 - Resource Deployment/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ There are two options for deploying the resources to Azure for this solution acc
99
1. Provision the required Azure resources
1010
2. Upload sample data to your storage account
1111
3. Create a search index
12-
4. Update your web app's settings to connect to your new Azure Services
12+
4. Print out the values and keys needed for the web app's *appsettings.json*
1313

1414
If you choose to run this script, you can skip the Search Index Creation in the next folder.
1515

1616
2. **Using an ARM Template**: `azuredeploy.json`
1717

1818
To deploy this ARM Template, simply press the button below:
1919

20+
> Please note that this will only deploy the resources. You'll then need to create a search index in the next step.
21+
2022
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fazure-search-knowledge-mining%2Fmaster%2Fazuredeploy.json" target="_blank">
2123
<img src="http://azuredeploy.net/deploybutton.png"/>
2224
</a>
2325

24-
> Please note that this will only deploy the resources. You'll then need to create a search index in the next step.
25-
2626
## Prerequisites
2727

2828
1. Access to an Azure Subscription

00 - Resource Deployment/deploy.ps1

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22
# Licensed under the MIT License.
33

44
Write-Host "Ensuring Azure dependencies are installed."
5-
Install-Module -Name Az
6-
Import-Module -Name Az
7-
Install-Module -Name Az.Search
8-
Import-Module -Name Az.Search
5+
if (!(Get-Module -Name Az)) {
6+
Write-Host "Installing Az PowerShell..."
7+
Install-Module -Name Az
8+
Import-Module -Name Az
9+
}
10+
if (!(Get-Module -Name Az.Search)) {
11+
Write-Host "Installing Az.Search PowerShell..."
12+
Install-Module -Name Az.Search
13+
Import-Module -Name Az.Search
14+
}
915

1016
Write-Host @"
1117
@@ -155,26 +161,16 @@ function Deploy
155161
-Name $storageContainerName `
156162
-Context $storageContext `
157163
-Permission Off
158-
}
159-
160-
CreateStorageAccountAndContainer;
161-
162164

163-
function UploadSampleDocuments
164-
{
165165
Write-Host "Uploading sample_documents directory";
166-
167-
# Note: These use the "Azure" api instead of the "Az" api.
168-
$storageContext = New-AzureStorageContext `
169-
-StorageAccountName $storageAccountName `
170-
-StorageAccountKey $global:storageAccountKey
171-
172166
Push-Location "../sample_documents"
173-
ls -File -Recurse | Set-AzureStorageBlobContent -Container $storageContainerName -Context $storageContext -Force
167+
ls -File -Recurse | Set-AzStorageBlobContent -Container $storageContainerName -Context $storageContext -Force
174168
Pop-Location
175169
}
176170

177-
UploadSampleDocuments;
171+
CreateStorageAccountAndContainer;
172+
173+
178174

179175

180176
function CreateSearchServices
@@ -193,10 +189,9 @@ function Deploy
193189
# Create a new search service
194190
# Alternatively, you can now use the Az.Search module: https://docs.microsoft.com/en-us/azure/search/search-manage-powershell
195191
Write-Host "Creating Search Service";
196-
$searchService = New-AzResourceGroupDeployment `
192+
$searchService = New-AzSearchService `
197193
-ResourceGroupName $resourceGroupName `
198-
-TemplateUri "https://gallery.azure.com/artifact/20151001/Microsoft.Search.1.0.9/DeploymentTemplates/searchServiceDefaultTemplate.json" `
199-
-NameFromTemplate $searchServiceName `
194+
-Name $searchServiceName `
200195
-Sku $searchSku -Location $location `
201196
-PartitionCount 1 `
202197
-ReplicaCount 1
@@ -301,29 +296,21 @@ function Deploy
301296

302297
CreateWebApp;
303298

304-
305-
function WriteAppSettings
299+
function PrintAppsettings
306300
{
307-
Write-Host "Writing App Settings";
308-
309-
# Read the existing settings.
310-
$filePath = "..\02 - Web UI Template\CognitiveSearch.UI\appsettings.json"
311-
$file = ([System.IO.File]::ReadAllText($filePath) | ConvertFrom-Json)
312-
313-
# Update the values.
314-
$file.SearchServiceName = $searchServiceName
315-
$file.SearchApiKey = $global:searchServiceKey
316-
$file.SearchIndexName = $indexName
317-
$file.SearchIndexerName = $indexerName
318-
$file.StorageAccountName = $storageAccountName
319-
$file.StorageAccountKey = $global:storageAccountKey
320-
$file.StorageContainerAddress = ("https://"+$storageAccountName+".blob.core.windows.net/"+$storageContainerName)
321-
322-
# Write the settings to the file.
323-
$file | ConvertTo-Json | Out-File -FilePath $filePath -Encoding utf8 -Force
301+
Write-Host "Copy and paste the following values to update the appsettings.json file described in the next folder:";
302+
Write-Host "------------------------------------------------------------";
303+
Write-Host "SearchServiceName: '$searchServiceName'";
304+
Write-Host "SearchApiKey: '$global:searchServiceKey'";
305+
Write-Host "SearchIndexName: '$indexName'";
306+
Write-Host "SearchIndexerName: '$indexerName'";
307+
Write-Host "StorageAccountName: '$storageAccountName'";
308+
Write-Host "StorageAccountKey: '$global:storageAccountKey'";
309+
$StorageContainerAddress = ("https://"+$storageAccountName+".blob.core.windows.net/"+$storageContainerName)
310+
Write-Host "StorageContainerAddress: '$StorageContainerAddress'";
311+
Write-Host "------------------------------------------------------------";
324312
}
325-
326-
WriteAppSettings;
313+
PrintAppsettings;
327314
}
328315

329316
Deploy;

02 - Web UI Template/CognitiveSearch.UI/appsettings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"Default": "Warning"
66
}
77
},
8+
9+
// Required fields
810
"SearchServiceName": "",
911
"SearchApiKey": "",
1012
"SearchIndexName": "",
@@ -14,9 +16,15 @@
1416
"StorageContainerAddress": "https://{storage-account-name}.blob.core.windows.net/{container-name}",
1517
"KeyField": "metadata_storage_path",
1618
"IsPathBase64Encoded": true,
19+
20+
// Optional instrumentation key
1721
"InstrumentationKey": "",
22+
23+
// Optional container addresses if using more than one indexer:
1824
"StorageContainerAddress2": "https://{storage-account-name}.blob.core.windows.net/{container-name}",
1925
"StorageContainerAddress3": "https://{storage-account-name}.blob.core.windows.net/{container-name}",
26+
27+
// Optional key to an Azure Maps account if you would like to display the geoLocation field in a map
2028
"AzureMapsSubscriptionKey": "",
2129

2230
// Set to the name of a facetable field you would like to represent as a graph.

0 commit comments

Comments
 (0)