Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Update search skill deployment scripts (#1819)
Browse files Browse the repository at this point in the history
* updated deployment scripts

* fixed appsettings properties
  • Loading branch information
lauren-mills authored Jul 11, 2019
1 parent 5d68cfd commit 8275ec5
Show file tree
Hide file tree
Showing 9 changed files with 401 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
}
},
"variables": {
"botEndpoint": "[concat('https://', toLower(parameters('botWebAppName')), '.azurewebsites.net/api/messages')]"
"botEndpoint": "[concat('https://', toLower(parameters('botWebAppName')), '.azurewebsites.net/api/messages')]",
"cleanStorageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]"
},
"resources": [
{
Expand Down Expand Up @@ -107,7 +108,7 @@
"type": "Microsoft.Storage/storageAccounts",
"kind": "StorageV2",
"apiVersion": "2018-07-01",
"name": "[parameters('storageAccountName')]",
"name": "[variables('cleanStorageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS"
Expand Down Expand Up @@ -190,34 +191,38 @@
}
],
"outputs": {
"botWebAppName": {
"type": "string",
"value": "[parameters('botWebAppName')]"
},
"ApplicationInsights": {
"type": "object",
"value": {
"appId": "[reference(resourceId('Microsoft.Insights/components', parameters('appInsightsName'))).AppId]",
"InstrumentationKey": "[reference(resourceId('Microsoft.Insights/components', parameters('appInsightsName'))).InstrumentationKey]"
}
},
"storage": {
"blobStorage": {
"type": "object",
"value": {
"connectionString": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2018-07-01').keys[0].value, ';EndpointSuffix=core.windows.net')]",
"connectionString": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('cleanStorageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('cleanStorageAccountName')), '2018-07-01').keys[0].value, ';EndpointSuffix=core.windows.net')]",
"container": "transcripts"
}
},
"cosmosDb": {
"type": "object",
"value": {
"cosmosDBEndpoint": "[reference(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosDbName'))).documentEndpoint]",
"authkey": "[listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosDbName')), '2015-04-08').primaryMasterKey]",
"authKey": "[listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosDbName')), '2015-04-08').primaryMasterKey]",
"databaseId": "botstate-db",
"collectionId": "botstate-collection"
}
},
"luis": {
"type": "object",
"value": {
"accountName": "[parameters('luisServiceName')]",
"key": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', parameters('luisServiceName')),'2017-04-18').key1]"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ if ($parametersFile) {
--parameters name=$name microsoftAppId=$appId microsoftAppPassword="`"$($appPassword)`""

if ($validation) {
$validation >> $logFile
$validation = $validation | ConvertFrom-Json

if (-not $validation.error) {
Expand All @@ -125,8 +126,9 @@ if ($parametersFile) {
--parameters name=$name microsoftAppId=$appId microsoftAppPassword="`"$($appPassword)`""
}
else {
Write-Host "! Template is not valid with provided parameters." -ForegroundColor DarkRed
Write-Host "! Template is not valid with provided parameters. Review the log for more information." -ForegroundColor DarkRed
Write-Host "! Error: $($validation.error.message)" -ForegroundColor DarkRed
Write-Host "! Log: $($logFile)" -ForegroundColor DarkRed
Write-Host "+ To delete this resource group, run 'az group delete -g $($resourceGroup) --no-wait'" -ForegroundColor Magenta
Break
}
Expand All @@ -140,6 +142,7 @@ else {
--parameters name=$name microsoftAppId=$appId microsoftAppPassword="`"$($appPassword)`""

if ($validation) {
$validation >> $logFile
$validation = $validation | ConvertFrom-Json

if (-not $validation.error) {
Expand All @@ -151,8 +154,9 @@ else {
--parameters name=$name microsoftAppId=$appId microsoftAppPassword="`"$($appPassword)`""
}
else {
Write-Host "! Template is not valid with provided parameters." -ForegroundColor DarkRed
Write-Host "! Error: $($validation.error.message)" -ForegroundColor DarkRed
Write-Host "! Template is not valid with provided parameters. Review the log for more information." -ForegroundColor DarkRed
Write-Host "! Error: $($validation.error.message)" -ForegroundColor DarkRed
Write-Host "! Log: $($logFile)" -ForegroundColor DarkRed
Write-Host "+ To delete this resource group, run 'az group delete -g $($resourceGroup) --no-wait'" -ForegroundColor Magenta
Break
}
Expand All @@ -171,6 +175,8 @@ if ($outputs)
# Log and convert to JSON
$outputs >> $logFile
$outputs = $outputs | ConvertFrom-Json
$outputMap = @{}
$outputs.PSObject.Properties | Foreach-Object { $outputMap[$_.Name] = $_.Value }

# Update appsettings.json
Write-Host "> Updating appsettings.json ..."
Expand All @@ -183,21 +189,19 @@ if ($outputs)

$settings | Add-Member -Type NoteProperty -Force -Name 'microsoftAppId' -Value $appId
$settings | Add-Member -Type NoteProperty -Force -Name 'microsoftAppPassword' -Value $appPassword
if ($outputs.ApplicationInsights) { $settings | Add-Member -Type NoteProperty -Force -Name 'ApplicationInsights' -Value $outputs.ApplicationInsights.value }
if ($outputs.storage) { $settings | Add-Member -Type NoteProperty -Force -Name 'blobStorage' -Value $outputs.storage.value }
if ($outputs.cosmosDb) { $settings | Add-Member -Type NoteProperty -Force -Name 'cosmosDb' -Value $outputs.cosmosDb.value }
if ($outputs.contentModerator) { $settings | Add-Member -Type NoteProperty -Force -Name 'contentModerator' -Value $outputs.contentModerator.value }

foreach ($key in $outputMap.Keys) { $settings | Add-Member -Type NoteProperty -Force -Name $key -Value $outputMap[$key].value }
$settings | ConvertTo-Json -depth 100 | Out-File $(Join-Path $projDir appsettings.json)

if ($outputs.qnaMaker.value.key) { $qnaSubscriptionKey = $outputs.qnaMaker.value.key }

# Delay to let QnA Maker finish setting up
Start-Sleep -s 30

# Deploy cognitive models
Invoke-Expression "$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1') -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -outFolder `"$($projDir)`" -languages `"$($languages)`""
Invoke-Expression "& '$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1')' -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -luisAccountName $($outputs.luis.value.accountName) -luisSubscriptionKey $($outputs.luis.value.key) -resourceGroup $($resourceGroup) -qnaSubscriptionKey '$($qnaSubscriptionKey)' -outFolder '$($projDir)' -languages '$($languages)'"

# Publish bot
Invoke-Expression "$(Join-Path $PSScriptRoot 'publish.ps1') -name $($name) -resourceGroup $($resourceGroup) -projFolder `"$($projDir)`""
Invoke-Expression "& '$(Join-Path $PSScriptRoot 'publish.ps1')' -name $($outputs.botWebAppName.value) -resourceGroup $($resourceGroup) -projFolder '$($projDir)'"

Write-Host "> Done."
}
Expand Down Expand Up @@ -232,4 +236,4 @@ else

Write-Host "+ To delete this resource group, run 'az group delete -g $($resourceGroup) --no-wait'" -ForegroundColor Magenta
Break
}
}
Loading

0 comments on commit 8275ec5

Please sign in to comment.