Azure Health Bot CI

I have been getting a lot of exposure to Azure Health Bot services in my current role at Microsoft and have even been fortunate enough to help a tiny bit with the implementation during the initial days of the COVID-19 response. The Health Bot services are a SaaS offering in the Azure Cloud which gives teams a ton of flexibility internally, but generally lack easy CI/CD for configurations. I recently created a new azure-healthbot-ci (repo) package to help with pulling and updating configurations between instances so you can stage changes in one environment and public it to production using Azure DevOps or Github Actions.

Here's an Azure Pipelines yaml configuration for storing configurations as artifacts before deploying the configuration artifact to a different instance.

# Transfer one scenario and bot configurations to a new instance.

# Variables:
#  $(scenarioName)
#  $(tenantName1) 
#  $(jwtSecret1)
#  $(tenantName2)
#  $(jwtSecret2)

trigger:
  none

stages:
- stage: Snapshot
  displayName: Snapshot Configuration

  jobs:
  - job: Snapshot
    displayName: Snapshot
    pool:
      vmImage: 'ubuntu-latest'

    steps:
    - task: NodeTool@0
      inputs:
        versionSpec: '12.x'
      displayName: 'Install Node.js'

    - script: |
        npm install azure-healthbot-ci -g
      displayName: 'azure-healthbot-ci install'

    - script: |
        mkdir $(Agent.BuildDirectory)/snapshots
        azure-healthbot-ci get_medical $(tenantName1) $(jwtSecret1) $(Agent.BuildDirectory)/snapshots/medical.json
        azure-healthbot-ci get_privacy $(tenantName1) $(jwtSecret1) $(Agent.BuildDirectory)/snapshots/privacy.json
        azure-healthbot-ci get_interactions $(tenantName1) $(jwtSecret1) $(Agent.BuildDirectory)/snapshots/interactions.json
        azure-healthbot-ci get_scenario $(tenantName1) $(jwtSecret1) $(scenarioName) $(Agent.BuildDirectory)/snapshots/scenario.json
      displayName: 'Snapshot configurations'

    - task: ArchiveFiles@2
      inputs:
        rootFolderOrFile: '$(Agent.BuildDirectory)/snapshots/'
        includeRootFolder: false
        archiveType: 'zip'
        archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
        replaceExistingArchive: true
        verbose: true

    - publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
      artifact: drop

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Snapshot
  condition: succeeded()

  jobs:
  - deployment: Deploy
    displayName: Deploy
    environment: 'development'
    pool:
      vmImage: 'ubuntu-latest'

    strategy:
      runOnce:
        deploy:
          steps:
          - task: ExtractFiles@1
            inputs:
              archiveFilePatterns: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
              destinationFolder: '$(System.DefaultWorkingDirectory)/$(Build.BuildId)/dist'
              cleanDestinationFolder: true
          - script: |
              azure-healthbot-ci post_medical $(tenantName2) $(jwtSecret2) $(Agent.BuildDirectory)/dist/medical.json
              azure-healthbot-ci post_privacy $(tenantName2) $(jwtSecret2) $(Agent.BuildDirectory)/dist/privacy.json
              azure-healthbot-ci post_interactions $(tenantName2) $(jwtSecret2) $(Agent.BuildDirectory)/dist/interactions.json
              azure-healthbot-ci post_scenario $(tenantName2) $(jwtSecret2) $(scenarioName) $(Agent.BuildDirectory)/dist/scenario.json
            displayName: 'Update configurations'