azuremicrosoft-teamsteams-toolkit

Using Bicep to enable the calling functions of MSTeams channel in Azure Bot Services


I have a Microsoft Teams bot App, and I plan to use Teams Toolkit CLI v3 for provision Azure Resource, one is callingbot support for the Teams app. I try to implement the function by bicep.

There are my azurebot.bicep and azurebot.parameters.json

The azurebot.bicep file


@maxLength(32)
@minLength(4)
@description('Used to generate names for all resources in this file')
param resourceBaseName string

@maxLength(42)
param botDisplayName string

param botServiceName string = resourceBaseName
param botServiceSku string
param botAadAppClientId string
param botAppDomain string

// Register your web service as a bot with the Bot Framework
resource botService 'Microsoft.BotService/botServices@2022-09-15' = {
  kind: 'azurebot'
  location: 'global'
  name: botServiceName
  properties: {
    displayName: botDisplayName
    endpoint: 'https://${botAppDomain}/api/messages'
    msaAppId: botAadAppClientId
  }
  sku: {
    name: botServiceSku
  }
}

// Connect the bot service to Microsoft Teams
resource botServiceMsTeamsChannel 'Microsoft.BotService/botServices/channels@2022-09-15' = {
  parent: botService
  location: 'global'
  name: 'MsTeamsChannel'
  properties: {
    channelName: 'MsTeamsChannel'
    isEnabled: true
    acceptedTerms: true
    enableCalling: true
    callingWebhook: 'https://${botAppDomain}/api/callback'
    deploymentEnvironment: 'CommercialDeployment'
  }
}

The azurebot.parameters.json


{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "resourceBaseName": {
        "value": "My_BotService_${{RESOURCE_SUFFIX}}"
      },
      "botServiceSku": {
        "value": "${{BOT_SERVICE_SKU}}"
      },
      "botDisplayName": {
        "value": "My bot for MSTeams"
      },
      "botAadAppClientId": {
        "value": "${{BOT_ID}}"
      },
      "botAppDomain": {
        "value": "${{BOT_DOMAIN}}"
      }
    }
}

the Calling page of Azure Resource

Teams Toolkit CLI runs success, but the Calling function cannot be configured as script. I also try the 2023-09-15-preview version, it is still failed to configure Calling.

I can't fix it and understand what I'm doing wrong.


Solution

  • As Microsoft docs, resource format is defined as

    resource symbolicname 'Microsoft.BotService/botServices/channels@2022-09-15' = {
      parent: resourceSymbolicName
      etag: 'string'
      kind: 'string'
      location: 'string'
      name: 'string'
      properties: {
        etag: 'string'
        location: 'string'
        channelName: 'string'
        // For remaining properties, see Channel objects
      }
      sku: {
        name: 'string'
      }
      tags: {
        {customized property}: 'string'
      }
    }
    

    and MSTeamsChannel is defined as

    {
      channelName: 'MsTeamsChannel'
      properties: {
        acceptedTerms: bool
        callingWebhook: 'string'
        deploymentEnvironment: 'string'
        enableCalling: bool
        incomingCallRoute: 'string'
        isEnabled: bool
      }
    }
    

    It cannot be added any key-value pair into properties after name: 'MsTeamsChannel' directly, we should re-defined the children node named properties after channelName: 'MsTeamsChannel', it is means we need define the properties for MsTeamsChannel for channel only.

    It's confusing and I made this mistake, so fixed by below:

    // Connect the bot service to Microsoft Teams
    resource botServiceMsTeamsChannel 'Microsoft.BotService/botServices/channels@2022-09-15' = {
      parent: botService
      location: 'global'
      name: 'MsTeamsChannel'
      properties: {
        channelName: 'MsTeamsChannel'
        properties: {
          acceptedTerms: true
          callingWebhook: 'https://${botAppDomain}/api/callback'
          deploymentEnvironment: 'CommercialDeployment'
          enableCalling: true
    //      incomingCallRoute: 'https://${botAppDomain}/api/callback'
          isEnabled: true
        }
      }
    }