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

Updated Automotive deployment scripts #1799

Merged
merged 7 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -561,4 +561,4 @@ $PREBUILT:ordinal

> # List entities

> # RegEx entities
> # RegEx entities
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,17 @@
}
],
"outputs": {
"botWebAppName": {
"type": "string",
"value": "[parameters('botWebAppName')]"
},
"ApplicationInsights": {
"type": "object",
"value": {
"InstrumentationKey": "[reference(resourceId('Microsoft.Insights/components', parameters('appInsightsName'))).InstrumentationKey]"
}
},
"storage": {
"blobStorage": {
"type": "object",
"value": {
"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')]",
Expand All @@ -208,14 +212,15 @@
"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]"
}
}
Expand Down
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