Forum Discussion

arie_schwartzman's avatar
arie_schwartzman
Brass Contributor
Dec 21, 2022

Automate Health Bot Deployment using Bicep

Health Bot Azure resource provider now supports retrieval of secrets using the ARM API.

This will allow the automated deployment of Health Bot and any other resources that rely on the https://learn.microsoft.com/en-us/azure/health-bot/keys.

 

In this example, we show how to deploy Health Bot and a Web Application that uses the https://github.com/microsoft/HealthBotContainerSample, wire up the secrets the app needs to communicate with the bot and even upload bot template that resides on a publicly accessible storage account via the https://learn.microsoft.com/en-us/azure/health-bot/integrations/managementapi using a PowerShell deployment script.

 

For the complete https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/overview?tabs=bicep code and the restoreBot.ps1 file, see the attached bicep.zip file.

param serviceName string
param linuxFxVersion string = 'node|14-lts'
param farmSKU string = 'F1'
param botSKU string = 'F0'
param location string = 'eastus'
param hbsRestoreFile string = 'https://xxxxxxxxx.blob.core.windows.net/templates/botTemplate.hbs'

resource healthbot 'Microsoft.HealthBot/healthBots@2022-08-08' = {
  name: '${serviceName}-bot'
  location: location
  properties: {
    keyVaultProperties: {
      keyName: 'string'
      keyVaultUri: 'string'
      keyVersion: 'string'
      userIdentity: 'string'
    }
  }
  sku: {
    name: botSKU
  }
}

resource farm 'Microsoft.Web/serverfarms@2022-03-01' = {
  location: location
  name: '${serviceName}-farm'
  kind: 'linux'
  sku: {
    name: farmSKU
  }
  properties: {
    reserved: true
  }
}

resource webapp 'Microsoft.Web/sites@2022-03-01' = {
  name: '${serviceName}-webapp'
  location: location
  properties: {
    serverFarmId: farm.id
    siteConfig: {
      linuxFxVersion: linuxFxVersion
      appSettings: [
        {
          name: 'PORT'
          value: '80'
        }
        {
          name: 'APP_SECRET'
          value: healthbot.listSecrets().secrets[0].value
        }
        {
          name: 'WEBCHAT_SECRET'
          value: healthbot.listSecrets().secrets[1].value
        }
      ]
    }
  }
}

resource srcControls 'Microsoft.Web/sites/sourcecontrols@2021-01-01' = {
  name: '${webapp.name}/web'
  properties: {
    repoUrl: 'https://github.com/microsoft/HealthBotContainerSample'
    branch: 'master'
    isManualIntegration: true
  }
}

resource importBotScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
  name: '${serviceName}-RestoreBotScript'
  location: location
  kind: 'AzurePowerShell'
  properties: {
    azPowerShellVersion: '3.0'
    scriptContent: loadTextContent('restoreBot.ps1')
    retentionInterval: 'P1D'
    arguments: '-secret ${healthbot.listSecrets().secrets[2].value} -baseUrl ${healthbot.properties.botManagementPortalLink} -hbsRestoreFile ${hbsRestoreFile}'
  }
}

 

 

 

 

 

No RepliesBe the first to reply

Resources