How do I get a Bot Service's DirectLine Key with a bicep?
I have a bicep that creates the bot service and then creates the app service. I need to add the direct line key as an app setting value in the app service. I can't find a way to get the key from the bot resource in my bicep.
I saw some posts that indicate that I might be able to get the key with the CLI or with an http call, but that seems convoluted when I'm building everything with a bicep. I am probably overlooking something simple?
You can retrieve the key using the listChannelWithKeys()
function:
param botServiceName string
// reference to bot service
resource botService 'Microsoft.BotService/botServices@2023-09-15-preview' existing = {
name: botServiceName
}
// reference to bot service channel
resource directLineChannel 'Microsoft.BotService/botServices/channels@2023-09-15-preview' existing = {
parent: botService
name: 'DirectLineChannel'
}
// DO NOT USE OUTPUT in real world
output directLine object = directLineChannel.listChannelWithKeys()