From 9b81e1f321e42494072b23fd2127a5eb836fe3b0 Mon Sep 17 00:00:00 2001 From: lauren-mills Date: Tue, 16 Jul 2019 01:44:05 -0700 Subject: [PATCH] Skills - New deployment features (#1845) * automotive skill updates * calendar updates * email skill updates * poi skill updates * todo skill * updated bing search skill * updated news skill * updated reservation skill * updated weather skill * Update template.json * Update template.json * Update template.json * added useLuisGen flag to update script (build pipeline) --- .../Resources/parameters.template.json | 20 ++- .../Deployment/Resources/template.json | 59 ++++--- .../Deployment/Scripts/deploy.ps1 | 4 +- .../Scripts/deploy_cognitive_models.ps1 | 11 +- .../Scripts/update_cognitive_models.ps1 | 161 +++++++++--------- .../automotiveskill/cognitivemodels.json | 4 + .../Resources/parameters.template.json | 20 ++- .../Deployment/Resources/template.json | 59 ++++--- .../Deployment/Scripts/deploy.ps1 | 4 +- .../Scripts/deploy_cognitive_models.ps1 | 11 +- .../Scripts/update_cognitive_models.ps1 | 161 +++++++++--------- .../calendarskill/cognitivemodels.json | 2 + .../Resources/parameters.template.json | 20 ++- .../Deployment/Resources/template.json | 59 ++++--- .../emailskill/Deployment/Scripts/deploy.ps1 | 4 +- .../Scripts/deploy_cognitive_models.ps1 | 11 +- .../Scripts/update_cognitive_models.ps1 | 161 +++++++++--------- .../emailskill/cognitivemodels.json | 2 + .../Resources/parameters.template.json | 21 ++- .../Deployment/Resources/template.json | 57 ++++--- .../Deployment/Scripts/deploy.ps1 | 4 +- .../Scripts/deploy_cognitive_models.ps1 | 11 +- .../Scripts/update_cognitive_models.ps1 | 161 +++++++++--------- .../bingsearchskill/cognitivemodels.json | 2 + .../Resources/parameters.template.json | 20 ++- .../Deployment/Resources/template.json | 55 +++--- .../newsskill/Deployment/Scripts/deploy.ps1 | 4 +- .../Scripts/deploy_cognitive_models.ps1 | 11 +- .../Scripts/update_cognitive_models.ps1 | 161 +++++++++--------- .../newsskill/cognitivemodels.json | 2 + .../Resources/parameters.template.json | 20 ++- .../Deployment/Resources/template.json | 55 +++--- .../Deployment/Scripts/deploy.ps1 | 4 +- .../Scripts/deploy_cognitive_models.ps1 | 11 +- .../Scripts/update_cognitive_models.ps1 | 161 +++++++++--------- .../restaurantbooking/cognitivemodels.json | 2 + .../Resources/parameters.template.json | 21 ++- .../Deployment/Resources/template.json | 57 ++++--- .../Deployment/Scripts/deploy.ps1 | 4 +- .../Scripts/deploy_cognitive_models.ps1 | 11 +- .../Scripts/update_cognitive_models.ps1 | 161 +++++++++--------- .../weatherskill/cognitivemodels.json | 2 + .../Resources/parameters.template.json | 20 ++- .../Deployment/Resources/template.json | 55 +++--- .../Deployment/Scripts/deploy.ps1 | 4 +- .../Scripts/deploy_cognitive_models.ps1 | 11 +- .../Scripts/update_cognitive_models.ps1 | 161 +++++++++--------- .../pointofinterestskill/cognitivemodels.json | 2 + .../Resources/parameters.template.json | 20 ++- .../Deployment/Resources/template.json | 57 ++++--- .../todoskill/Deployment/Scripts/deploy.ps1 | 4 +- .../Scripts/deploy_cognitive_models.ps1 | 11 +- .../Scripts/update_cognitive_models.ps1 | 161 +++++++++--------- .../todoskill/todoskill/cognitivemodels.json | 2 + 54 files changed, 1323 insertions(+), 976 deletions(-) diff --git a/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Resources/parameters.template.json b/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Resources/parameters.template.json index 41a2013cad..95841eb589 100644 --- a/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Resources/parameters.template.json +++ b/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Resources/parameters.template.json @@ -2,11 +2,23 @@ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - "appInsightsLocation": { - "value": "westus2" + "useCosmosDb": { + "value": false }, - "luisServiceLocation": { - "value": "westus" + "useStorage": { + "value": false + }, + "appServicePlanSku": { + "value": { + "tier": "Free", + "name": "F1" + } + }, + "botServiceSku": { + "value": "F0" + }, + "luisServiceSku": { + "value": "F0" } } } \ No newline at end of file diff --git a/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Resources/template.json b/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Resources/template.json index a962277a51..b6aaee7f85 100644 --- a/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Resources/template.json +++ b/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Resources/template.json @@ -10,23 +10,35 @@ "type": "string", "defaultValue": "[resourceGroup().location]" }, + "suffix": { + "type": "string", + "defaultValue": "[take(uniqueString(resourceGroup().id), 7)]" + }, "microsoftAppId": { "type": "string" }, "microsoftAppPassword": { "type": "string" }, + "useCosmosDb": { + "type": "bool", + "defaultValue": true + }, "cosmosDbName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" + }, + "useStorage": { + "type": "bool", + "defaultValue": true }, "storageAccountName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanSku": { "type": "object", @@ -37,19 +49,19 @@ }, "appInsightsName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appInsightsLocation": { "type": "string", - "defaultValue": "westus2" + "defaultValue": "[resourceGroup().location]" }, "botWebAppName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceSku": { "type": "string", @@ -57,7 +69,7 @@ }, "luisServiceName": { "type": "string", - "defaultValue": "[concat(parameters('name'), '-luis')]" + "defaultValue": "[concat(parameters('name'), '-luis-', parameters('suffix'))]" }, "luisServiceSku": { "type": "string", @@ -69,8 +81,10 @@ } }, "variables": { - "botEndpoint": "[concat('https://', toLower(parameters('botWebAppName')), '.azurewebsites.net/api/messages')]", - "cleanStorageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]" + "botWebAppName": "[replace(parameters('botWebAppName'), '_', '')]", + "storageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]", + "cosmosDbAccountName": "[toLower(take(replace(parameters('cosmosDbName'), '_', ''), 31))]", + "botEndpoint": "[concat('https://', toLower(variables('botWebAppName')), '.azurewebsites.net/api/messages')]" }, "resources": [ { @@ -91,7 +105,7 @@ "type": "Microsoft.DocumentDB/databaseAccounts", "kind": "GlobalDocumentDB", "apiVersion": "2015-04-08", - "name": "[parameters('cosmosDbName')]", + "name": "[variables('cosmosDbAccountName')]", "location": "[parameters('location')]", "properties": { "databaseAccountOfferType": "Standard", @@ -101,18 +115,20 @@ "failoverPriority": 0 } ] - } + }, + "condition": "[parameters('useCosmosDb')]" }, { "comments": "storage account", "type": "Microsoft.Storage/storageAccounts", "kind": "StorageV2", "apiVersion": "2018-07-01", - "name": "[variables('cleanStorageAccountName')]", + "name": "[variables('storageAccountName')]", "location": "[parameters('location')]", "sku": { "name": "Standard_LRS" - } + }, + "condition": "[parameters('useStorage')]" }, { "comments": "app service plan", @@ -138,7 +154,7 @@ "comments": "bot web app", "type": "Microsoft.Web/sites", "apiVersion": "2018-02-01", - "name": "[parameters('botWebAppName')]", + "name": "[variables('botWebAppName')]", "location": "[parameters('location')]", "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]", @@ -193,7 +209,7 @@ "outputs": { "botWebAppName": { "type": "string", - "value": "[parameters('botWebAppName')]" + "value": "[variables('botWebAppName')]" }, "ApplicationInsights": { "type": "object", @@ -204,15 +220,15 @@ "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')]", + "connectionString": "[if(parameters('useStorage'), concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '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]", + "cosmosDBEndpoint": "[if(parameters('useCosmosDb'), reference(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName'))).documentEndpoint, '')]", + "authKey": "[if(parameters('useCosmosDb'), listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName')), '2015-04-08').primaryMasterKey, '')]", "databaseId": "botstate-db", "collectionId": "botstate-collection" } @@ -221,8 +237,9 @@ "type": "object", "value": { "accountName": "[parameters('luisServiceName')]", + "region": "[parameters('luisServiceLocation')]", "key": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', parameters('luisServiceName')),'2017-04-18').key1]" - } + } } } -} \ No newline at end of file +} diff --git a/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Scripts/deploy.ps1 b/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Scripts/deploy.ps1 index 0b79e0c717..78cbf4e5fc 100644 --- a/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Scripts/deploy.ps1 +++ b/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Scripts/deploy.ps1 @@ -79,7 +79,7 @@ if (-not $appId) { # Create app registration $app = (az ad app create ` --display-name $name ` - --password $appPassword ` + --password `"$($appPassword)`" ` --available-to-other-tenants ` --reply-urls 'https://token.botframework.com/.auth/web/redirect') @@ -198,7 +198,7 @@ if ($outputs) Start-Sleep -s 30 # Deploy cognitive models - 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)'" + Invoke-Expression "& '$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1')' -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -luisAccountName $($outputs.luis.value.accountName) -luisAccountRegion $($outputs.luis.value.region) -luisSubscriptionKey $($outputs.luis.value.key) -resourceGroup $($resourceGroup) -qnaSubscriptionKey '$($qnaSubscriptionKey)' -outFolder '$($projDir)' -languages '$($languages)'" # Publish bot Invoke-Expression "& '$(Join-Path $PSScriptRoot 'publish.ps1')' -name $($outputs.botWebAppName.value) -resourceGroup $($resourceGroup) -projFolder '$($projDir)'" diff --git a/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Scripts/deploy_cognitive_models.ps1 b/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Scripts/deploy_cognitive_models.ps1 index 22b708c23c..e3dfbfcd60 100644 --- a/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Scripts/deploy_cognitive_models.ps1 +++ b/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Scripts/deploy_cognitive_models.ps1 @@ -5,6 +5,7 @@ Param( [string] $luisAuthoringRegion, [string] $luisAuthoringKey, [string] $luisAccountName, + [string] $luisAccountRegion, [string] $luisSubscriptionKey, [string] $qnaSubscriptionKey, [string] $resourceGroup, @@ -86,6 +87,10 @@ if (-not $luisSubscriptionKey) { } } +if (-not $luisAccountRegion) { + $luisAccountRegion = Read-Host "? LUIS Service Location" +} + if (-not $qnaSubscriptionKey) { $useQna = $false } @@ -178,9 +183,10 @@ foreach ($language in $languageArr) name = $luisApp.name appid = $luisApp.id authoringkey = $luisAuthoringKey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey version = $luisApp.activeVersion - region = $luisAuthoringRegion + region = $luisAccountRegion } } else { @@ -279,8 +285,9 @@ foreach ($language in $languageArr) name = $dispatchApp.name appid = $dispatchApp.appId authoringkey = $luisauthoringkey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey - region = $luisAuthoringRegion + region = $luisAccountRegion } } } diff --git a/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Scripts/update_cognitive_models.ps1 b/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Scripts/update_cognitive_models.ps1 index e015ff3a63..827dee559a 100644 --- a/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Scripts/update_cognitive_models.ps1 +++ b/skills/src/csharp/automotiveskill/automotiveskill/Deployment/Scripts/update_cognitive_models.ps1 @@ -2,6 +2,7 @@ Param( [switch] $RemoteToLocal, + [switch] $useLuisGen = $true, [string] $configFile = $(Join-Path (Get-Location) 'cognitivemodels.json'), [string] $dispatchFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'Dispatch'), [string] $luisFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'LU'), @@ -15,14 +16,14 @@ Param( # Reset log file if (Test-Path $logFile) { - Clear-Content $logFile -Force | Out-Null + Clear-Content $logFile -Force | Out-Null } else { - New-Item -Path $logFile | Out-Null + New-Item -Path $logFile | Out-Null } Write-Host "> Getting config file ..." -$languageMap = @{} +$languageMap = @{ } $config = Get-Content -Raw -Path $configFile | ConvertFrom-Json $config.cognitiveModels.PSObject.Properties | Foreach-Object { $languageMap[$_.Name] = $_.Value } @@ -30,62 +31,61 @@ foreach ($langCode in $languageMap.Keys) { $models = $languageMap[$langCode] $dispatch = $models.dispatchModel - if ($RemoteToLocal) - { + if ($RemoteToLocal) { # Update local LU files based on hosted models - foreach ($luisApp in $models.languageModels) - { - $culture = (luis get application ` - --appId $luisApp.appId ` - --authoringKey $luisApp.authoringKey ` - --subscriptionKey $luisApp.subscriptionKey ` - --region $luisApp.region | ConvertFrom-Json).culture + foreach ($luisApp in $models.languageModels) { + $culture = (luis get application ` + --appId $luisApp.appId ` + --authoringKey $luisApp.authoringKey ` + --subscriptionKey $luisApp.subscriptionKey ` + --region $luisApp.authoringRegion | ConvertFrom-Json).culture Write-Host "> Updating local $($luisApp.id).lu file ..." luis export version ` --appId $luisApp.appid ` --versionId $luisApp.version ` - --region $luisApp.region ` + --region $luisApp.authoringRegion ` --authoringKey $luisApp.authoringKey | ludown refresh ` --stdin ` -n "$($luisApp.id).lu" ` -o $(Join-Path $luisFolder $langCode) - # Parse LU file - $id = $luisApp.id - $outFile = "$($id).luis" - $outFolder = $(Join-Path $luisFolder $langCode) - $appName = "$($name)$($langCode)_$($id)" + # Parse LU file + $id = $luisApp.id + $outFile = "$($id).luis" + $outFolder = $(Join-Path $luisFolder $langCode) + $appName = "$($name)$($langCode)_$($id)" - Write-Host "> Parsing $($luisApp.id) LU file ..." - ludown parse toluis ` - --in $(Join-Path $outFolder "$($luisApp.id).lu") ` - --luis_culture $culture ` - --out_folder $(Join-Path $luisFolder $langCode) ` - --out "$($luisApp.id).luis" + Write-Host "> Parsing $($luisApp.id) LU file ..." + ludown parse toluis ` + --in $(Join-Path $outFolder "$($luisApp.id).lu") ` + --luis_culture $culture ` + --out_folder $(Join-Path $luisFolder $langCode) ` + --out "$($luisApp.id).luis" - Write-Host "> Running LuisGen for $($luisApp.id) app ..." - $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + if ($useLuisGen) { + Write-Host "> Running LuisGen for $($luisApp.id) app ..." + $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + } # Add the LUIS application to the dispatch model. # If the LUIS application id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($luisApp.id) app to dispatch model ... " - (dispatch add ` - --type "luis" ` - --name $luisApp.name ` - --id $luisApp.appid ` - --region $luisApp.region ` - --intentName "l_$($luisApp.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($luisApp.id) app to dispatch model ... " + (dispatch add ` + --type "luis" ` + --name $luisApp.name ` + --id $luisApp.appid ` + --region $luisApp.authoringRegion ` + --intentName "l_$($luisApp.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } # Update local LU files based on hosted QnA KBs - foreach ($kb in $models.knowledgebases) - { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating local $($kb.id).lu file ..." qnamaker export kb ` --environment Prod ` @@ -97,56 +97,57 @@ foreach ($langCode in $languageMap.Keys) { # Add the knowledge base to the dispatch model. # If the knowledge base id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($kb.id) kb to dispatch model ..." - (dispatch add ` - --type "qna" ` - --name $kb.name ` - --id $kb.kbId ` - --key $kb.subscriptionKey ` - --intentName "q_$($kb.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($kb.id) kb to dispatch model ..." + (dispatch add ` + --type "qna" ` + --name $kb.name ` + --id $kb.kbId ` + --key $kb.subscriptionKey ` + --intentName "q_$($kb.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } } - else - { + else { # Update each luis model based on local LU files - foreach ($luisApp in $models.languageModels) { + foreach ($luisApp in $models.languageModels) { Write-Host "> Updating hosted $($luisApp.id) app..." - $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - UpdateLUIS ` - -lu_file $lu ` - -appId $luisApp.appid ` - -version $luisApp.version ` - -region $luisApp.region ` - -authoringKey $luisApp.authoringKey ` - -subscriptionKey $app.subscriptionKey - } + $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + UpdateLUIS ` + -lu_file $lu ` + -appId $luisApp.appid ` + -version $luisApp.version ` + -region $luisApp.authoringRegion ` + -authoringKey $luisApp.authoringKey ` + -subscriptionKey $app.subscriptionKey + } # Update each knowledgebase based on local LU files - foreach ($kb in $models.knowledgebases) { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating hosted $($kb.id) kb..." - $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") - UpdateKB ` - -lu_file $lu ` - -kbId $kb.kbId ` - -qnaSubscriptionKey $kb.subscriptionKey + $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") + UpdateKB ` + -lu_file $lu ` + -kbId $kb.kbId ` + -qnaSubscriptionKey $kb.subscriptionKey } - } + } - if ($dispatch) { - # Update dispatch model - Write-Host "> Updating dispatch model ..." - dispatch refresh ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null + if ($dispatch) { + # Update dispatch model + Write-Host "> Updating dispatch model ..." + dispatch refresh ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null - # Update dispatch.cs file - Write-Host "> Running LuisGen for Dispatch app..." - luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null - } + if ($useLuisGen) { + # Update dispatch.cs file + Write-Host "> Running LuisGen for Dispatch app..." + luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null + } + } } Write-Host "> Done." \ No newline at end of file diff --git a/skills/src/csharp/automotiveskill/automotiveskill/cognitivemodels.json b/skills/src/csharp/automotiveskill/automotiveskill/cognitivemodels.json index 05945ab9ad..a875fe40b4 100644 --- a/skills/src/csharp/automotiveskill/automotiveskill/cognitivemodels.json +++ b/skills/src/csharp/automotiveskill/automotiveskill/cognitivemodels.json @@ -7,6 +7,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" @@ -16,6 +17,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" @@ -25,6 +27,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" @@ -34,6 +37,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" diff --git a/skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/parameters.template.json b/skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/parameters.template.json index 41a2013cad..95841eb589 100644 --- a/skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/parameters.template.json +++ b/skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/parameters.template.json @@ -2,11 +2,23 @@ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - "appInsightsLocation": { - "value": "westus2" + "useCosmosDb": { + "value": false }, - "luisServiceLocation": { - "value": "westus" + "useStorage": { + "value": false + }, + "appServicePlanSku": { + "value": { + "tier": "Free", + "name": "F1" + } + }, + "botServiceSku": { + "value": "F0" + }, + "luisServiceSku": { + "value": "F0" } } } \ No newline at end of file diff --git a/skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/template.json b/skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/template.json index 681fafff07..9f72d9ecfd 100644 --- a/skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/template.json +++ b/skills/src/csharp/calendarskill/calendarskill/Deployment/Resources/template.json @@ -10,23 +10,35 @@ "type": "string", "defaultValue": "[resourceGroup().location]" }, + "suffix": { + "type": "string", + "defaultValue": "[take(uniqueString(resourceGroup().id), 7)]" + }, "microsoftAppId": { "type": "string" }, "microsoftAppPassword": { "type": "string" }, + "useCosmosDb": { + "type": "bool", + "defaultValue": true + }, "cosmosDbName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" + }, + "useStorage": { + "type": "bool", + "defaultValue": true }, "storageAccountName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanSku": { "type": "object", @@ -37,19 +49,19 @@ }, "appInsightsName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appInsightsLocation": { "type": "string", - "defaultValue": "westus2" + "defaultValue": "[resourceGroup().location]" }, "botWebAppName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceSku": { "type": "string", @@ -57,7 +69,7 @@ }, "luisServiceName": { "type": "string", - "defaultValue": "[concat(parameters('name'), '-luis')]" + "defaultValue": "[concat(parameters('name'), '-luis-', parameters('suffix'))]" }, "luisServiceSku": { "type": "string", @@ -69,8 +81,10 @@ } }, "variables": { - "botEndpoint": "[concat('https://', toLower(parameters('botWebAppName')), '.azurewebsites.net/api/messages')]", - "cleanStorageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]" + "botWebAppName": "[replace(parameters('botWebAppName'), '_', '')]", + "storageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]", + "cosmosDbAccountName": "[toLower(take(replace(parameters('cosmosDbName'), '_', ''), 31))]", + "botEndpoint": "[concat('https://', toLower(variables('botWebAppName')), '.azurewebsites.net/api/messages')]" }, "resources": [ { @@ -91,7 +105,7 @@ "type": "Microsoft.DocumentDB/databaseAccounts", "kind": "GlobalDocumentDB", "apiVersion": "2015-04-08", - "name": "[parameters('cosmosDbName')]", + "name": "[variables('cosmosDbAccountName')]", "location": "[parameters('location')]", "properties": { "databaseAccountOfferType": "Standard", @@ -101,18 +115,20 @@ "failoverPriority": 0 } ] - } + }, + "condition": "[parameters('useCosmosDb')]" }, { "comments": "storage account", "type": "Microsoft.Storage/storageAccounts", "kind": "StorageV2", "apiVersion": "2018-07-01", - "name": "[variables('cleanStorageAccountName')]", + "name": "[variables('storageAccountName')]", "location": "[parameters('location')]", "sku": { "name": "Standard_LRS" - } + }, + "condition": "[parameters('useStorage')]" }, { "comments": "app service plan", @@ -138,7 +154,7 @@ "comments": "bot web app", "type": "Microsoft.Web/sites", "apiVersion": "2018-02-01", - "name": "[parameters('botWebAppName')]", + "name": "[variables('botWebAppName')]", "location": "[parameters('location')]", "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]", @@ -193,7 +209,7 @@ "outputs": { "botWebAppName": { "type": "string", - "value": "[parameters('botWebAppName')]" + "value": "[variables('botWebAppName')]" }, "ApplicationInsights": { "type": "object", @@ -204,15 +220,15 @@ "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')]", + "connectionString": "[if(parameters('useStorage'), concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '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]", + "cosmosDBEndpoint": "[if(parameters('useCosmosDb'), reference(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName'))).documentEndpoint, '')]", + "authKey": "[if(parameters('useCosmosDb'), listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName')), '2015-04-08').primaryMasterKey, '')]", "databaseId": "botstate-db", "collectionId": "botstate-collection" } @@ -221,8 +237,9 @@ "type": "object", "value": { "accountName": "[parameters('luisServiceName')]", + "region": "[parameters('luisServiceLocation')]", "key": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', parameters('luisServiceName')),'2017-04-18').key1]" - } + } } } -} \ No newline at end of file +} diff --git a/skills/src/csharp/calendarskill/calendarskill/Deployment/Scripts/deploy.ps1 b/skills/src/csharp/calendarskill/calendarskill/Deployment/Scripts/deploy.ps1 index 0b79e0c717..78cbf4e5fc 100644 --- a/skills/src/csharp/calendarskill/calendarskill/Deployment/Scripts/deploy.ps1 +++ b/skills/src/csharp/calendarskill/calendarskill/Deployment/Scripts/deploy.ps1 @@ -79,7 +79,7 @@ if (-not $appId) { # Create app registration $app = (az ad app create ` --display-name $name ` - --password $appPassword ` + --password `"$($appPassword)`" ` --available-to-other-tenants ` --reply-urls 'https://token.botframework.com/.auth/web/redirect') @@ -198,7 +198,7 @@ if ($outputs) Start-Sleep -s 30 # Deploy cognitive models - 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)'" + Invoke-Expression "& '$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1')' -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -luisAccountName $($outputs.luis.value.accountName) -luisAccountRegion $($outputs.luis.value.region) -luisSubscriptionKey $($outputs.luis.value.key) -resourceGroup $($resourceGroup) -qnaSubscriptionKey '$($qnaSubscriptionKey)' -outFolder '$($projDir)' -languages '$($languages)'" # Publish bot Invoke-Expression "& '$(Join-Path $PSScriptRoot 'publish.ps1')' -name $($outputs.botWebAppName.value) -resourceGroup $($resourceGroup) -projFolder '$($projDir)'" diff --git a/skills/src/csharp/calendarskill/calendarskill/Deployment/Scripts/deploy_cognitive_models.ps1 b/skills/src/csharp/calendarskill/calendarskill/Deployment/Scripts/deploy_cognitive_models.ps1 index 22b708c23c..e3dfbfcd60 100644 --- a/skills/src/csharp/calendarskill/calendarskill/Deployment/Scripts/deploy_cognitive_models.ps1 +++ b/skills/src/csharp/calendarskill/calendarskill/Deployment/Scripts/deploy_cognitive_models.ps1 @@ -5,6 +5,7 @@ Param( [string] $luisAuthoringRegion, [string] $luisAuthoringKey, [string] $luisAccountName, + [string] $luisAccountRegion, [string] $luisSubscriptionKey, [string] $qnaSubscriptionKey, [string] $resourceGroup, @@ -86,6 +87,10 @@ if (-not $luisSubscriptionKey) { } } +if (-not $luisAccountRegion) { + $luisAccountRegion = Read-Host "? LUIS Service Location" +} + if (-not $qnaSubscriptionKey) { $useQna = $false } @@ -178,9 +183,10 @@ foreach ($language in $languageArr) name = $luisApp.name appid = $luisApp.id authoringkey = $luisAuthoringKey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey version = $luisApp.activeVersion - region = $luisAuthoringRegion + region = $luisAccountRegion } } else { @@ -279,8 +285,9 @@ foreach ($language in $languageArr) name = $dispatchApp.name appid = $dispatchApp.appId authoringkey = $luisauthoringkey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey - region = $luisAuthoringRegion + region = $luisAccountRegion } } } diff --git a/skills/src/csharp/calendarskill/calendarskill/Deployment/Scripts/update_cognitive_models.ps1 b/skills/src/csharp/calendarskill/calendarskill/Deployment/Scripts/update_cognitive_models.ps1 index e015ff3a63..827dee559a 100644 --- a/skills/src/csharp/calendarskill/calendarskill/Deployment/Scripts/update_cognitive_models.ps1 +++ b/skills/src/csharp/calendarskill/calendarskill/Deployment/Scripts/update_cognitive_models.ps1 @@ -2,6 +2,7 @@ Param( [switch] $RemoteToLocal, + [switch] $useLuisGen = $true, [string] $configFile = $(Join-Path (Get-Location) 'cognitivemodels.json'), [string] $dispatchFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'Dispatch'), [string] $luisFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'LU'), @@ -15,14 +16,14 @@ Param( # Reset log file if (Test-Path $logFile) { - Clear-Content $logFile -Force | Out-Null + Clear-Content $logFile -Force | Out-Null } else { - New-Item -Path $logFile | Out-Null + New-Item -Path $logFile | Out-Null } Write-Host "> Getting config file ..." -$languageMap = @{} +$languageMap = @{ } $config = Get-Content -Raw -Path $configFile | ConvertFrom-Json $config.cognitiveModels.PSObject.Properties | Foreach-Object { $languageMap[$_.Name] = $_.Value } @@ -30,62 +31,61 @@ foreach ($langCode in $languageMap.Keys) { $models = $languageMap[$langCode] $dispatch = $models.dispatchModel - if ($RemoteToLocal) - { + if ($RemoteToLocal) { # Update local LU files based on hosted models - foreach ($luisApp in $models.languageModels) - { - $culture = (luis get application ` - --appId $luisApp.appId ` - --authoringKey $luisApp.authoringKey ` - --subscriptionKey $luisApp.subscriptionKey ` - --region $luisApp.region | ConvertFrom-Json).culture + foreach ($luisApp in $models.languageModels) { + $culture = (luis get application ` + --appId $luisApp.appId ` + --authoringKey $luisApp.authoringKey ` + --subscriptionKey $luisApp.subscriptionKey ` + --region $luisApp.authoringRegion | ConvertFrom-Json).culture Write-Host "> Updating local $($luisApp.id).lu file ..." luis export version ` --appId $luisApp.appid ` --versionId $luisApp.version ` - --region $luisApp.region ` + --region $luisApp.authoringRegion ` --authoringKey $luisApp.authoringKey | ludown refresh ` --stdin ` -n "$($luisApp.id).lu" ` -o $(Join-Path $luisFolder $langCode) - # Parse LU file - $id = $luisApp.id - $outFile = "$($id).luis" - $outFolder = $(Join-Path $luisFolder $langCode) - $appName = "$($name)$($langCode)_$($id)" + # Parse LU file + $id = $luisApp.id + $outFile = "$($id).luis" + $outFolder = $(Join-Path $luisFolder $langCode) + $appName = "$($name)$($langCode)_$($id)" - Write-Host "> Parsing $($luisApp.id) LU file ..." - ludown parse toluis ` - --in $(Join-Path $outFolder "$($luisApp.id).lu") ` - --luis_culture $culture ` - --out_folder $(Join-Path $luisFolder $langCode) ` - --out "$($luisApp.id).luis" + Write-Host "> Parsing $($luisApp.id) LU file ..." + ludown parse toluis ` + --in $(Join-Path $outFolder "$($luisApp.id).lu") ` + --luis_culture $culture ` + --out_folder $(Join-Path $luisFolder $langCode) ` + --out "$($luisApp.id).luis" - Write-Host "> Running LuisGen for $($luisApp.id) app ..." - $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + if ($useLuisGen) { + Write-Host "> Running LuisGen for $($luisApp.id) app ..." + $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + } # Add the LUIS application to the dispatch model. # If the LUIS application id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($luisApp.id) app to dispatch model ... " - (dispatch add ` - --type "luis" ` - --name $luisApp.name ` - --id $luisApp.appid ` - --region $luisApp.region ` - --intentName "l_$($luisApp.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($luisApp.id) app to dispatch model ... " + (dispatch add ` + --type "luis" ` + --name $luisApp.name ` + --id $luisApp.appid ` + --region $luisApp.authoringRegion ` + --intentName "l_$($luisApp.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } # Update local LU files based on hosted QnA KBs - foreach ($kb in $models.knowledgebases) - { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating local $($kb.id).lu file ..." qnamaker export kb ` --environment Prod ` @@ -97,56 +97,57 @@ foreach ($langCode in $languageMap.Keys) { # Add the knowledge base to the dispatch model. # If the knowledge base id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($kb.id) kb to dispatch model ..." - (dispatch add ` - --type "qna" ` - --name $kb.name ` - --id $kb.kbId ` - --key $kb.subscriptionKey ` - --intentName "q_$($kb.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($kb.id) kb to dispatch model ..." + (dispatch add ` + --type "qna" ` + --name $kb.name ` + --id $kb.kbId ` + --key $kb.subscriptionKey ` + --intentName "q_$($kb.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } } - else - { + else { # Update each luis model based on local LU files - foreach ($luisApp in $models.languageModels) { + foreach ($luisApp in $models.languageModels) { Write-Host "> Updating hosted $($luisApp.id) app..." - $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - UpdateLUIS ` - -lu_file $lu ` - -appId $luisApp.appid ` - -version $luisApp.version ` - -region $luisApp.region ` - -authoringKey $luisApp.authoringKey ` - -subscriptionKey $app.subscriptionKey - } + $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + UpdateLUIS ` + -lu_file $lu ` + -appId $luisApp.appid ` + -version $luisApp.version ` + -region $luisApp.authoringRegion ` + -authoringKey $luisApp.authoringKey ` + -subscriptionKey $app.subscriptionKey + } # Update each knowledgebase based on local LU files - foreach ($kb in $models.knowledgebases) { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating hosted $($kb.id) kb..." - $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") - UpdateKB ` - -lu_file $lu ` - -kbId $kb.kbId ` - -qnaSubscriptionKey $kb.subscriptionKey + $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") + UpdateKB ` + -lu_file $lu ` + -kbId $kb.kbId ` + -qnaSubscriptionKey $kb.subscriptionKey } - } + } - if ($dispatch) { - # Update dispatch model - Write-Host "> Updating dispatch model ..." - dispatch refresh ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null + if ($dispatch) { + # Update dispatch model + Write-Host "> Updating dispatch model ..." + dispatch refresh ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null - # Update dispatch.cs file - Write-Host "> Running LuisGen for Dispatch app..." - luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null - } + if ($useLuisGen) { + # Update dispatch.cs file + Write-Host "> Running LuisGen for Dispatch app..." + luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null + } + } } Write-Host "> Done." \ No newline at end of file diff --git a/skills/src/csharp/calendarskill/calendarskill/cognitivemodels.json b/skills/src/csharp/calendarskill/calendarskill/cognitivemodels.json index 6eaeec0b57..0a3f2e95d9 100644 --- a/skills/src/csharp/calendarskill/calendarskill/cognitivemodels.json +++ b/skills/src/csharp/calendarskill/calendarskill/cognitivemodels.json @@ -7,6 +7,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" @@ -16,6 +17,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" diff --git a/skills/src/csharp/emailskill/emailskill/Deployment/Resources/parameters.template.json b/skills/src/csharp/emailskill/emailskill/Deployment/Resources/parameters.template.json index 41a2013cad..95841eb589 100644 --- a/skills/src/csharp/emailskill/emailskill/Deployment/Resources/parameters.template.json +++ b/skills/src/csharp/emailskill/emailskill/Deployment/Resources/parameters.template.json @@ -2,11 +2,23 @@ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - "appInsightsLocation": { - "value": "westus2" + "useCosmosDb": { + "value": false }, - "luisServiceLocation": { - "value": "westus" + "useStorage": { + "value": false + }, + "appServicePlanSku": { + "value": { + "tier": "Free", + "name": "F1" + } + }, + "botServiceSku": { + "value": "F0" + }, + "luisServiceSku": { + "value": "F0" } } } \ No newline at end of file diff --git a/skills/src/csharp/emailskill/emailskill/Deployment/Resources/template.json b/skills/src/csharp/emailskill/emailskill/Deployment/Resources/template.json index b7d4ee0040..5f16938571 100644 --- a/skills/src/csharp/emailskill/emailskill/Deployment/Resources/template.json +++ b/skills/src/csharp/emailskill/emailskill/Deployment/Resources/template.json @@ -10,23 +10,35 @@ "type": "string", "defaultValue": "[resourceGroup().location]" }, + "suffix": { + "type": "string", + "defaultValue": "[take(uniqueString(resourceGroup().id), 7)]" + }, "microsoftAppId": { "type": "string" }, "microsoftAppPassword": { "type": "string" }, + "useCosmosDb": { + "type": "bool", + "defaultValue": true + }, "cosmosDbName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" + }, + "useStorage": { + "type": "bool", + "defaultValue": true }, "storageAccountName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanSku": { "type": "object", @@ -37,19 +49,19 @@ }, "appInsightsName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appInsightsLocation": { "type": "string", - "defaultValue": "westus2" + "defaultValue": "[resourceGroup().location]" }, "botWebAppName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceSku": { "type": "string", @@ -57,7 +69,7 @@ }, "luisServiceName": { "type": "string", - "defaultValue": "[concat(parameters('name'), '-luis')]" + "defaultValue": "[concat(parameters('name'), '-luis-', parameters('suffix'))]" }, "luisServiceSku": { "type": "string", @@ -69,8 +81,10 @@ } }, "variables": { - "botEndpoint": "[concat('https://', toLower(parameters('botWebAppName')), '.azurewebsites.net/api/messages')]", - "cleanStorageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]" + "botWebAppName": "[replace(parameters('botWebAppName'), '_', '')]", + "storageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]", + "cosmosDbAccountName": "[toLower(take(replace(parameters('cosmosDbName'), '_', ''), 31))]", + "botEndpoint": "[concat('https://', toLower(variables('botWebAppName')), '.azurewebsites.net/api/messages')]" }, "resources": [ { @@ -91,7 +105,7 @@ "type": "Microsoft.DocumentDB/databaseAccounts", "kind": "GlobalDocumentDB", "apiVersion": "2015-04-08", - "name": "[parameters('cosmosDbName')]", + "name": "[variables('cosmosDbAccountName')]", "location": "[parameters('location')]", "properties": { "databaseAccountOfferType": "Standard", @@ -101,18 +115,20 @@ "failoverPriority": 0 } ] - } + }, + "condition": "[parameters('useCosmosDb')]" }, { "comments": "storage account", "type": "Microsoft.Storage/storageAccounts", "kind": "StorageV2", "apiVersion": "2018-07-01", - "name": "[variables('cleanStorageAccountName')]", + "name": "[variables('storageAccountName')]", "location": "[parameters('location')]", "sku": { "name": "Standard_LRS" - } + }, + "condition": "[parameters('useStorage')]" }, { "comments": "app service plan", @@ -138,7 +154,7 @@ "comments": "bot web app", "type": "Microsoft.Web/sites", "apiVersion": "2018-02-01", - "name": "[parameters('botWebAppName')]", + "name": "[variables('botWebAppName')]", "location": "[parameters('location')]", "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]", @@ -193,7 +209,7 @@ "outputs": { "botWebAppName": { "type": "string", - "value": "[parameters('botWebAppName')]" + "value": "[variables('botWebAppName')]" }, "ApplicationInsights": { "type": "object", @@ -204,15 +220,15 @@ "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')]", + "connectionString": "[if(parameters('useStorage'), concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '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]", + "cosmosDBEndpoint": "[if(parameters('useCosmosDb'), reference(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName'))).documentEndpoint, '')]", + "authKey": "[if(parameters('useCosmosDb'), listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName')), '2015-04-08').primaryMasterKey, '')]", "databaseId": "botstate-db", "collectionId": "botstate-collection" } @@ -221,8 +237,9 @@ "type": "object", "value": { "accountName": "[parameters('luisServiceName')]", + "region": "[parameters('luisServiceLocation')]", "key": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', parameters('luisServiceName')),'2017-04-18').key1]" - } + } } } -} \ No newline at end of file +} diff --git a/skills/src/csharp/emailskill/emailskill/Deployment/Scripts/deploy.ps1 b/skills/src/csharp/emailskill/emailskill/Deployment/Scripts/deploy.ps1 index 0b79e0c717..78cbf4e5fc 100644 --- a/skills/src/csharp/emailskill/emailskill/Deployment/Scripts/deploy.ps1 +++ b/skills/src/csharp/emailskill/emailskill/Deployment/Scripts/deploy.ps1 @@ -79,7 +79,7 @@ if (-not $appId) { # Create app registration $app = (az ad app create ` --display-name $name ` - --password $appPassword ` + --password `"$($appPassword)`" ` --available-to-other-tenants ` --reply-urls 'https://token.botframework.com/.auth/web/redirect') @@ -198,7 +198,7 @@ if ($outputs) Start-Sleep -s 30 # Deploy cognitive models - 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)'" + Invoke-Expression "& '$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1')' -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -luisAccountName $($outputs.luis.value.accountName) -luisAccountRegion $($outputs.luis.value.region) -luisSubscriptionKey $($outputs.luis.value.key) -resourceGroup $($resourceGroup) -qnaSubscriptionKey '$($qnaSubscriptionKey)' -outFolder '$($projDir)' -languages '$($languages)'" # Publish bot Invoke-Expression "& '$(Join-Path $PSScriptRoot 'publish.ps1')' -name $($outputs.botWebAppName.value) -resourceGroup $($resourceGroup) -projFolder '$($projDir)'" diff --git a/skills/src/csharp/emailskill/emailskill/Deployment/Scripts/deploy_cognitive_models.ps1 b/skills/src/csharp/emailskill/emailskill/Deployment/Scripts/deploy_cognitive_models.ps1 index 22b708c23c..e3dfbfcd60 100644 --- a/skills/src/csharp/emailskill/emailskill/Deployment/Scripts/deploy_cognitive_models.ps1 +++ b/skills/src/csharp/emailskill/emailskill/Deployment/Scripts/deploy_cognitive_models.ps1 @@ -5,6 +5,7 @@ Param( [string] $luisAuthoringRegion, [string] $luisAuthoringKey, [string] $luisAccountName, + [string] $luisAccountRegion, [string] $luisSubscriptionKey, [string] $qnaSubscriptionKey, [string] $resourceGroup, @@ -86,6 +87,10 @@ if (-not $luisSubscriptionKey) { } } +if (-not $luisAccountRegion) { + $luisAccountRegion = Read-Host "? LUIS Service Location" +} + if (-not $qnaSubscriptionKey) { $useQna = $false } @@ -178,9 +183,10 @@ foreach ($language in $languageArr) name = $luisApp.name appid = $luisApp.id authoringkey = $luisAuthoringKey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey version = $luisApp.activeVersion - region = $luisAuthoringRegion + region = $luisAccountRegion } } else { @@ -279,8 +285,9 @@ foreach ($language in $languageArr) name = $dispatchApp.name appid = $dispatchApp.appId authoringkey = $luisauthoringkey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey - region = $luisAuthoringRegion + region = $luisAccountRegion } } } diff --git a/skills/src/csharp/emailskill/emailskill/Deployment/Scripts/update_cognitive_models.ps1 b/skills/src/csharp/emailskill/emailskill/Deployment/Scripts/update_cognitive_models.ps1 index e015ff3a63..827dee559a 100644 --- a/skills/src/csharp/emailskill/emailskill/Deployment/Scripts/update_cognitive_models.ps1 +++ b/skills/src/csharp/emailskill/emailskill/Deployment/Scripts/update_cognitive_models.ps1 @@ -2,6 +2,7 @@ Param( [switch] $RemoteToLocal, + [switch] $useLuisGen = $true, [string] $configFile = $(Join-Path (Get-Location) 'cognitivemodels.json'), [string] $dispatchFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'Dispatch'), [string] $luisFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'LU'), @@ -15,14 +16,14 @@ Param( # Reset log file if (Test-Path $logFile) { - Clear-Content $logFile -Force | Out-Null + Clear-Content $logFile -Force | Out-Null } else { - New-Item -Path $logFile | Out-Null + New-Item -Path $logFile | Out-Null } Write-Host "> Getting config file ..." -$languageMap = @{} +$languageMap = @{ } $config = Get-Content -Raw -Path $configFile | ConvertFrom-Json $config.cognitiveModels.PSObject.Properties | Foreach-Object { $languageMap[$_.Name] = $_.Value } @@ -30,62 +31,61 @@ foreach ($langCode in $languageMap.Keys) { $models = $languageMap[$langCode] $dispatch = $models.dispatchModel - if ($RemoteToLocal) - { + if ($RemoteToLocal) { # Update local LU files based on hosted models - foreach ($luisApp in $models.languageModels) - { - $culture = (luis get application ` - --appId $luisApp.appId ` - --authoringKey $luisApp.authoringKey ` - --subscriptionKey $luisApp.subscriptionKey ` - --region $luisApp.region | ConvertFrom-Json).culture + foreach ($luisApp in $models.languageModels) { + $culture = (luis get application ` + --appId $luisApp.appId ` + --authoringKey $luisApp.authoringKey ` + --subscriptionKey $luisApp.subscriptionKey ` + --region $luisApp.authoringRegion | ConvertFrom-Json).culture Write-Host "> Updating local $($luisApp.id).lu file ..." luis export version ` --appId $luisApp.appid ` --versionId $luisApp.version ` - --region $luisApp.region ` + --region $luisApp.authoringRegion ` --authoringKey $luisApp.authoringKey | ludown refresh ` --stdin ` -n "$($luisApp.id).lu" ` -o $(Join-Path $luisFolder $langCode) - # Parse LU file - $id = $luisApp.id - $outFile = "$($id).luis" - $outFolder = $(Join-Path $luisFolder $langCode) - $appName = "$($name)$($langCode)_$($id)" + # Parse LU file + $id = $luisApp.id + $outFile = "$($id).luis" + $outFolder = $(Join-Path $luisFolder $langCode) + $appName = "$($name)$($langCode)_$($id)" - Write-Host "> Parsing $($luisApp.id) LU file ..." - ludown parse toluis ` - --in $(Join-Path $outFolder "$($luisApp.id).lu") ` - --luis_culture $culture ` - --out_folder $(Join-Path $luisFolder $langCode) ` - --out "$($luisApp.id).luis" + Write-Host "> Parsing $($luisApp.id) LU file ..." + ludown parse toluis ` + --in $(Join-Path $outFolder "$($luisApp.id).lu") ` + --luis_culture $culture ` + --out_folder $(Join-Path $luisFolder $langCode) ` + --out "$($luisApp.id).luis" - Write-Host "> Running LuisGen for $($luisApp.id) app ..." - $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + if ($useLuisGen) { + Write-Host "> Running LuisGen for $($luisApp.id) app ..." + $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + } # Add the LUIS application to the dispatch model. # If the LUIS application id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($luisApp.id) app to dispatch model ... " - (dispatch add ` - --type "luis" ` - --name $luisApp.name ` - --id $luisApp.appid ` - --region $luisApp.region ` - --intentName "l_$($luisApp.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($luisApp.id) app to dispatch model ... " + (dispatch add ` + --type "luis" ` + --name $luisApp.name ` + --id $luisApp.appid ` + --region $luisApp.authoringRegion ` + --intentName "l_$($luisApp.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } # Update local LU files based on hosted QnA KBs - foreach ($kb in $models.knowledgebases) - { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating local $($kb.id).lu file ..." qnamaker export kb ` --environment Prod ` @@ -97,56 +97,57 @@ foreach ($langCode in $languageMap.Keys) { # Add the knowledge base to the dispatch model. # If the knowledge base id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($kb.id) kb to dispatch model ..." - (dispatch add ` - --type "qna" ` - --name $kb.name ` - --id $kb.kbId ` - --key $kb.subscriptionKey ` - --intentName "q_$($kb.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($kb.id) kb to dispatch model ..." + (dispatch add ` + --type "qna" ` + --name $kb.name ` + --id $kb.kbId ` + --key $kb.subscriptionKey ` + --intentName "q_$($kb.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } } - else - { + else { # Update each luis model based on local LU files - foreach ($luisApp in $models.languageModels) { + foreach ($luisApp in $models.languageModels) { Write-Host "> Updating hosted $($luisApp.id) app..." - $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - UpdateLUIS ` - -lu_file $lu ` - -appId $luisApp.appid ` - -version $luisApp.version ` - -region $luisApp.region ` - -authoringKey $luisApp.authoringKey ` - -subscriptionKey $app.subscriptionKey - } + $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + UpdateLUIS ` + -lu_file $lu ` + -appId $luisApp.appid ` + -version $luisApp.version ` + -region $luisApp.authoringRegion ` + -authoringKey $luisApp.authoringKey ` + -subscriptionKey $app.subscriptionKey + } # Update each knowledgebase based on local LU files - foreach ($kb in $models.knowledgebases) { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating hosted $($kb.id) kb..." - $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") - UpdateKB ` - -lu_file $lu ` - -kbId $kb.kbId ` - -qnaSubscriptionKey $kb.subscriptionKey + $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") + UpdateKB ` + -lu_file $lu ` + -kbId $kb.kbId ` + -qnaSubscriptionKey $kb.subscriptionKey } - } + } - if ($dispatch) { - # Update dispatch model - Write-Host "> Updating dispatch model ..." - dispatch refresh ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null + if ($dispatch) { + # Update dispatch model + Write-Host "> Updating dispatch model ..." + dispatch refresh ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null - # Update dispatch.cs file - Write-Host "> Running LuisGen for Dispatch app..." - luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null - } + if ($useLuisGen) { + # Update dispatch.cs file + Write-Host "> Running LuisGen for Dispatch app..." + luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null + } + } } Write-Host "> Done." \ No newline at end of file diff --git a/skills/src/csharp/emailskill/emailskill/cognitivemodels.json b/skills/src/csharp/emailskill/emailskill/cognitivemodels.json index 00d791ff5a..823cc99f13 100644 --- a/skills/src/csharp/emailskill/emailskill/cognitivemodels.json +++ b/skills/src/csharp/emailskill/emailskill/cognitivemodels.json @@ -7,6 +7,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" @@ -16,6 +17,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" diff --git a/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Resources/parameters.template.json b/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Resources/parameters.template.json index 009470a910..95841eb589 100644 --- a/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Resources/parameters.template.json +++ b/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Resources/parameters.template.json @@ -2,14 +2,23 @@ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - "appInsightsLocation": { - "value": "westus2" + "useCosmosDb": { + "value": false }, - "luisServiceLocation": { - "value": "westus" + "useStorage": { + "value": false }, - "qnaMakerSearchSku": { - "value": "standard" + "appServicePlanSku": { + "value": { + "tier": "Free", + "name": "F1" + } + }, + "botServiceSku": { + "value": "F0" + }, + "luisServiceSku": { + "value": "F0" } } } \ No newline at end of file diff --git a/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Resources/template.json b/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Resources/template.json index 5683793a2f..7c6ba6200a 100644 --- a/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Resources/template.json +++ b/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Resources/template.json @@ -10,23 +10,35 @@ "type": "string", "defaultValue": "[resourceGroup().location]" }, + "suffix": { + "type": "string", + "defaultValue": "[take(uniqueString(resourceGroup().id), 7)]" + }, "microsoftAppId": { "type": "string" }, "microsoftAppPassword": { "type": "string" }, + "useCosmosDb": { + "type": "bool", + "defaultValue": true + }, "cosmosDbName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" + }, + "useStorage": { + "type": "bool", + "defaultValue": true }, "storageAccountName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanSku": { "type": "object", @@ -37,19 +49,19 @@ }, "appInsightsName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appInsightsLocation": { "type": "string", - "defaultValue": "westus2" + "defaultValue": "[resourceGroup().location]" }, "botWebAppName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceSku": { "type": "string", @@ -57,7 +69,7 @@ }, "luisServiceName": { "type": "string", - "defaultValue": "[concat(parameters('name'), '-luis')]" + "defaultValue": "[concat(parameters('name'), '-luis-', parameters('suffix'))]" }, "luisServiceSku": { "type": "string", @@ -69,8 +81,10 @@ } }, "variables": { - "botEndpoint": "[concat('https://', toLower(parameters('botWebAppName')), '.azurewebsites.net/api/messages')]", - "cleanStorageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]" + "botWebAppName": "[replace(parameters('botWebAppName'), '_', '')]", + "storageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]", + "cosmosDbAccountName": "[toLower(take(replace(parameters('cosmosDbName'), '_', ''), 31))]", + "botEndpoint": "[concat('https://', toLower(variables('botWebAppName')), '.azurewebsites.net/api/messages')]" }, "resources": [ { @@ -91,7 +105,7 @@ "type": "Microsoft.DocumentDB/databaseAccounts", "kind": "GlobalDocumentDB", "apiVersion": "2015-04-08", - "name": "[parameters('cosmosDbName')]", + "name": "[variables('cosmosDbAccountName')]", "location": "[parameters('location')]", "properties": { "databaseAccountOfferType": "Standard", @@ -101,18 +115,20 @@ "failoverPriority": 0 } ] - } + }, + "condition": "[parameters('useCosmosDb')]" }, { "comments": "storage account", "type": "Microsoft.Storage/storageAccounts", "kind": "StorageV2", "apiVersion": "2018-07-01", - "name": "[variables('cleanStorageAccountName')]", + "name": "[variables('storageAccountName')]", "location": "[parameters('location')]", "sku": { "name": "Standard_LRS" - } + }, + "condition": "[parameters('useStorage')]" }, { "comments": "app service plan", @@ -138,7 +154,7 @@ "comments": "bot web app", "type": "Microsoft.Web/sites", "apiVersion": "2018-02-01", - "name": "[parameters('botWebAppName')]", + "name": "[variables('botWebAppName')]", "location": "[parameters('location')]", "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]", @@ -193,7 +209,7 @@ "outputs": { "botWebAppName": { "type": "string", - "value": "[parameters('botWebAppName')]" + "value": "[variables('botWebAppName')]" }, "ApplicationInsights": { "type": "object", @@ -204,15 +220,15 @@ "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')]", + "connectionString": "[if(parameters('useStorage'), concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '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]", + "cosmosDBEndpoint": "[if(parameters('useCosmosDb'), reference(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName'))).documentEndpoint, '')]", + "authKey": "[if(parameters('useCosmosDb'), listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName')), '2015-04-08').primaryMasterKey, '')]", "databaseId": "botstate-db", "collectionId": "botstate-collection" } @@ -221,8 +237,9 @@ "type": "object", "value": { "accountName": "[parameters('luisServiceName')]", + "region": "[parameters('luisServiceLocation')]", "key": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', parameters('luisServiceName')),'2017-04-18').key1]" - } + } } } } \ No newline at end of file diff --git a/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Scripts/deploy.ps1 b/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Scripts/deploy.ps1 index 0b79e0c717..78cbf4e5fc 100644 --- a/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Scripts/deploy.ps1 +++ b/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Scripts/deploy.ps1 @@ -79,7 +79,7 @@ if (-not $appId) { # Create app registration $app = (az ad app create ` --display-name $name ` - --password $appPassword ` + --password `"$($appPassword)`" ` --available-to-other-tenants ` --reply-urls 'https://token.botframework.com/.auth/web/redirect') @@ -198,7 +198,7 @@ if ($outputs) Start-Sleep -s 30 # Deploy cognitive models - 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)'" + Invoke-Expression "& '$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1')' -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -luisAccountName $($outputs.luis.value.accountName) -luisAccountRegion $($outputs.luis.value.region) -luisSubscriptionKey $($outputs.luis.value.key) -resourceGroup $($resourceGroup) -qnaSubscriptionKey '$($qnaSubscriptionKey)' -outFolder '$($projDir)' -languages '$($languages)'" # Publish bot Invoke-Expression "& '$(Join-Path $PSScriptRoot 'publish.ps1')' -name $($outputs.botWebAppName.value) -resourceGroup $($resourceGroup) -projFolder '$($projDir)'" diff --git a/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Scripts/deploy_cognitive_models.ps1 b/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Scripts/deploy_cognitive_models.ps1 index 22b708c23c..e3dfbfcd60 100644 --- a/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Scripts/deploy_cognitive_models.ps1 +++ b/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Scripts/deploy_cognitive_models.ps1 @@ -5,6 +5,7 @@ Param( [string] $luisAuthoringRegion, [string] $luisAuthoringKey, [string] $luisAccountName, + [string] $luisAccountRegion, [string] $luisSubscriptionKey, [string] $qnaSubscriptionKey, [string] $resourceGroup, @@ -86,6 +87,10 @@ if (-not $luisSubscriptionKey) { } } +if (-not $luisAccountRegion) { + $luisAccountRegion = Read-Host "? LUIS Service Location" +} + if (-not $qnaSubscriptionKey) { $useQna = $false } @@ -178,9 +183,10 @@ foreach ($language in $languageArr) name = $luisApp.name appid = $luisApp.id authoringkey = $luisAuthoringKey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey version = $luisApp.activeVersion - region = $luisAuthoringRegion + region = $luisAccountRegion } } else { @@ -279,8 +285,9 @@ foreach ($language in $languageArr) name = $dispatchApp.name appid = $dispatchApp.appId authoringkey = $luisauthoringkey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey - region = $luisAuthoringRegion + region = $luisAccountRegion } } } diff --git a/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Scripts/update_cognitive_models.ps1 b/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Scripts/update_cognitive_models.ps1 index e015ff3a63..827dee559a 100644 --- a/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Scripts/update_cognitive_models.ps1 +++ b/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/Deployment/Scripts/update_cognitive_models.ps1 @@ -2,6 +2,7 @@ Param( [switch] $RemoteToLocal, + [switch] $useLuisGen = $true, [string] $configFile = $(Join-Path (Get-Location) 'cognitivemodels.json'), [string] $dispatchFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'Dispatch'), [string] $luisFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'LU'), @@ -15,14 +16,14 @@ Param( # Reset log file if (Test-Path $logFile) { - Clear-Content $logFile -Force | Out-Null + Clear-Content $logFile -Force | Out-Null } else { - New-Item -Path $logFile | Out-Null + New-Item -Path $logFile | Out-Null } Write-Host "> Getting config file ..." -$languageMap = @{} +$languageMap = @{ } $config = Get-Content -Raw -Path $configFile | ConvertFrom-Json $config.cognitiveModels.PSObject.Properties | Foreach-Object { $languageMap[$_.Name] = $_.Value } @@ -30,62 +31,61 @@ foreach ($langCode in $languageMap.Keys) { $models = $languageMap[$langCode] $dispatch = $models.dispatchModel - if ($RemoteToLocal) - { + if ($RemoteToLocal) { # Update local LU files based on hosted models - foreach ($luisApp in $models.languageModels) - { - $culture = (luis get application ` - --appId $luisApp.appId ` - --authoringKey $luisApp.authoringKey ` - --subscriptionKey $luisApp.subscriptionKey ` - --region $luisApp.region | ConvertFrom-Json).culture + foreach ($luisApp in $models.languageModels) { + $culture = (luis get application ` + --appId $luisApp.appId ` + --authoringKey $luisApp.authoringKey ` + --subscriptionKey $luisApp.subscriptionKey ` + --region $luisApp.authoringRegion | ConvertFrom-Json).culture Write-Host "> Updating local $($luisApp.id).lu file ..." luis export version ` --appId $luisApp.appid ` --versionId $luisApp.version ` - --region $luisApp.region ` + --region $luisApp.authoringRegion ` --authoringKey $luisApp.authoringKey | ludown refresh ` --stdin ` -n "$($luisApp.id).lu" ` -o $(Join-Path $luisFolder $langCode) - # Parse LU file - $id = $luisApp.id - $outFile = "$($id).luis" - $outFolder = $(Join-Path $luisFolder $langCode) - $appName = "$($name)$($langCode)_$($id)" + # Parse LU file + $id = $luisApp.id + $outFile = "$($id).luis" + $outFolder = $(Join-Path $luisFolder $langCode) + $appName = "$($name)$($langCode)_$($id)" - Write-Host "> Parsing $($luisApp.id) LU file ..." - ludown parse toluis ` - --in $(Join-Path $outFolder "$($luisApp.id).lu") ` - --luis_culture $culture ` - --out_folder $(Join-Path $luisFolder $langCode) ` - --out "$($luisApp.id).luis" + Write-Host "> Parsing $($luisApp.id) LU file ..." + ludown parse toluis ` + --in $(Join-Path $outFolder "$($luisApp.id).lu") ` + --luis_culture $culture ` + --out_folder $(Join-Path $luisFolder $langCode) ` + --out "$($luisApp.id).luis" - Write-Host "> Running LuisGen for $($luisApp.id) app ..." - $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + if ($useLuisGen) { + Write-Host "> Running LuisGen for $($luisApp.id) app ..." + $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + } # Add the LUIS application to the dispatch model. # If the LUIS application id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($luisApp.id) app to dispatch model ... " - (dispatch add ` - --type "luis" ` - --name $luisApp.name ` - --id $luisApp.appid ` - --region $luisApp.region ` - --intentName "l_$($luisApp.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($luisApp.id) app to dispatch model ... " + (dispatch add ` + --type "luis" ` + --name $luisApp.name ` + --id $luisApp.appid ` + --region $luisApp.authoringRegion ` + --intentName "l_$($luisApp.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } # Update local LU files based on hosted QnA KBs - foreach ($kb in $models.knowledgebases) - { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating local $($kb.id).lu file ..." qnamaker export kb ` --environment Prod ` @@ -97,56 +97,57 @@ foreach ($langCode in $languageMap.Keys) { # Add the knowledge base to the dispatch model. # If the knowledge base id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($kb.id) kb to dispatch model ..." - (dispatch add ` - --type "qna" ` - --name $kb.name ` - --id $kb.kbId ` - --key $kb.subscriptionKey ` - --intentName "q_$($kb.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($kb.id) kb to dispatch model ..." + (dispatch add ` + --type "qna" ` + --name $kb.name ` + --id $kb.kbId ` + --key $kb.subscriptionKey ` + --intentName "q_$($kb.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } } - else - { + else { # Update each luis model based on local LU files - foreach ($luisApp in $models.languageModels) { + foreach ($luisApp in $models.languageModels) { Write-Host "> Updating hosted $($luisApp.id) app..." - $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - UpdateLUIS ` - -lu_file $lu ` - -appId $luisApp.appid ` - -version $luisApp.version ` - -region $luisApp.region ` - -authoringKey $luisApp.authoringKey ` - -subscriptionKey $app.subscriptionKey - } + $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + UpdateLUIS ` + -lu_file $lu ` + -appId $luisApp.appid ` + -version $luisApp.version ` + -region $luisApp.authoringRegion ` + -authoringKey $luisApp.authoringKey ` + -subscriptionKey $app.subscriptionKey + } # Update each knowledgebase based on local LU files - foreach ($kb in $models.knowledgebases) { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating hosted $($kb.id) kb..." - $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") - UpdateKB ` - -lu_file $lu ` - -kbId $kb.kbId ` - -qnaSubscriptionKey $kb.subscriptionKey + $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") + UpdateKB ` + -lu_file $lu ` + -kbId $kb.kbId ` + -qnaSubscriptionKey $kb.subscriptionKey } - } + } - if ($dispatch) { - # Update dispatch model - Write-Host "> Updating dispatch model ..." - dispatch refresh ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null + if ($dispatch) { + # Update dispatch model + Write-Host "> Updating dispatch model ..." + dispatch refresh ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null - # Update dispatch.cs file - Write-Host "> Running LuisGen for Dispatch app..." - luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null - } + if ($useLuisGen) { + # Update dispatch.cs file + Write-Host "> Running LuisGen for Dispatch app..." + luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null + } + } } Write-Host "> Done." \ No newline at end of file diff --git a/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/cognitivemodels.json b/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/cognitivemodels.json index 4b3f98258f..bd2c31df1f 100644 --- a/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/cognitivemodels.json +++ b/skills/src/csharp/experimental/bingsearchskill/bingsearchskill/cognitivemodels.json @@ -5,6 +5,7 @@ { "id": "BingSearchSkill", "authoringkey": "", + "authoringRegion": "", "subscriptionkey": "", "region": "", "name": "", @@ -14,6 +15,7 @@ { "id": "General", "authoringkey": "", + "authoringRegion": "", "subscriptionkey": "", "region": "", "name": "", diff --git a/skills/src/csharp/experimental/newsskill/Deployment/Resources/parameters.template.json b/skills/src/csharp/experimental/newsskill/Deployment/Resources/parameters.template.json index 41a2013cad..95841eb589 100644 --- a/skills/src/csharp/experimental/newsskill/Deployment/Resources/parameters.template.json +++ b/skills/src/csharp/experimental/newsskill/Deployment/Resources/parameters.template.json @@ -2,11 +2,23 @@ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - "appInsightsLocation": { - "value": "westus2" + "useCosmosDb": { + "value": false }, - "luisServiceLocation": { - "value": "westus" + "useStorage": { + "value": false + }, + "appServicePlanSku": { + "value": { + "tier": "Free", + "name": "F1" + } + }, + "botServiceSku": { + "value": "F0" + }, + "luisServiceSku": { + "value": "F0" } } } \ No newline at end of file diff --git a/skills/src/csharp/experimental/newsskill/Deployment/Resources/template.json b/skills/src/csharp/experimental/newsskill/Deployment/Resources/template.json index c729f83188..bbe82b9b43 100644 --- a/skills/src/csharp/experimental/newsskill/Deployment/Resources/template.json +++ b/skills/src/csharp/experimental/newsskill/Deployment/Resources/template.json @@ -10,23 +10,35 @@ "type": "string", "defaultValue": "[resourceGroup().location]" }, + "suffix": { + "type": "string", + "defaultValue": "[take(uniqueString(resourceGroup().id), 7)]" + }, "microsoftAppId": { "type": "string" }, "microsoftAppPassword": { "type": "string" }, + "useCosmosDb": { + "type": "bool", + "defaultValue": true + }, "cosmosDbName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" + }, + "useStorage": { + "type": "bool", + "defaultValue": true }, "storageAccountName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanSku": { "type": "object", @@ -37,19 +49,19 @@ }, "appInsightsName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appInsightsLocation": { "type": "string", - "defaultValue": "westus2" + "defaultValue": "[resourceGroup().location]" }, "botWebAppName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceSku": { "type": "string", @@ -57,7 +69,7 @@ }, "luisServiceName": { "type": "string", - "defaultValue": "[concat(parameters('name'), '-luis')]" + "defaultValue": "[concat(parameters('name'), '-luis-', parameters('suffix'))]" }, "luisServiceSku": { "type": "string", @@ -77,8 +89,10 @@ } }, "variables": { - "botEndpoint": "[concat('https://', toLower(parameters('botWebAppName')), '.azurewebsites.net/api/messages')]", - "cleanStorageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]" + "botWebAppName": "[replace(parameters('botWebAppName'), '_', '')]", + "storageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]", + "cosmosDbAccountName": "[toLower(take(replace(parameters('cosmosDbName'), '_', ''), 31))]", + "botEndpoint": "[concat('https://', toLower(variables('botWebAppName')), '.azurewebsites.net/api/messages')]" }, "resources": [ { @@ -99,7 +113,7 @@ "type": "Microsoft.DocumentDB/databaseAccounts", "kind": "GlobalDocumentDB", "apiVersion": "2015-04-08", - "name": "[parameters('cosmosDbName')]", + "name": "[variables('cosmosDbAccountName')]", "location": "[parameters('location')]", "properties": { "databaseAccountOfferType": "Standard", @@ -109,18 +123,20 @@ "failoverPriority": 0 } ] - } + }, + "condition": "[parameters('useCosmosDb')]" }, { "comments": "storage account", "type": "Microsoft.Storage/storageAccounts", "kind": "StorageV2", "apiVersion": "2018-07-01", - "name": "[variables('cleanStorageAccountName')]", + "name": "[variables('storageAccountName')]", "location": "[parameters('location')]", "sku": { "name": "Standard_LRS" - } + }, + "condition": "[parameters('useStorage')]" }, { "comments": "app service plan", @@ -146,7 +162,7 @@ "comments": "bot web app", "type": "Microsoft.Web/sites", "apiVersion": "2018-02-01", - "name": "[parameters('botWebAppName')]", + "name": "[variables('botWebAppName')]", "location": "[parameters('location')]", "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]", @@ -221,7 +237,7 @@ "outputs": { "botWebAppName": { "type": "string", - "value": "[parameters('botWebAppName')]" + "value": "[variables('botWebAppName')]" }, "ApplicationInsights": { "type": "object", @@ -232,15 +248,15 @@ "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')]", + "connectionString": "[if(parameters('useStorage'), concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '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]", + "cosmosDBEndpoint": "[if(parameters('useCosmosDb'), reference(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName'))).documentEndpoint, '')]", + "authKey": "[if(parameters('useCosmosDb'), listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName')), '2015-04-08').primaryMasterKey, '')]", "databaseId": "botstate-db", "collectionId": "botstate-collection" } @@ -249,6 +265,7 @@ "type": "object", "value": { "accountName": "[parameters('luisServiceName')]", + "region": "[parameters('luisServiceLocation')]", "key": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', parameters('luisServiceName')),'2017-04-18').key1]" } }, diff --git a/skills/src/csharp/experimental/newsskill/Deployment/Scripts/deploy.ps1 b/skills/src/csharp/experimental/newsskill/Deployment/Scripts/deploy.ps1 index 0b79e0c717..78cbf4e5fc 100644 --- a/skills/src/csharp/experimental/newsskill/Deployment/Scripts/deploy.ps1 +++ b/skills/src/csharp/experimental/newsskill/Deployment/Scripts/deploy.ps1 @@ -79,7 +79,7 @@ if (-not $appId) { # Create app registration $app = (az ad app create ` --display-name $name ` - --password $appPassword ` + --password `"$($appPassword)`" ` --available-to-other-tenants ` --reply-urls 'https://token.botframework.com/.auth/web/redirect') @@ -198,7 +198,7 @@ if ($outputs) Start-Sleep -s 30 # Deploy cognitive models - 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)'" + Invoke-Expression "& '$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1')' -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -luisAccountName $($outputs.luis.value.accountName) -luisAccountRegion $($outputs.luis.value.region) -luisSubscriptionKey $($outputs.luis.value.key) -resourceGroup $($resourceGroup) -qnaSubscriptionKey '$($qnaSubscriptionKey)' -outFolder '$($projDir)' -languages '$($languages)'" # Publish bot Invoke-Expression "& '$(Join-Path $PSScriptRoot 'publish.ps1')' -name $($outputs.botWebAppName.value) -resourceGroup $($resourceGroup) -projFolder '$($projDir)'" diff --git a/skills/src/csharp/experimental/newsskill/Deployment/Scripts/deploy_cognitive_models.ps1 b/skills/src/csharp/experimental/newsskill/Deployment/Scripts/deploy_cognitive_models.ps1 index 22b708c23c..e3dfbfcd60 100644 --- a/skills/src/csharp/experimental/newsskill/Deployment/Scripts/deploy_cognitive_models.ps1 +++ b/skills/src/csharp/experimental/newsskill/Deployment/Scripts/deploy_cognitive_models.ps1 @@ -5,6 +5,7 @@ Param( [string] $luisAuthoringRegion, [string] $luisAuthoringKey, [string] $luisAccountName, + [string] $luisAccountRegion, [string] $luisSubscriptionKey, [string] $qnaSubscriptionKey, [string] $resourceGroup, @@ -86,6 +87,10 @@ if (-not $luisSubscriptionKey) { } } +if (-not $luisAccountRegion) { + $luisAccountRegion = Read-Host "? LUIS Service Location" +} + if (-not $qnaSubscriptionKey) { $useQna = $false } @@ -178,9 +183,10 @@ foreach ($language in $languageArr) name = $luisApp.name appid = $luisApp.id authoringkey = $luisAuthoringKey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey version = $luisApp.activeVersion - region = $luisAuthoringRegion + region = $luisAccountRegion } } else { @@ -279,8 +285,9 @@ foreach ($language in $languageArr) name = $dispatchApp.name appid = $dispatchApp.appId authoringkey = $luisauthoringkey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey - region = $luisAuthoringRegion + region = $luisAccountRegion } } } diff --git a/skills/src/csharp/experimental/newsskill/Deployment/Scripts/update_cognitive_models.ps1 b/skills/src/csharp/experimental/newsskill/Deployment/Scripts/update_cognitive_models.ps1 index e015ff3a63..827dee559a 100644 --- a/skills/src/csharp/experimental/newsskill/Deployment/Scripts/update_cognitive_models.ps1 +++ b/skills/src/csharp/experimental/newsskill/Deployment/Scripts/update_cognitive_models.ps1 @@ -2,6 +2,7 @@ Param( [switch] $RemoteToLocal, + [switch] $useLuisGen = $true, [string] $configFile = $(Join-Path (Get-Location) 'cognitivemodels.json'), [string] $dispatchFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'Dispatch'), [string] $luisFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'LU'), @@ -15,14 +16,14 @@ Param( # Reset log file if (Test-Path $logFile) { - Clear-Content $logFile -Force | Out-Null + Clear-Content $logFile -Force | Out-Null } else { - New-Item -Path $logFile | Out-Null + New-Item -Path $logFile | Out-Null } Write-Host "> Getting config file ..." -$languageMap = @{} +$languageMap = @{ } $config = Get-Content -Raw -Path $configFile | ConvertFrom-Json $config.cognitiveModels.PSObject.Properties | Foreach-Object { $languageMap[$_.Name] = $_.Value } @@ -30,62 +31,61 @@ foreach ($langCode in $languageMap.Keys) { $models = $languageMap[$langCode] $dispatch = $models.dispatchModel - if ($RemoteToLocal) - { + if ($RemoteToLocal) { # Update local LU files based on hosted models - foreach ($luisApp in $models.languageModels) - { - $culture = (luis get application ` - --appId $luisApp.appId ` - --authoringKey $luisApp.authoringKey ` - --subscriptionKey $luisApp.subscriptionKey ` - --region $luisApp.region | ConvertFrom-Json).culture + foreach ($luisApp in $models.languageModels) { + $culture = (luis get application ` + --appId $luisApp.appId ` + --authoringKey $luisApp.authoringKey ` + --subscriptionKey $luisApp.subscriptionKey ` + --region $luisApp.authoringRegion | ConvertFrom-Json).culture Write-Host "> Updating local $($luisApp.id).lu file ..." luis export version ` --appId $luisApp.appid ` --versionId $luisApp.version ` - --region $luisApp.region ` + --region $luisApp.authoringRegion ` --authoringKey $luisApp.authoringKey | ludown refresh ` --stdin ` -n "$($luisApp.id).lu" ` -o $(Join-Path $luisFolder $langCode) - # Parse LU file - $id = $luisApp.id - $outFile = "$($id).luis" - $outFolder = $(Join-Path $luisFolder $langCode) - $appName = "$($name)$($langCode)_$($id)" + # Parse LU file + $id = $luisApp.id + $outFile = "$($id).luis" + $outFolder = $(Join-Path $luisFolder $langCode) + $appName = "$($name)$($langCode)_$($id)" - Write-Host "> Parsing $($luisApp.id) LU file ..." - ludown parse toluis ` - --in $(Join-Path $outFolder "$($luisApp.id).lu") ` - --luis_culture $culture ` - --out_folder $(Join-Path $luisFolder $langCode) ` - --out "$($luisApp.id).luis" + Write-Host "> Parsing $($luisApp.id) LU file ..." + ludown parse toluis ` + --in $(Join-Path $outFolder "$($luisApp.id).lu") ` + --luis_culture $culture ` + --out_folder $(Join-Path $luisFolder $langCode) ` + --out "$($luisApp.id).luis" - Write-Host "> Running LuisGen for $($luisApp.id) app ..." - $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + if ($useLuisGen) { + Write-Host "> Running LuisGen for $($luisApp.id) app ..." + $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + } # Add the LUIS application to the dispatch model. # If the LUIS application id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($luisApp.id) app to dispatch model ... " - (dispatch add ` - --type "luis" ` - --name $luisApp.name ` - --id $luisApp.appid ` - --region $luisApp.region ` - --intentName "l_$($luisApp.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($luisApp.id) app to dispatch model ... " + (dispatch add ` + --type "luis" ` + --name $luisApp.name ` + --id $luisApp.appid ` + --region $luisApp.authoringRegion ` + --intentName "l_$($luisApp.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } # Update local LU files based on hosted QnA KBs - foreach ($kb in $models.knowledgebases) - { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating local $($kb.id).lu file ..." qnamaker export kb ` --environment Prod ` @@ -97,56 +97,57 @@ foreach ($langCode in $languageMap.Keys) { # Add the knowledge base to the dispatch model. # If the knowledge base id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($kb.id) kb to dispatch model ..." - (dispatch add ` - --type "qna" ` - --name $kb.name ` - --id $kb.kbId ` - --key $kb.subscriptionKey ` - --intentName "q_$($kb.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($kb.id) kb to dispatch model ..." + (dispatch add ` + --type "qna" ` + --name $kb.name ` + --id $kb.kbId ` + --key $kb.subscriptionKey ` + --intentName "q_$($kb.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } } - else - { + else { # Update each luis model based on local LU files - foreach ($luisApp in $models.languageModels) { + foreach ($luisApp in $models.languageModels) { Write-Host "> Updating hosted $($luisApp.id) app..." - $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - UpdateLUIS ` - -lu_file $lu ` - -appId $luisApp.appid ` - -version $luisApp.version ` - -region $luisApp.region ` - -authoringKey $luisApp.authoringKey ` - -subscriptionKey $app.subscriptionKey - } + $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + UpdateLUIS ` + -lu_file $lu ` + -appId $luisApp.appid ` + -version $luisApp.version ` + -region $luisApp.authoringRegion ` + -authoringKey $luisApp.authoringKey ` + -subscriptionKey $app.subscriptionKey + } # Update each knowledgebase based on local LU files - foreach ($kb in $models.knowledgebases) { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating hosted $($kb.id) kb..." - $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") - UpdateKB ` - -lu_file $lu ` - -kbId $kb.kbId ` - -qnaSubscriptionKey $kb.subscriptionKey + $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") + UpdateKB ` + -lu_file $lu ` + -kbId $kb.kbId ` + -qnaSubscriptionKey $kb.subscriptionKey } - } + } - if ($dispatch) { - # Update dispatch model - Write-Host "> Updating dispatch model ..." - dispatch refresh ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null + if ($dispatch) { + # Update dispatch model + Write-Host "> Updating dispatch model ..." + dispatch refresh ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null - # Update dispatch.cs file - Write-Host "> Running LuisGen for Dispatch app..." - luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null - } + if ($useLuisGen) { + # Update dispatch.cs file + Write-Host "> Running LuisGen for Dispatch app..." + luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null + } + } } Write-Host "> Done." \ No newline at end of file diff --git a/skills/src/csharp/experimental/newsskill/cognitivemodels.json b/skills/src/csharp/experimental/newsskill/cognitivemodels.json index 61e797c211..66e531ba3e 100644 --- a/skills/src/csharp/experimental/newsskill/cognitivemodels.json +++ b/skills/src/csharp/experimental/newsskill/cognitivemodels.json @@ -7,6 +7,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" @@ -16,6 +17,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" diff --git a/skills/src/csharp/experimental/restaurantbooking/Deployment/Resources/parameters.template.json b/skills/src/csharp/experimental/restaurantbooking/Deployment/Resources/parameters.template.json index 41a2013cad..95841eb589 100644 --- a/skills/src/csharp/experimental/restaurantbooking/Deployment/Resources/parameters.template.json +++ b/skills/src/csharp/experimental/restaurantbooking/Deployment/Resources/parameters.template.json @@ -2,11 +2,23 @@ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - "appInsightsLocation": { - "value": "westus2" + "useCosmosDb": { + "value": false }, - "luisServiceLocation": { - "value": "westus" + "useStorage": { + "value": false + }, + "appServicePlanSku": { + "value": { + "tier": "Free", + "name": "F1" + } + }, + "botServiceSku": { + "value": "F0" + }, + "luisServiceSku": { + "value": "F0" } } } \ No newline at end of file diff --git a/skills/src/csharp/experimental/restaurantbooking/Deployment/Resources/template.json b/skills/src/csharp/experimental/restaurantbooking/Deployment/Resources/template.json index d58858841a..8844fc970d 100644 --- a/skills/src/csharp/experimental/restaurantbooking/Deployment/Resources/template.json +++ b/skills/src/csharp/experimental/restaurantbooking/Deployment/Resources/template.json @@ -10,23 +10,35 @@ "type": "string", "defaultValue": "[resourceGroup().location]" }, + "suffix": { + "type": "string", + "defaultValue": "[take(uniqueString(resourceGroup().id), 7)]" + }, "microsoftAppId": { "type": "string" }, "microsoftAppPassword": { "type": "string" }, + "useCosmosDb": { + "type": "bool", + "defaultValue": true + }, "cosmosDbName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" + }, + "useStorage": { + "type": "bool", + "defaultValue": true }, "storageAccountName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanSku": { "type": "object", @@ -37,19 +49,19 @@ }, "appInsightsName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appInsightsLocation": { "type": "string", - "defaultValue": "westus2" + "defaultValue": "[resourceGroup().location]" }, "botWebAppName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceSku": { "type": "string", @@ -57,7 +69,7 @@ }, "luisServiceName": { "type": "string", - "defaultValue": "[concat(parameters('name'), '-luis')]" + "defaultValue": "[concat(parameters('name'), '-luis-', parameters('suffix'))]" }, "luisServiceSku": { "type": "string", @@ -69,8 +81,10 @@ } }, "variables": { - "botEndpoint": "[concat('https://', toLower(parameters('botWebAppName')), '.azurewebsites.net/api/messages')]", - "cleanStorageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]" + "botWebAppName": "[replace(parameters('botWebAppName'), '_', '')]", + "storageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]", + "cosmosDbAccountName": "[toLower(take(replace(parameters('cosmosDbName'), '_', ''), 31))]", + "botEndpoint": "[concat('https://', toLower(variables('botWebAppName')), '.azurewebsites.net/api/messages')]" }, "resources": [ { @@ -91,7 +105,7 @@ "type": "Microsoft.DocumentDB/databaseAccounts", "kind": "GlobalDocumentDB", "apiVersion": "2015-04-08", - "name": "[parameters('cosmosDbName')]", + "name": "[variables('cosmosDbAccountName')]", "location": "[parameters('location')]", "properties": { "databaseAccountOfferType": "Standard", @@ -101,18 +115,20 @@ "failoverPriority": 0 } ] - } + }, + "condition": "[parameters('useCosmosDb')]" }, { "comments": "storage account", "type": "Microsoft.Storage/storageAccounts", "kind": "StorageV2", "apiVersion": "2018-07-01", - "name": "[variables('cleanStorageAccountName')]", + "name": "[variables('storageAccountName')]", "location": "[parameters('location')]", "sku": { "name": "Standard_LRS" - } + }, + "condition": "[parameters('useStorage')]" }, { "comments": "app service plan", @@ -138,7 +154,7 @@ "comments": "bot web app", "type": "Microsoft.Web/sites", "apiVersion": "2018-02-01", - "name": "[parameters('botWebAppName')]", + "name": "[variables('botWebAppName')]", "location": "[parameters('location')]", "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]", @@ -193,7 +209,7 @@ "outputs": { "botWebAppName": { "type": "string", - "value": "[parameters('botWebAppName')]" + "value": "[variables('botWebAppName')]" }, "ApplicationInsights": { "type": "object", @@ -204,15 +220,15 @@ "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')]", + "connectionString": "[if(parameters('useStorage'), concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '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]", + "cosmosDBEndpoint": "[if(parameters('useCosmosDb'), reference(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName'))).documentEndpoint, '')]", + "authKey": "[if(parameters('useCosmosDb'), listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName')), '2015-04-08').primaryMasterKey, '')]", "databaseId": "botstate-db", "collectionId": "botstate-collection" } @@ -221,6 +237,7 @@ "type": "object", "value": { "accountName": "[parameters('luisServiceName')]", + "region": "[parameters('luisServiceLocation')]", "key": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', parameters('luisServiceName')),'2017-04-18').key1]" } } diff --git a/skills/src/csharp/experimental/restaurantbooking/Deployment/Scripts/deploy.ps1 b/skills/src/csharp/experimental/restaurantbooking/Deployment/Scripts/deploy.ps1 index 0b79e0c717..78cbf4e5fc 100644 --- a/skills/src/csharp/experimental/restaurantbooking/Deployment/Scripts/deploy.ps1 +++ b/skills/src/csharp/experimental/restaurantbooking/Deployment/Scripts/deploy.ps1 @@ -79,7 +79,7 @@ if (-not $appId) { # Create app registration $app = (az ad app create ` --display-name $name ` - --password $appPassword ` + --password `"$($appPassword)`" ` --available-to-other-tenants ` --reply-urls 'https://token.botframework.com/.auth/web/redirect') @@ -198,7 +198,7 @@ if ($outputs) Start-Sleep -s 30 # Deploy cognitive models - 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)'" + Invoke-Expression "& '$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1')' -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -luisAccountName $($outputs.luis.value.accountName) -luisAccountRegion $($outputs.luis.value.region) -luisSubscriptionKey $($outputs.luis.value.key) -resourceGroup $($resourceGroup) -qnaSubscriptionKey '$($qnaSubscriptionKey)' -outFolder '$($projDir)' -languages '$($languages)'" # Publish bot Invoke-Expression "& '$(Join-Path $PSScriptRoot 'publish.ps1')' -name $($outputs.botWebAppName.value) -resourceGroup $($resourceGroup) -projFolder '$($projDir)'" diff --git a/skills/src/csharp/experimental/restaurantbooking/Deployment/Scripts/deploy_cognitive_models.ps1 b/skills/src/csharp/experimental/restaurantbooking/Deployment/Scripts/deploy_cognitive_models.ps1 index 22b708c23c..e3dfbfcd60 100644 --- a/skills/src/csharp/experimental/restaurantbooking/Deployment/Scripts/deploy_cognitive_models.ps1 +++ b/skills/src/csharp/experimental/restaurantbooking/Deployment/Scripts/deploy_cognitive_models.ps1 @@ -5,6 +5,7 @@ Param( [string] $luisAuthoringRegion, [string] $luisAuthoringKey, [string] $luisAccountName, + [string] $luisAccountRegion, [string] $luisSubscriptionKey, [string] $qnaSubscriptionKey, [string] $resourceGroup, @@ -86,6 +87,10 @@ if (-not $luisSubscriptionKey) { } } +if (-not $luisAccountRegion) { + $luisAccountRegion = Read-Host "? LUIS Service Location" +} + if (-not $qnaSubscriptionKey) { $useQna = $false } @@ -178,9 +183,10 @@ foreach ($language in $languageArr) name = $luisApp.name appid = $luisApp.id authoringkey = $luisAuthoringKey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey version = $luisApp.activeVersion - region = $luisAuthoringRegion + region = $luisAccountRegion } } else { @@ -279,8 +285,9 @@ foreach ($language in $languageArr) name = $dispatchApp.name appid = $dispatchApp.appId authoringkey = $luisauthoringkey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey - region = $luisAuthoringRegion + region = $luisAccountRegion } } } diff --git a/skills/src/csharp/experimental/restaurantbooking/Deployment/Scripts/update_cognitive_models.ps1 b/skills/src/csharp/experimental/restaurantbooking/Deployment/Scripts/update_cognitive_models.ps1 index e015ff3a63..827dee559a 100644 --- a/skills/src/csharp/experimental/restaurantbooking/Deployment/Scripts/update_cognitive_models.ps1 +++ b/skills/src/csharp/experimental/restaurantbooking/Deployment/Scripts/update_cognitive_models.ps1 @@ -2,6 +2,7 @@ Param( [switch] $RemoteToLocal, + [switch] $useLuisGen = $true, [string] $configFile = $(Join-Path (Get-Location) 'cognitivemodels.json'), [string] $dispatchFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'Dispatch'), [string] $luisFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'LU'), @@ -15,14 +16,14 @@ Param( # Reset log file if (Test-Path $logFile) { - Clear-Content $logFile -Force | Out-Null + Clear-Content $logFile -Force | Out-Null } else { - New-Item -Path $logFile | Out-Null + New-Item -Path $logFile | Out-Null } Write-Host "> Getting config file ..." -$languageMap = @{} +$languageMap = @{ } $config = Get-Content -Raw -Path $configFile | ConvertFrom-Json $config.cognitiveModels.PSObject.Properties | Foreach-Object { $languageMap[$_.Name] = $_.Value } @@ -30,62 +31,61 @@ foreach ($langCode in $languageMap.Keys) { $models = $languageMap[$langCode] $dispatch = $models.dispatchModel - if ($RemoteToLocal) - { + if ($RemoteToLocal) { # Update local LU files based on hosted models - foreach ($luisApp in $models.languageModels) - { - $culture = (luis get application ` - --appId $luisApp.appId ` - --authoringKey $luisApp.authoringKey ` - --subscriptionKey $luisApp.subscriptionKey ` - --region $luisApp.region | ConvertFrom-Json).culture + foreach ($luisApp in $models.languageModels) { + $culture = (luis get application ` + --appId $luisApp.appId ` + --authoringKey $luisApp.authoringKey ` + --subscriptionKey $luisApp.subscriptionKey ` + --region $luisApp.authoringRegion | ConvertFrom-Json).culture Write-Host "> Updating local $($luisApp.id).lu file ..." luis export version ` --appId $luisApp.appid ` --versionId $luisApp.version ` - --region $luisApp.region ` + --region $luisApp.authoringRegion ` --authoringKey $luisApp.authoringKey | ludown refresh ` --stdin ` -n "$($luisApp.id).lu" ` -o $(Join-Path $luisFolder $langCode) - # Parse LU file - $id = $luisApp.id - $outFile = "$($id).luis" - $outFolder = $(Join-Path $luisFolder $langCode) - $appName = "$($name)$($langCode)_$($id)" + # Parse LU file + $id = $luisApp.id + $outFile = "$($id).luis" + $outFolder = $(Join-Path $luisFolder $langCode) + $appName = "$($name)$($langCode)_$($id)" - Write-Host "> Parsing $($luisApp.id) LU file ..." - ludown parse toluis ` - --in $(Join-Path $outFolder "$($luisApp.id).lu") ` - --luis_culture $culture ` - --out_folder $(Join-Path $luisFolder $langCode) ` - --out "$($luisApp.id).luis" + Write-Host "> Parsing $($luisApp.id) LU file ..." + ludown parse toluis ` + --in $(Join-Path $outFolder "$($luisApp.id).lu") ` + --luis_culture $culture ` + --out_folder $(Join-Path $luisFolder $langCode) ` + --out "$($luisApp.id).luis" - Write-Host "> Running LuisGen for $($luisApp.id) app ..." - $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + if ($useLuisGen) { + Write-Host "> Running LuisGen for $($luisApp.id) app ..." + $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + } # Add the LUIS application to the dispatch model. # If the LUIS application id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($luisApp.id) app to dispatch model ... " - (dispatch add ` - --type "luis" ` - --name $luisApp.name ` - --id $luisApp.appid ` - --region $luisApp.region ` - --intentName "l_$($luisApp.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($luisApp.id) app to dispatch model ... " + (dispatch add ` + --type "luis" ` + --name $luisApp.name ` + --id $luisApp.appid ` + --region $luisApp.authoringRegion ` + --intentName "l_$($luisApp.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } # Update local LU files based on hosted QnA KBs - foreach ($kb in $models.knowledgebases) - { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating local $($kb.id).lu file ..." qnamaker export kb ` --environment Prod ` @@ -97,56 +97,57 @@ foreach ($langCode in $languageMap.Keys) { # Add the knowledge base to the dispatch model. # If the knowledge base id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($kb.id) kb to dispatch model ..." - (dispatch add ` - --type "qna" ` - --name $kb.name ` - --id $kb.kbId ` - --key $kb.subscriptionKey ` - --intentName "q_$($kb.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($kb.id) kb to dispatch model ..." + (dispatch add ` + --type "qna" ` + --name $kb.name ` + --id $kb.kbId ` + --key $kb.subscriptionKey ` + --intentName "q_$($kb.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } } - else - { + else { # Update each luis model based on local LU files - foreach ($luisApp in $models.languageModels) { + foreach ($luisApp in $models.languageModels) { Write-Host "> Updating hosted $($luisApp.id) app..." - $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - UpdateLUIS ` - -lu_file $lu ` - -appId $luisApp.appid ` - -version $luisApp.version ` - -region $luisApp.region ` - -authoringKey $luisApp.authoringKey ` - -subscriptionKey $app.subscriptionKey - } + $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + UpdateLUIS ` + -lu_file $lu ` + -appId $luisApp.appid ` + -version $luisApp.version ` + -region $luisApp.authoringRegion ` + -authoringKey $luisApp.authoringKey ` + -subscriptionKey $app.subscriptionKey + } # Update each knowledgebase based on local LU files - foreach ($kb in $models.knowledgebases) { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating hosted $($kb.id) kb..." - $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") - UpdateKB ` - -lu_file $lu ` - -kbId $kb.kbId ` - -qnaSubscriptionKey $kb.subscriptionKey + $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") + UpdateKB ` + -lu_file $lu ` + -kbId $kb.kbId ` + -qnaSubscriptionKey $kb.subscriptionKey } - } + } - if ($dispatch) { - # Update dispatch model - Write-Host "> Updating dispatch model ..." - dispatch refresh ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null + if ($dispatch) { + # Update dispatch model + Write-Host "> Updating dispatch model ..." + dispatch refresh ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null - # Update dispatch.cs file - Write-Host "> Running LuisGen for Dispatch app..." - luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null - } + if ($useLuisGen) { + # Update dispatch.cs file + Write-Host "> Running LuisGen for Dispatch app..." + luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null + } + } } Write-Host "> Done." \ No newline at end of file diff --git a/skills/src/csharp/experimental/restaurantbooking/cognitivemodels.json b/skills/src/csharp/experimental/restaurantbooking/cognitivemodels.json index a7b4a332d2..579f16cc44 100644 --- a/skills/src/csharp/experimental/restaurantbooking/cognitivemodels.json +++ b/skills/src/csharp/experimental/restaurantbooking/cognitivemodels.json @@ -7,6 +7,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" @@ -16,6 +17,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" diff --git a/skills/src/csharp/experimental/weatherskill/Deployment/Resources/parameters.template.json b/skills/src/csharp/experimental/weatherskill/Deployment/Resources/parameters.template.json index 009470a910..95841eb589 100644 --- a/skills/src/csharp/experimental/weatherskill/Deployment/Resources/parameters.template.json +++ b/skills/src/csharp/experimental/weatherskill/Deployment/Resources/parameters.template.json @@ -2,14 +2,23 @@ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - "appInsightsLocation": { - "value": "westus2" + "useCosmosDb": { + "value": false }, - "luisServiceLocation": { - "value": "westus" + "useStorage": { + "value": false }, - "qnaMakerSearchSku": { - "value": "standard" + "appServicePlanSku": { + "value": { + "tier": "Free", + "name": "F1" + } + }, + "botServiceSku": { + "value": "F0" + }, + "luisServiceSku": { + "value": "F0" } } } \ No newline at end of file diff --git a/skills/src/csharp/experimental/weatherskill/Deployment/Resources/template.json b/skills/src/csharp/experimental/weatherskill/Deployment/Resources/template.json index 18f13f255e..ed5abd6b25 100644 --- a/skills/src/csharp/experimental/weatherskill/Deployment/Resources/template.json +++ b/skills/src/csharp/experimental/weatherskill/Deployment/Resources/template.json @@ -10,23 +10,35 @@ "type": "string", "defaultValue": "[resourceGroup().location]" }, + "suffix": { + "type": "string", + "defaultValue": "[take(uniqueString(resourceGroup().id), 7)]" + }, "microsoftAppId": { "type": "string" }, "microsoftAppPassword": { "type": "string" }, + "useCosmosDb": { + "type": "bool", + "defaultValue": true + }, "cosmosDbName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" + }, + "useStorage": { + "type": "bool", + "defaultValue": true }, "storageAccountName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanSku": { "type": "object", @@ -37,19 +49,19 @@ }, "appInsightsName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appInsightsLocation": { "type": "string", - "defaultValue": "westus2" + "defaultValue": "[resourceGroup().location]" }, "botWebAppName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceSku": { "type": "string", @@ -57,7 +69,7 @@ }, "luisServiceName": { "type": "string", - "defaultValue": "[concat(parameters('name'), '-luis')]" + "defaultValue": "[concat(parameters('name'), '-luis-', parameters('suffix'))]" }, "luisServiceSku": { "type": "string", @@ -69,8 +81,10 @@ } }, "variables": { - "botEndpoint": "[concat('https://', toLower(parameters('botWebAppName')), '.azurewebsites.net/api/messages')]", - "cleanStorageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]" + "botWebAppName": "[replace(parameters('botWebAppName'), '_', '')]", + "storageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]", + "cosmosDbAccountName": "[toLower(take(replace(parameters('cosmosDbName'), '_', ''), 31))]", + "botEndpoint": "[concat('https://', toLower(variables('botWebAppName')), '.azurewebsites.net/api/messages')]" }, "resources": [ { @@ -91,7 +105,7 @@ "type": "Microsoft.DocumentDB/databaseAccounts", "kind": "GlobalDocumentDB", "apiVersion": "2015-04-08", - "name": "[parameters('cosmosDbName')]", + "name": "[variables('cosmosDbAccountName')]", "location": "[parameters('location')]", "properties": { "databaseAccountOfferType": "Standard", @@ -101,18 +115,20 @@ "failoverPriority": 0 } ] - } + }, + "condition": "[parameters('useCosmosDb')]" }, { "comments": "storage account", "type": "Microsoft.Storage/storageAccounts", "kind": "StorageV2", "apiVersion": "2018-07-01", - "name": "[variables('cleanStorageAccountName')]", + "name": "[variables('storageAccountName')]", "location": "[parameters('location')]", "sku": { "name": "Standard_LRS" - } + }, + "condition": "[parameters('useStorage')]" }, { "comments": "app service plan", @@ -138,7 +154,7 @@ "comments": "bot web app", "type": "Microsoft.Web/sites", "apiVersion": "2018-02-01", - "name": "[parameters('botWebAppName')]", + "name": "[variables('botWebAppName')]", "location": "[parameters('location')]", "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]", @@ -193,7 +209,7 @@ "outputs": { "botWebAppName": { "type": "string", - "value": "[parameters('botWebAppName')]" + "value": "[variables('botWebAppName')]" }, "ApplicationInsights": { "type": "object", @@ -204,15 +220,15 @@ "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')]", + "connectionString": "[if(parameters('useStorage'), concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '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]", + "cosmosDBEndpoint": "[if(parameters('useCosmosDb'), reference(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName'))).documentEndpoint, '')]", + "authKey": "[if(parameters('useCosmosDb'), listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName')), '2015-04-08').primaryMasterKey, '')]", "databaseId": "botstate-db", "collectionId": "botstate-collection" } @@ -221,8 +237,9 @@ "type": "object", "value": { "accountName": "[parameters('luisServiceName')]", + "region": "[parameters('luisServiceLocation')]", "key": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', parameters('luisServiceName')),'2017-04-18').key1]" - } + } } } } \ No newline at end of file diff --git a/skills/src/csharp/experimental/weatherskill/Deployment/Scripts/deploy.ps1 b/skills/src/csharp/experimental/weatherskill/Deployment/Scripts/deploy.ps1 index 0b79e0c717..78cbf4e5fc 100644 --- a/skills/src/csharp/experimental/weatherskill/Deployment/Scripts/deploy.ps1 +++ b/skills/src/csharp/experimental/weatherskill/Deployment/Scripts/deploy.ps1 @@ -79,7 +79,7 @@ if (-not $appId) { # Create app registration $app = (az ad app create ` --display-name $name ` - --password $appPassword ` + --password `"$($appPassword)`" ` --available-to-other-tenants ` --reply-urls 'https://token.botframework.com/.auth/web/redirect') @@ -198,7 +198,7 @@ if ($outputs) Start-Sleep -s 30 # Deploy cognitive models - 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)'" + Invoke-Expression "& '$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1')' -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -luisAccountName $($outputs.luis.value.accountName) -luisAccountRegion $($outputs.luis.value.region) -luisSubscriptionKey $($outputs.luis.value.key) -resourceGroup $($resourceGroup) -qnaSubscriptionKey '$($qnaSubscriptionKey)' -outFolder '$($projDir)' -languages '$($languages)'" # Publish bot Invoke-Expression "& '$(Join-Path $PSScriptRoot 'publish.ps1')' -name $($outputs.botWebAppName.value) -resourceGroup $($resourceGroup) -projFolder '$($projDir)'" diff --git a/skills/src/csharp/experimental/weatherskill/Deployment/Scripts/deploy_cognitive_models.ps1 b/skills/src/csharp/experimental/weatherskill/Deployment/Scripts/deploy_cognitive_models.ps1 index 22b708c23c..e3dfbfcd60 100644 --- a/skills/src/csharp/experimental/weatherskill/Deployment/Scripts/deploy_cognitive_models.ps1 +++ b/skills/src/csharp/experimental/weatherskill/Deployment/Scripts/deploy_cognitive_models.ps1 @@ -5,6 +5,7 @@ Param( [string] $luisAuthoringRegion, [string] $luisAuthoringKey, [string] $luisAccountName, + [string] $luisAccountRegion, [string] $luisSubscriptionKey, [string] $qnaSubscriptionKey, [string] $resourceGroup, @@ -86,6 +87,10 @@ if (-not $luisSubscriptionKey) { } } +if (-not $luisAccountRegion) { + $luisAccountRegion = Read-Host "? LUIS Service Location" +} + if (-not $qnaSubscriptionKey) { $useQna = $false } @@ -178,9 +183,10 @@ foreach ($language in $languageArr) name = $luisApp.name appid = $luisApp.id authoringkey = $luisAuthoringKey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey version = $luisApp.activeVersion - region = $luisAuthoringRegion + region = $luisAccountRegion } } else { @@ -279,8 +285,9 @@ foreach ($language in $languageArr) name = $dispatchApp.name appid = $dispatchApp.appId authoringkey = $luisauthoringkey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey - region = $luisAuthoringRegion + region = $luisAccountRegion } } } diff --git a/skills/src/csharp/experimental/weatherskill/Deployment/Scripts/update_cognitive_models.ps1 b/skills/src/csharp/experimental/weatherskill/Deployment/Scripts/update_cognitive_models.ps1 index e015ff3a63..827dee559a 100644 --- a/skills/src/csharp/experimental/weatherskill/Deployment/Scripts/update_cognitive_models.ps1 +++ b/skills/src/csharp/experimental/weatherskill/Deployment/Scripts/update_cognitive_models.ps1 @@ -2,6 +2,7 @@ Param( [switch] $RemoteToLocal, + [switch] $useLuisGen = $true, [string] $configFile = $(Join-Path (Get-Location) 'cognitivemodels.json'), [string] $dispatchFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'Dispatch'), [string] $luisFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'LU'), @@ -15,14 +16,14 @@ Param( # Reset log file if (Test-Path $logFile) { - Clear-Content $logFile -Force | Out-Null + Clear-Content $logFile -Force | Out-Null } else { - New-Item -Path $logFile | Out-Null + New-Item -Path $logFile | Out-Null } Write-Host "> Getting config file ..." -$languageMap = @{} +$languageMap = @{ } $config = Get-Content -Raw -Path $configFile | ConvertFrom-Json $config.cognitiveModels.PSObject.Properties | Foreach-Object { $languageMap[$_.Name] = $_.Value } @@ -30,62 +31,61 @@ foreach ($langCode in $languageMap.Keys) { $models = $languageMap[$langCode] $dispatch = $models.dispatchModel - if ($RemoteToLocal) - { + if ($RemoteToLocal) { # Update local LU files based on hosted models - foreach ($luisApp in $models.languageModels) - { - $culture = (luis get application ` - --appId $luisApp.appId ` - --authoringKey $luisApp.authoringKey ` - --subscriptionKey $luisApp.subscriptionKey ` - --region $luisApp.region | ConvertFrom-Json).culture + foreach ($luisApp in $models.languageModels) { + $culture = (luis get application ` + --appId $luisApp.appId ` + --authoringKey $luisApp.authoringKey ` + --subscriptionKey $luisApp.subscriptionKey ` + --region $luisApp.authoringRegion | ConvertFrom-Json).culture Write-Host "> Updating local $($luisApp.id).lu file ..." luis export version ` --appId $luisApp.appid ` --versionId $luisApp.version ` - --region $luisApp.region ` + --region $luisApp.authoringRegion ` --authoringKey $luisApp.authoringKey | ludown refresh ` --stdin ` -n "$($luisApp.id).lu" ` -o $(Join-Path $luisFolder $langCode) - # Parse LU file - $id = $luisApp.id - $outFile = "$($id).luis" - $outFolder = $(Join-Path $luisFolder $langCode) - $appName = "$($name)$($langCode)_$($id)" + # Parse LU file + $id = $luisApp.id + $outFile = "$($id).luis" + $outFolder = $(Join-Path $luisFolder $langCode) + $appName = "$($name)$($langCode)_$($id)" - Write-Host "> Parsing $($luisApp.id) LU file ..." - ludown parse toluis ` - --in $(Join-Path $outFolder "$($luisApp.id).lu") ` - --luis_culture $culture ` - --out_folder $(Join-Path $luisFolder $langCode) ` - --out "$($luisApp.id).luis" + Write-Host "> Parsing $($luisApp.id) LU file ..." + ludown parse toluis ` + --in $(Join-Path $outFolder "$($luisApp.id).lu") ` + --luis_culture $culture ` + --out_folder $(Join-Path $luisFolder $langCode) ` + --out "$($luisApp.id).luis" - Write-Host "> Running LuisGen for $($luisApp.id) app ..." - $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + if ($useLuisGen) { + Write-Host "> Running LuisGen for $($luisApp.id) app ..." + $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + } # Add the LUIS application to the dispatch model. # If the LUIS application id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($luisApp.id) app to dispatch model ... " - (dispatch add ` - --type "luis" ` - --name $luisApp.name ` - --id $luisApp.appid ` - --region $luisApp.region ` - --intentName "l_$($luisApp.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($luisApp.id) app to dispatch model ... " + (dispatch add ` + --type "luis" ` + --name $luisApp.name ` + --id $luisApp.appid ` + --region $luisApp.authoringRegion ` + --intentName "l_$($luisApp.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } # Update local LU files based on hosted QnA KBs - foreach ($kb in $models.knowledgebases) - { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating local $($kb.id).lu file ..." qnamaker export kb ` --environment Prod ` @@ -97,56 +97,57 @@ foreach ($langCode in $languageMap.Keys) { # Add the knowledge base to the dispatch model. # If the knowledge base id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($kb.id) kb to dispatch model ..." - (dispatch add ` - --type "qna" ` - --name $kb.name ` - --id $kb.kbId ` - --key $kb.subscriptionKey ` - --intentName "q_$($kb.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($kb.id) kb to dispatch model ..." + (dispatch add ` + --type "qna" ` + --name $kb.name ` + --id $kb.kbId ` + --key $kb.subscriptionKey ` + --intentName "q_$($kb.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } } - else - { + else { # Update each luis model based on local LU files - foreach ($luisApp in $models.languageModels) { + foreach ($luisApp in $models.languageModels) { Write-Host "> Updating hosted $($luisApp.id) app..." - $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - UpdateLUIS ` - -lu_file $lu ` - -appId $luisApp.appid ` - -version $luisApp.version ` - -region $luisApp.region ` - -authoringKey $luisApp.authoringKey ` - -subscriptionKey $app.subscriptionKey - } + $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + UpdateLUIS ` + -lu_file $lu ` + -appId $luisApp.appid ` + -version $luisApp.version ` + -region $luisApp.authoringRegion ` + -authoringKey $luisApp.authoringKey ` + -subscriptionKey $app.subscriptionKey + } # Update each knowledgebase based on local LU files - foreach ($kb in $models.knowledgebases) { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating hosted $($kb.id) kb..." - $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") - UpdateKB ` - -lu_file $lu ` - -kbId $kb.kbId ` - -qnaSubscriptionKey $kb.subscriptionKey + $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") + UpdateKB ` + -lu_file $lu ` + -kbId $kb.kbId ` + -qnaSubscriptionKey $kb.subscriptionKey } - } + } - if ($dispatch) { - # Update dispatch model - Write-Host "> Updating dispatch model ..." - dispatch refresh ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null + if ($dispatch) { + # Update dispatch model + Write-Host "> Updating dispatch model ..." + dispatch refresh ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null - # Update dispatch.cs file - Write-Host "> Running LuisGen for Dispatch app..." - luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null - } + if ($useLuisGen) { + # Update dispatch.cs file + Write-Host "> Running LuisGen for Dispatch app..." + luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null + } + } } Write-Host "> Done." \ No newline at end of file diff --git a/skills/src/csharp/experimental/weatherskill/cognitivemodels.json b/skills/src/csharp/experimental/weatherskill/cognitivemodels.json index a9a9647edb..4a660a12ec 100644 --- a/skills/src/csharp/experimental/weatherskill/cognitivemodels.json +++ b/skills/src/csharp/experimental/weatherskill/cognitivemodels.json @@ -7,6 +7,7 @@ "appid": "", "id": "General", "authoringkey": "", + "authoringRegion": "", "region": "", "subscriptionkey": "", "name": "" @@ -16,6 +17,7 @@ "appid": "", "id": "WeatherSkill", "authoringkey": "", + "authoringRegion": "", "region": "", "subscriptionkey": "", "name": "" diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Resources/parameters.template.json b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Resources/parameters.template.json index 41a2013cad..95841eb589 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Resources/parameters.template.json +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Resources/parameters.template.json @@ -2,11 +2,23 @@ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - "appInsightsLocation": { - "value": "westus2" + "useCosmosDb": { + "value": false }, - "luisServiceLocation": { - "value": "westus" + "useStorage": { + "value": false + }, + "appServicePlanSku": { + "value": { + "tier": "Free", + "name": "F1" + } + }, + "botServiceSku": { + "value": "F0" + }, + "luisServiceSku": { + "value": "F0" } } } \ No newline at end of file diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Resources/template.json b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Resources/template.json index 2c1e1e93b0..ecb64680b6 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Resources/template.json +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Resources/template.json @@ -10,23 +10,35 @@ "type": "string", "defaultValue": "[resourceGroup().location]" }, + "suffix": { + "type": "string", + "defaultValue": "[take(uniqueString(resourceGroup().id), 7)]" + }, "microsoftAppId": { "type": "string" }, "microsoftAppPassword": { "type": "string" }, + "useCosmosDb": { + "type": "bool", + "defaultValue": true + }, "cosmosDbName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" + }, + "useStorage": { + "type": "bool", + "defaultValue": true }, "storageAccountName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanSku": { "type": "object", @@ -37,19 +49,19 @@ }, "appInsightsName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appInsightsLocation": { "type": "string", - "defaultValue": "westus2" + "defaultValue": "[resourceGroup().location]" }, "botWebAppName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceSku": { "type": "string", @@ -57,7 +69,7 @@ }, "luisServiceName": { "type": "string", - "defaultValue": "[concat(parameters('name'), '-luis')]" + "defaultValue": "[concat(parameters('name'), '-luis-', parameters('suffix'))]" }, "luisServiceSku": { "type": "string", @@ -73,8 +85,10 @@ } }, "variables": { - "botEndpoint": "[concat('https://', toLower(parameters('botWebAppName')), '.azurewebsites.net/api/messages')]", - "cleanStorageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]" + "botWebAppName": "[replace(parameters('botWebAppName'), '_', '')]", + "storageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]", + "cosmosDbAccountName": "[toLower(take(replace(parameters('cosmosDbName'), '_', ''), 31))]", + "botEndpoint": "[concat('https://', toLower(variables('botWebAppName')), '.azurewebsites.net/api/messages')]" }, "resources": [ { @@ -95,7 +109,7 @@ "type": "Microsoft.DocumentDB/databaseAccounts", "kind": "GlobalDocumentDB", "apiVersion": "2015-04-08", - "name": "[parameters('cosmosDbName')]", + "name": "[variables('cosmosDbAccountName')]", "location": "[parameters('location')]", "properties": { "databaseAccountOfferType": "Standard", @@ -105,18 +119,20 @@ "failoverPriority": 0 } ] - } + }, + "condition": "[parameters('useCosmosDb')]" }, { "comments": "storage account", "type": "Microsoft.Storage/storageAccounts", "kind": "StorageV2", "apiVersion": "2018-07-01", - "name": "[variables('cleanStorageAccountName')]", + "name": "[variables('storageAccountName')]", "location": "[parameters('location')]", "sku": { "name": "Standard_LRS" - } + }, + "condition": "[parameters('useStorage')]" }, { "comments": "app service plan", @@ -142,7 +158,7 @@ "comments": "bot web app", "type": "Microsoft.Web/sites", "apiVersion": "2018-02-01", - "name": "[parameters('botWebAppName')]", + "name": "[variables('botWebAppName')]", "location": "[parameters('location')]", "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]", @@ -207,7 +223,7 @@ "outputs": { "botWebAppName": { "type": "string", - "value": "[parameters('botWebAppName')]" + "value": "[variables('botWebAppName')]" }, "ApplicationInsights": { "type": "object", @@ -218,15 +234,15 @@ "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')]", + "connectionString": "[if(parameters('useStorage'), concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '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]", + "cosmosDBEndpoint": "[if(parameters('useCosmosDb'), reference(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName'))).documentEndpoint, '')]", + "authKey": "[if(parameters('useCosmosDb'), listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName')), '2015-04-08').primaryMasterKey, '')]", "databaseId": "botstate-db", "collectionId": "botstate-collection" } @@ -235,6 +251,7 @@ "type": "object", "value": { "accountName": "[parameters('luisServiceName')]", + "region": "[parameters('luisServiceLocation')]", "key": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', parameters('luisServiceName')),'2017-04-18').key1]" } }, diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Scripts/deploy.ps1 b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Scripts/deploy.ps1 index 0b79e0c717..78cbf4e5fc 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Scripts/deploy.ps1 +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Scripts/deploy.ps1 @@ -79,7 +79,7 @@ if (-not $appId) { # Create app registration $app = (az ad app create ` --display-name $name ` - --password $appPassword ` + --password `"$($appPassword)`" ` --available-to-other-tenants ` --reply-urls 'https://token.botframework.com/.auth/web/redirect') @@ -198,7 +198,7 @@ if ($outputs) Start-Sleep -s 30 # Deploy cognitive models - 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)'" + Invoke-Expression "& '$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1')' -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -luisAccountName $($outputs.luis.value.accountName) -luisAccountRegion $($outputs.luis.value.region) -luisSubscriptionKey $($outputs.luis.value.key) -resourceGroup $($resourceGroup) -qnaSubscriptionKey '$($qnaSubscriptionKey)' -outFolder '$($projDir)' -languages '$($languages)'" # Publish bot Invoke-Expression "& '$(Join-Path $PSScriptRoot 'publish.ps1')' -name $($outputs.botWebAppName.value) -resourceGroup $($resourceGroup) -projFolder '$($projDir)'" diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Scripts/deploy_cognitive_models.ps1 b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Scripts/deploy_cognitive_models.ps1 index 22b708c23c..e3dfbfcd60 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Scripts/deploy_cognitive_models.ps1 +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Scripts/deploy_cognitive_models.ps1 @@ -5,6 +5,7 @@ Param( [string] $luisAuthoringRegion, [string] $luisAuthoringKey, [string] $luisAccountName, + [string] $luisAccountRegion, [string] $luisSubscriptionKey, [string] $qnaSubscriptionKey, [string] $resourceGroup, @@ -86,6 +87,10 @@ if (-not $luisSubscriptionKey) { } } +if (-not $luisAccountRegion) { + $luisAccountRegion = Read-Host "? LUIS Service Location" +} + if (-not $qnaSubscriptionKey) { $useQna = $false } @@ -178,9 +183,10 @@ foreach ($language in $languageArr) name = $luisApp.name appid = $luisApp.id authoringkey = $luisAuthoringKey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey version = $luisApp.activeVersion - region = $luisAuthoringRegion + region = $luisAccountRegion } } else { @@ -279,8 +285,9 @@ foreach ($language in $languageArr) name = $dispatchApp.name appid = $dispatchApp.appId authoringkey = $luisauthoringkey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey - region = $luisAuthoringRegion + region = $luisAccountRegion } } } diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Scripts/update_cognitive_models.ps1 b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Scripts/update_cognitive_models.ps1 index e015ff3a63..827dee559a 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Scripts/update_cognitive_models.ps1 +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/Deployment/Scripts/update_cognitive_models.ps1 @@ -2,6 +2,7 @@ Param( [switch] $RemoteToLocal, + [switch] $useLuisGen = $true, [string] $configFile = $(Join-Path (Get-Location) 'cognitivemodels.json'), [string] $dispatchFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'Dispatch'), [string] $luisFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'LU'), @@ -15,14 +16,14 @@ Param( # Reset log file if (Test-Path $logFile) { - Clear-Content $logFile -Force | Out-Null + Clear-Content $logFile -Force | Out-Null } else { - New-Item -Path $logFile | Out-Null + New-Item -Path $logFile | Out-Null } Write-Host "> Getting config file ..." -$languageMap = @{} +$languageMap = @{ } $config = Get-Content -Raw -Path $configFile | ConvertFrom-Json $config.cognitiveModels.PSObject.Properties | Foreach-Object { $languageMap[$_.Name] = $_.Value } @@ -30,62 +31,61 @@ foreach ($langCode in $languageMap.Keys) { $models = $languageMap[$langCode] $dispatch = $models.dispatchModel - if ($RemoteToLocal) - { + if ($RemoteToLocal) { # Update local LU files based on hosted models - foreach ($luisApp in $models.languageModels) - { - $culture = (luis get application ` - --appId $luisApp.appId ` - --authoringKey $luisApp.authoringKey ` - --subscriptionKey $luisApp.subscriptionKey ` - --region $luisApp.region | ConvertFrom-Json).culture + foreach ($luisApp in $models.languageModels) { + $culture = (luis get application ` + --appId $luisApp.appId ` + --authoringKey $luisApp.authoringKey ` + --subscriptionKey $luisApp.subscriptionKey ` + --region $luisApp.authoringRegion | ConvertFrom-Json).culture Write-Host "> Updating local $($luisApp.id).lu file ..." luis export version ` --appId $luisApp.appid ` --versionId $luisApp.version ` - --region $luisApp.region ` + --region $luisApp.authoringRegion ` --authoringKey $luisApp.authoringKey | ludown refresh ` --stdin ` -n "$($luisApp.id).lu" ` -o $(Join-Path $luisFolder $langCode) - # Parse LU file - $id = $luisApp.id - $outFile = "$($id).luis" - $outFolder = $(Join-Path $luisFolder $langCode) - $appName = "$($name)$($langCode)_$($id)" + # Parse LU file + $id = $luisApp.id + $outFile = "$($id).luis" + $outFolder = $(Join-Path $luisFolder $langCode) + $appName = "$($name)$($langCode)_$($id)" - Write-Host "> Parsing $($luisApp.id) LU file ..." - ludown parse toluis ` - --in $(Join-Path $outFolder "$($luisApp.id).lu") ` - --luis_culture $culture ` - --out_folder $(Join-Path $luisFolder $langCode) ` - --out "$($luisApp.id).luis" + Write-Host "> Parsing $($luisApp.id) LU file ..." + ludown parse toluis ` + --in $(Join-Path $outFolder "$($luisApp.id).lu") ` + --luis_culture $culture ` + --out_folder $(Join-Path $luisFolder $langCode) ` + --out "$($luisApp.id).luis" - Write-Host "> Running LuisGen for $($luisApp.id) app ..." - $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + if ($useLuisGen) { + Write-Host "> Running LuisGen for $($luisApp.id) app ..." + $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + } # Add the LUIS application to the dispatch model. # If the LUIS application id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($luisApp.id) app to dispatch model ... " - (dispatch add ` - --type "luis" ` - --name $luisApp.name ` - --id $luisApp.appid ` - --region $luisApp.region ` - --intentName "l_$($luisApp.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($luisApp.id) app to dispatch model ... " + (dispatch add ` + --type "luis" ` + --name $luisApp.name ` + --id $luisApp.appid ` + --region $luisApp.authoringRegion ` + --intentName "l_$($luisApp.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } # Update local LU files based on hosted QnA KBs - foreach ($kb in $models.knowledgebases) - { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating local $($kb.id).lu file ..." qnamaker export kb ` --environment Prod ` @@ -97,56 +97,57 @@ foreach ($langCode in $languageMap.Keys) { # Add the knowledge base to the dispatch model. # If the knowledge base id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($kb.id) kb to dispatch model ..." - (dispatch add ` - --type "qna" ` - --name $kb.name ` - --id $kb.kbId ` - --key $kb.subscriptionKey ` - --intentName "q_$($kb.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($kb.id) kb to dispatch model ..." + (dispatch add ` + --type "qna" ` + --name $kb.name ` + --id $kb.kbId ` + --key $kb.subscriptionKey ` + --intentName "q_$($kb.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } } - else - { + else { # Update each luis model based on local LU files - foreach ($luisApp in $models.languageModels) { + foreach ($luisApp in $models.languageModels) { Write-Host "> Updating hosted $($luisApp.id) app..." - $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - UpdateLUIS ` - -lu_file $lu ` - -appId $luisApp.appid ` - -version $luisApp.version ` - -region $luisApp.region ` - -authoringKey $luisApp.authoringKey ` - -subscriptionKey $app.subscriptionKey - } + $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + UpdateLUIS ` + -lu_file $lu ` + -appId $luisApp.appid ` + -version $luisApp.version ` + -region $luisApp.authoringRegion ` + -authoringKey $luisApp.authoringKey ` + -subscriptionKey $app.subscriptionKey + } # Update each knowledgebase based on local LU files - foreach ($kb in $models.knowledgebases) { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating hosted $($kb.id) kb..." - $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") - UpdateKB ` - -lu_file $lu ` - -kbId $kb.kbId ` - -qnaSubscriptionKey $kb.subscriptionKey + $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") + UpdateKB ` + -lu_file $lu ` + -kbId $kb.kbId ` + -qnaSubscriptionKey $kb.subscriptionKey } - } + } - if ($dispatch) { - # Update dispatch model - Write-Host "> Updating dispatch model ..." - dispatch refresh ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null + if ($dispatch) { + # Update dispatch model + Write-Host "> Updating dispatch model ..." + dispatch refresh ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null - # Update dispatch.cs file - Write-Host "> Running LuisGen for Dispatch app..." - luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null - } + if ($useLuisGen) { + # Update dispatch.cs file + Write-Host "> Running LuisGen for Dispatch app..." + luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null + } + } } Write-Host "> Done." \ No newline at end of file diff --git a/skills/src/csharp/pointofinterestskill/pointofinterestskill/cognitivemodels.json b/skills/src/csharp/pointofinterestskill/pointofinterestskill/cognitivemodels.json index ce963e17b3..a3e3651292 100644 --- a/skills/src/csharp/pointofinterestskill/pointofinterestskill/cognitivemodels.json +++ b/skills/src/csharp/pointofinterestskill/pointofinterestskill/cognitivemodels.json @@ -7,6 +7,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" @@ -16,6 +17,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" diff --git a/skills/src/csharp/todoskill/todoskill/Deployment/Resources/parameters.template.json b/skills/src/csharp/todoskill/todoskill/Deployment/Resources/parameters.template.json index 41a2013cad..95841eb589 100644 --- a/skills/src/csharp/todoskill/todoskill/Deployment/Resources/parameters.template.json +++ b/skills/src/csharp/todoskill/todoskill/Deployment/Resources/parameters.template.json @@ -2,11 +2,23 @@ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { - "appInsightsLocation": { - "value": "westus2" + "useCosmosDb": { + "value": false }, - "luisServiceLocation": { - "value": "westus" + "useStorage": { + "value": false + }, + "appServicePlanSku": { + "value": { + "tier": "Free", + "name": "F1" + } + }, + "botServiceSku": { + "value": "F0" + }, + "luisServiceSku": { + "value": "F0" } } } \ No newline at end of file diff --git a/skills/src/csharp/todoskill/todoskill/Deployment/Resources/template.json b/skills/src/csharp/todoskill/todoskill/Deployment/Resources/template.json index 315194f7de..e1de80150d 100644 --- a/skills/src/csharp/todoskill/todoskill/Deployment/Resources/template.json +++ b/skills/src/csharp/todoskill/todoskill/Deployment/Resources/template.json @@ -10,23 +10,35 @@ "type": "string", "defaultValue": "[resourceGroup().location]" }, + "suffix": { + "type": "string", + "defaultValue": "[take(uniqueString(resourceGroup().id), 7)]" + }, "microsoftAppId": { "type": "string" }, "microsoftAppPassword": { "type": "string" }, + "useCosmosDb": { + "type": "bool", + "defaultValue": true + }, "cosmosDbName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" + }, + "useStorage": { + "type": "bool", + "defaultValue": true }, "storageAccountName": { "type": "string", - "defaultValue": "[toLower(parameters('name'))]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appServicePlanSku": { "type": "object", @@ -37,19 +49,19 @@ }, "appInsightsName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "appInsightsLocation": { "type": "string", - "defaultValue": "westus2" + "defaultValue": "[resourceGroup().location]" }, "botWebAppName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceName": { "type": "string", - "defaultValue": "[parameters('name')]" + "defaultValue": "[concat(parameters('name'), '-', parameters('suffix'))]" }, "botServiceSku": { "type": "string", @@ -57,7 +69,7 @@ }, "luisServiceName": { "type": "string", - "defaultValue": "[concat(parameters('name'), '-luis')]" + "defaultValue": "[concat(parameters('name'), '-luis-', parameters('suffix'))]" }, "luisServiceSku": { "type": "string", @@ -69,8 +81,10 @@ } }, "variables": { - "botEndpoint": "[concat('https://', toLower(parameters('botWebAppName')), '.azurewebsites.net/api/messages')]", - "cleanStorageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]" + "botWebAppName": "[replace(parameters('botWebAppName'), '_', '')]", + "storageAccountName": "[toLower(take(replace(replace(parameters('storageAccountName'), '-', ''), '_', ''), 24))]", + "cosmosDbAccountName": "[toLower(take(replace(parameters('cosmosDbName'), '_', ''), 31))]", + "botEndpoint": "[concat('https://', toLower(variables('botWebAppName')), '.azurewebsites.net/api/messages')]" }, "resources": [ { @@ -91,7 +105,7 @@ "type": "Microsoft.DocumentDB/databaseAccounts", "kind": "GlobalDocumentDB", "apiVersion": "2015-04-08", - "name": "[parameters('cosmosDbName')]", + "name": "[variables('cosmosDbAccountName')]", "location": "[parameters('location')]", "properties": { "databaseAccountOfferType": "Standard", @@ -101,18 +115,20 @@ "failoverPriority": 0 } ] - } + }, + "condition": "[parameters('useCosmosDb')]" }, { "comments": "storage account", "type": "Microsoft.Storage/storageAccounts", "kind": "StorageV2", "apiVersion": "2018-07-01", - "name": "[variables('cleanStorageAccountName')]", + "name": "[variables('storageAccountName')]", "location": "[parameters('location')]", "sku": { "name": "Standard_LRS" - } + }, + "condition": "[parameters('useStorage')]" }, { "comments": "app service plan", @@ -138,7 +154,7 @@ "comments": "bot web app", "type": "Microsoft.Web/sites", "apiVersion": "2018-02-01", - "name": "[parameters('botWebAppName')]", + "name": "[variables('botWebAppName')]", "location": "[parameters('location')]", "properties": { "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]", @@ -193,7 +209,7 @@ "outputs": { "botWebAppName": { "type": "string", - "value": "[parameters('botWebAppName')]" + "value": "[variables('botWebAppName')]" }, "ApplicationInsights": { "type": "object", @@ -204,15 +220,15 @@ "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')]", + "connectionString": "[if(parameters('useStorage'), concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '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]", + "cosmosDBEndpoint": "[if(parameters('useCosmosDb'), reference(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName'))).documentEndpoint, '')]", + "authKey": "[if(parameters('useCosmosDb'), listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('cosmosDbAccountName')), '2015-04-08').primaryMasterKey, '')]", "databaseId": "botstate-db", "collectionId": "botstate-collection" } @@ -221,8 +237,9 @@ "type": "object", "value": { "accountName": "[parameters('luisServiceName')]", + "region": "[parameters('luisServiceLocation')]", "key": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', parameters('luisServiceName')),'2017-04-18').key1]" - } + } } } } \ No newline at end of file diff --git a/skills/src/csharp/todoskill/todoskill/Deployment/Scripts/deploy.ps1 b/skills/src/csharp/todoskill/todoskill/Deployment/Scripts/deploy.ps1 index 0b79e0c717..78cbf4e5fc 100644 --- a/skills/src/csharp/todoskill/todoskill/Deployment/Scripts/deploy.ps1 +++ b/skills/src/csharp/todoskill/todoskill/Deployment/Scripts/deploy.ps1 @@ -79,7 +79,7 @@ if (-not $appId) { # Create app registration $app = (az ad app create ` --display-name $name ` - --password $appPassword ` + --password `"$($appPassword)`" ` --available-to-other-tenants ` --reply-urls 'https://token.botframework.com/.auth/web/redirect') @@ -198,7 +198,7 @@ if ($outputs) Start-Sleep -s 30 # Deploy cognitive models - 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)'" + Invoke-Expression "& '$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1')' -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -luisAccountName $($outputs.luis.value.accountName) -luisAccountRegion $($outputs.luis.value.region) -luisSubscriptionKey $($outputs.luis.value.key) -resourceGroup $($resourceGroup) -qnaSubscriptionKey '$($qnaSubscriptionKey)' -outFolder '$($projDir)' -languages '$($languages)'" # Publish bot Invoke-Expression "& '$(Join-Path $PSScriptRoot 'publish.ps1')' -name $($outputs.botWebAppName.value) -resourceGroup $($resourceGroup) -projFolder '$($projDir)'" diff --git a/skills/src/csharp/todoskill/todoskill/Deployment/Scripts/deploy_cognitive_models.ps1 b/skills/src/csharp/todoskill/todoskill/Deployment/Scripts/deploy_cognitive_models.ps1 index 22b708c23c..e3dfbfcd60 100644 --- a/skills/src/csharp/todoskill/todoskill/Deployment/Scripts/deploy_cognitive_models.ps1 +++ b/skills/src/csharp/todoskill/todoskill/Deployment/Scripts/deploy_cognitive_models.ps1 @@ -5,6 +5,7 @@ Param( [string] $luisAuthoringRegion, [string] $luisAuthoringKey, [string] $luisAccountName, + [string] $luisAccountRegion, [string] $luisSubscriptionKey, [string] $qnaSubscriptionKey, [string] $resourceGroup, @@ -86,6 +87,10 @@ if (-not $luisSubscriptionKey) { } } +if (-not $luisAccountRegion) { + $luisAccountRegion = Read-Host "? LUIS Service Location" +} + if (-not $qnaSubscriptionKey) { $useQna = $false } @@ -178,9 +183,10 @@ foreach ($language in $languageArr) name = $luisApp.name appid = $luisApp.id authoringkey = $luisAuthoringKey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey version = $luisApp.activeVersion - region = $luisAuthoringRegion + region = $luisAccountRegion } } else { @@ -279,8 +285,9 @@ foreach ($language in $languageArr) name = $dispatchApp.name appid = $dispatchApp.appId authoringkey = $luisauthoringkey + authoringRegion = $luisAuthoringRegion subscriptionkey = $luisSubscriptionKey - region = $luisAuthoringRegion + region = $luisAccountRegion } } } diff --git a/skills/src/csharp/todoskill/todoskill/Deployment/Scripts/update_cognitive_models.ps1 b/skills/src/csharp/todoskill/todoskill/Deployment/Scripts/update_cognitive_models.ps1 index e015ff3a63..827dee559a 100644 --- a/skills/src/csharp/todoskill/todoskill/Deployment/Scripts/update_cognitive_models.ps1 +++ b/skills/src/csharp/todoskill/todoskill/Deployment/Scripts/update_cognitive_models.ps1 @@ -2,6 +2,7 @@ Param( [switch] $RemoteToLocal, + [switch] $useLuisGen = $true, [string] $configFile = $(Join-Path (Get-Location) 'cognitivemodels.json'), [string] $dispatchFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'Dispatch'), [string] $luisFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'LU'), @@ -15,14 +16,14 @@ Param( # Reset log file if (Test-Path $logFile) { - Clear-Content $logFile -Force | Out-Null + Clear-Content $logFile -Force | Out-Null } else { - New-Item -Path $logFile | Out-Null + New-Item -Path $logFile | Out-Null } Write-Host "> Getting config file ..." -$languageMap = @{} +$languageMap = @{ } $config = Get-Content -Raw -Path $configFile | ConvertFrom-Json $config.cognitiveModels.PSObject.Properties | Foreach-Object { $languageMap[$_.Name] = $_.Value } @@ -30,62 +31,61 @@ foreach ($langCode in $languageMap.Keys) { $models = $languageMap[$langCode] $dispatch = $models.dispatchModel - if ($RemoteToLocal) - { + if ($RemoteToLocal) { # Update local LU files based on hosted models - foreach ($luisApp in $models.languageModels) - { - $culture = (luis get application ` - --appId $luisApp.appId ` - --authoringKey $luisApp.authoringKey ` - --subscriptionKey $luisApp.subscriptionKey ` - --region $luisApp.region | ConvertFrom-Json).culture + foreach ($luisApp in $models.languageModels) { + $culture = (luis get application ` + --appId $luisApp.appId ` + --authoringKey $luisApp.authoringKey ` + --subscriptionKey $luisApp.subscriptionKey ` + --region $luisApp.authoringRegion | ConvertFrom-Json).culture Write-Host "> Updating local $($luisApp.id).lu file ..." luis export version ` --appId $luisApp.appid ` --versionId $luisApp.version ` - --region $luisApp.region ` + --region $luisApp.authoringRegion ` --authoringKey $luisApp.authoringKey | ludown refresh ` --stdin ` -n "$($luisApp.id).lu" ` -o $(Join-Path $luisFolder $langCode) - # Parse LU file - $id = $luisApp.id - $outFile = "$($id).luis" - $outFolder = $(Join-Path $luisFolder $langCode) - $appName = "$($name)$($langCode)_$($id)" + # Parse LU file + $id = $luisApp.id + $outFile = "$($id).luis" + $outFolder = $(Join-Path $luisFolder $langCode) + $appName = "$($name)$($langCode)_$($id)" - Write-Host "> Parsing $($luisApp.id) LU file ..." - ludown parse toluis ` - --in $(Join-Path $outFolder "$($luisApp.id).lu") ` - --luis_culture $culture ` - --out_folder $(Join-Path $luisFolder $langCode) ` - --out "$($luisApp.id).luis" + Write-Host "> Parsing $($luisApp.id) LU file ..." + ludown parse toluis ` + --in $(Join-Path $outFolder "$($luisApp.id).lu") ` + --luis_culture $culture ` + --out_folder $(Join-Path $luisFolder $langCode) ` + --out "$($luisApp.id).luis" - Write-Host "> Running LuisGen for $($luisApp.id) app ..." - $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + if ($useLuisGen) { + Write-Host "> Running LuisGen for $($luisApp.id) app ..." + $luPath = $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + RunLuisGen -lu_file $(Get-Item $luPath) -outName "$($luisApp.id)" -outFolder $lgOutFolder + } # Add the LUIS application to the dispatch model. # If the LUIS application id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($luisApp.id) app to dispatch model ... " - (dispatch add ` - --type "luis" ` - --name $luisApp.name ` - --id $luisApp.appid ` - --region $luisApp.region ` - --intentName "l_$($luisApp.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($luisApp.id) app to dispatch model ... " + (dispatch add ` + --type "luis" ` + --name $luisApp.name ` + --id $luisApp.appid ` + --region $luisApp.authoringRegion ` + --intentName "l_$($luisApp.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } # Update local LU files based on hosted QnA KBs - foreach ($kb in $models.knowledgebases) - { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating local $($kb.id).lu file ..." qnamaker export kb ` --environment Prod ` @@ -97,56 +97,57 @@ foreach ($langCode in $languageMap.Keys) { # Add the knowledge base to the dispatch model. # If the knowledge base id already exists within the model no action will be taken - if ($dispatch) { - Write-Host "> Adding $($kb.id) kb to dispatch model ..." - (dispatch add ` - --type "qna" ` - --name $kb.name ` - --id $kb.kbId ` - --key $kb.subscriptionKey ` - --intentName "q_$($kb.id)" ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null - } + if ($dispatch) { + Write-Host "> Adding $($kb.id) kb to dispatch model ..." + (dispatch add ` + --type "qna" ` + --name $kb.name ` + --id $kb.kbId ` + --key $kb.subscriptionKey ` + --intentName "q_$($kb.id)" ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode)) 2>> $logFile | Out-Null + } } } - else - { + else { # Update each luis model based on local LU files - foreach ($luisApp in $models.languageModels) { + foreach ($luisApp in $models.languageModels) { Write-Host "> Updating hosted $($luisApp.id) app..." - $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") - UpdateLUIS ` - -lu_file $lu ` - -appId $luisApp.appid ` - -version $luisApp.version ` - -region $luisApp.region ` - -authoringKey $luisApp.authoringKey ` - -subscriptionKey $app.subscriptionKey - } + $lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu") + UpdateLUIS ` + -lu_file $lu ` + -appId $luisApp.appid ` + -version $luisApp.version ` + -region $luisApp.authoringRegion ` + -authoringKey $luisApp.authoringKey ` + -subscriptionKey $app.subscriptionKey + } # Update each knowledgebase based on local LU files - foreach ($kb in $models.knowledgebases) { + foreach ($kb in $models.knowledgebases) { Write-Host "> Updating hosted $($kb.id) kb..." - $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") - UpdateKB ` - -lu_file $lu ` - -kbId $kb.kbId ` - -qnaSubscriptionKey $kb.subscriptionKey + $lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu") + UpdateKB ` + -lu_file $lu ` + -kbId $kb.kbId ` + -qnaSubscriptionKey $kb.subscriptionKey } - } + } - if ($dispatch) { - # Update dispatch model - Write-Host "> Updating dispatch model ..." - dispatch refresh ` - --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` - --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null + if ($dispatch) { + # Update dispatch model + Write-Host "> Updating dispatch model ..." + dispatch refresh ` + --dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") ` + --dataFolder $(Join-Path $dispatchFolder $langCode) 2>> $logFile | Out-Null - # Update dispatch.cs file - Write-Host "> Running LuisGen for Dispatch app..." - luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null - } + if ($useLuisGen) { + # Update dispatch.cs file + Write-Host "> Running LuisGen for Dispatch app..." + luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null + } + } } Write-Host "> Done." \ No newline at end of file diff --git a/skills/src/csharp/todoskill/todoskill/cognitivemodels.json b/skills/src/csharp/todoskill/todoskill/cognitivemodels.json index 3aa3029891..cf669a812d 100644 --- a/skills/src/csharp/todoskill/todoskill/cognitivemodels.json +++ b/skills/src/csharp/todoskill/todoskill/cognitivemodels.json @@ -7,6 +7,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": "" @@ -16,6 +17,7 @@ "name": "", "appId": "", "authoringKey": "", + "authoringRegion": "", "subscriptionKey": "", "version": "", "region": ""