Tutorial: Enable continuous deployment

Configure the pipeline to update bot services

  1. First add variables that will be used to connect your project to the bot resources. In the sample screenshot, the highlighted variables are from the az login command and the others are used to fill cognitivemodels.json In order. Configure Release Pipeline 1

  2. Create a Powershell task that logs into your Azure account using the Azure CLI.
    az login --user $(botUsername) --password $(botPassword) --tenant $(botTenant)
    

    Configure Release Pipeline 2

  3. Create a Powershell task that installs the required dependencies to update bot services.
    npm install -g botdispatch ludown luis-apis qnamaker luisgen@2.0.2
    

    Configure Release Pipeline 3

  4. Create an Azure Powershell task that checks if the resource group exists before running the next command.
    Get-AzureRmResourceGroup -Name $(ResourceGroup) -ErrorVariable notPresent -ErrorAction SilentlyContinue
    if ($notPresent)
    {
     Write-Host "ResourceGroup $(ResourceGroup) doesn't exist"
    }
    else
    {
     Write-Host "ResourceGroup $(ResourceGroup) exists."
    }
    

    Configure Release Pipeline 4

  5. To avoid uploading sensitive keys into the logs, use variable groups to fill in the Update cognitive models task. This replaces the configuration of the cognitivemodels.json stored in teh artifact configuration. VATest is the example name of the folder that the artifact is located.
    Set-Content -Path "$(System.DefaultWorkingDirectory)/$(Release.PrimaryArtifactSourceAlias)/drop/VATest/cognitivemodels.json" -Value '{
     "cognitiveModels": {
     "en": {
         "dispatchModel": {
         "subscriptionkey": "$(SubscriptionKey)",
         "type": "dispatch",
         "region": "$(Region)",
         "authoringRegion": "$(AuthoringRegion)",
         "appid": "$(AppId)",
         "authoringkey": "$(LuisAuthoringKey)",
         "name": "$(BotName)_Dispatch"
         },
         "languageModels": [
         {
             "region": "$(Region)",
             "id": "General",
             "name": "$(botName)_General",
             "authoringRegion": "$(AuthoringRegion)",
             "authoringkey": "$(LuisAuthoringKey)",
             "appid": "$(AppIdLanguageModels)",
             "subscriptionkey": "$(SubscriptionKey)",
             "version": "0.1"
         }
         ],
         "knowledgebases": [
         {
             "kbId": "$(KbIdChitchat)",
             "id": "Chitchat",
             "subscriptionKey": "$(SubscriptionKeyKb)",
             "hostname": "$(hostname)",
             "endpointKey": "$(endpointKey)",
             "name": "Chitchat"
         },
         {
             "kbId": "$(KbIdFaq)",
             "id": "Faq",
             "subscriptionKey": "$(SubscriptionKeyKb)",
             "hostname": "$(hostname)",
             "endpointKey": "$(endpointKey)",
             "name": "Faq"
         }
         ]
     }
     },
     "defaultLocale": "en-us"
    }' | ConvertFrom-Json
    

    Configure Release Pipeline 5

  6. Finally, the Run update cognitive models script task runs the following script to update the Bot Services
    pwsh.exe -ExecutionPolicy Bypass -File $(System.DefaultWorkingDirectory)/csharp-Virtual-Assistant-Sample/drop/VATest/Deployment/Scripts/update_cognitive_models.ps1
    

    Configure Release Pipeline 6