This site is obsolete and should be used for reference only. The information in this documentation is not guaranteed to work for Bot Framework SDK versions past 4.9.1.

Tutorial: Enable continuous deployment

Configure the pipeline to update bot services

  1. Configure the Release State environment creating variables. The highlighted ones are used for the az login command. The rest are used to fill the cognitivemodels.json file

    Release Pipeline Variables

  2. Create a PowerShell task to login your Azure account using Azure CLI
    • AzureUserName: email to access to your Azure account
    • AzurePassword: password to access to your Azure account
    • AzureTenant: present in your Azure AD or you can check the ID with az account list
       az login --user $(AzureUsername) --password $(AzurePassword) --tenant $(AzureTenant)
      
  3. Create a PowerShell task to install the Bot Framework CLI tools
     npm install -g botdispatch @microsoft/botframework-cli
    
  4. Create a PowerShell task to install BotSkills CLI tool:
     npm install -g botskills@latest
    
  5. Create an Azure PowerShell task to validate the resource group created in your Azure account
     Get-AzureRmResourceGroup -Name $(ResourceGroup) -ErrorVariable notPresent -ErrorAction SilentlyContinue
     if ($notPresent)
     {
         Write-Host "ResourceGroup $(ResourceGroup) doesn't exist"
     }
     else
     {
         Write-Host "ResourceGroup $(ResourceGroup) exists."
     }
    
  6. Create a PowerShell task to update the cognitivemodels.json file stored in the artifact.
     Set-Content -Path "$(System.DefaultWorkingDirectory)/$(Release.PrimaryArtifactSourceAlias)/drop/VATest/cognitivemodels.json" -Value '{
         "cognitiveModels": {
             "en-us": {
                 "dispatchModel": {
                     "appid": "$(AppId)",
                     "authoringkey": "$(LuisAuthoringKey)",
                     "authoringRegion": "$(AuthoringRegion)",
                     "name": "$(BotName)_Dispatch",
                     "region": "$(Region)",
                     "subscriptionkey": "$(SubscriptionKey)",
                     "type": "dispatch"
                 },
                 "languageModels": [
                     {
                         "appId": "$(AppIdLanguageModels)",
                         "authoringkey": "$(LuisAuthoringKey)",
                         "authoringRegion": "$(AuthoringRegion)",
                         "id": "General",
                         "name": "$(BotName)_General",
                         "region": "$(Region)",
                         "subscriptionkey": "$(SubscriptionKey)",
                         "version": "0.1"
                     }
                 ],
                 "knowledgebases": [
                     {
                         "endpointKey": "$(EndpointKey)",
                         "hostname": "$(Hostname)",
                         "id": "Chitchat",
                         "kbId": "$(KbIdChitchat)",
                         "name": "Chitchat",
                         "subscriptionKey": "$(SubscriptionKeyKb)"
                     },
                     {
                         "kbId": "$(KbIdFaq)",
                         "id": "Faq",
                         "subscriptionKey": "$(SubscriptionKeyKb)",
                         "hostname": "$(Hostname)",
                         "endpointKey": "$(EndpointKey)",
                         "name": "Faq"
                     }
                 ]
             }
         },
         "defaultLocale": "en-us"
     }' | ConvertFrom-Json
    
  7. Create a PowerShell task to update the bot services executing the update_cognitive_models.ps1 script
     pwsh.exe -ExecutionPolicy Bypass -File $(System.DefaultWorkingDirectory)/csharp-Virtual-Assistant-Sample/drop/VATest/Deployment/Scripts/update_cognitive_models.ps1
    

YAML Example

Check the yaml folder present in the repository.

steps:
- powershell: |
   az login --user $(AzureUsername) --password $(AzurePassword) --tenant $(AzureTenant)
   
  pwsh: true
  displayName: 'Az login '

- powershell: |
   npm install -g botdispatch @microsoft/botframework-cli
   
  pwsh: true
  displayName: Commands

- powershell: |
   npm install -g botskills@latest
   
  pwsh: true
  displayName: Commands

- task: AzurePowerShell@3
  displayName: 'Check resource group exists'
  inputs:
    azureSubscription: ManxAppPipeline
    ScriptType: InlineScript
    Inline: |
     Get-AzureRmResourceGroup -Name $(ResourceGroup) -ErrorVariable notPresent -ErrorAction SilentlyContinue
     
     if ($notPresent)
     {
         Write-Host "ResourceGroup $(ResourceGroup) doesn't exist"
     }
     else
     {
         Write-Host "ResourceGroup $(ResourceGroup) exists."
     }
    azurePowerShellVersion: LatestVersion

- powershell: |
    Set-Content -Path "$(System.DefaultWorkingDirectory)/$(Release.PrimaryArtifactSourceAlias)/drop/VATest/cognitivemodels.json" -Value '{
        "cognitiveModels": {
            "en-us": {
                "dispatchModel": {
                    "appid": "$(AppId)",
                    "authoringkey": "$(LuisAuthoringKey)",
                    "authoringRegion": "$(AuthoringRegion)",
                    "name": "$(BotName)_Dispatch",
                    "region": "$(Region)",
                    "subscriptionkey": "$(SubscriptionKey)",
                    "type": "dispatch"
                },
                "languageModels": [
                    {
                        "appId": "$(AppIdLanguageModels)",
                        "authoringkey": "$(LuisAuthoringKey)",
                        "authoringRegion": "$(AuthoringRegion)",
                        "id": "General",
                        "name": "$(BotName)_General",
                        "region": "$(Region)",
                        "subscriptionkey": "$(SubscriptionKey)",
                        "version": "0.1"
                    }
                ],
                "knowledgebases": [
                    {
                        "endpointKey": "$(EndpointKey)",
                        "hostname": "$(Hostname)",
                        "id": "Chitchat",
                        "kbId": "$(KbIdChitchat)",
                        "name": "Chitchat",
                        "subscriptionKey": "$(SubscriptionKeyKb)"
                    },
                    {
                        "kbId": "$(KbIdFaq)",
                        "id": "Faq",
                        "subscriptionKey": "$(SubscriptionKeyKb)",
                        "hostname": "$(Hostname)",
                        "endpointKey": "$(EndpointKey)",
                        "name": "Faq"
                    }
                ]
            }
        },
        "defaultLocale": "en-us"
    }' | ConvertFrom-Json
pwsh: true
workingDirectory: '$(System.DefaultWorkingDirectory)/csharp-Virtual-Assistant-Sample/drop/VATest'
displayName: 'Update cognitivemodels.json'

- powershell: 'pwsh.exe -ExecutionPolicy Bypass -File $(System.DefaultWorkingDirectory)/csharp-Virtual-Assistant-Sample/drop/VATest/Deployment/Scripts/update_cognitive_models.ps1'
pwsh: true
workingDirectory: '$(System.DefaultWorkingDirectory)/csharp-Virtual-Assistant-Sample/drop/VATest'
displayName: 'Run update cognitive models script'