如何将OUATH连接设置添加到BotFramework中的机器人?

huangapple go评论69阅读模式
英文:

How can we add OUATH Connection Settings to Bots in the BotFramework?

问题

使用TeamsFX构建Microsoft Teams的机器人时,机器人(在开发过程中)在BotFramework内创建,并可以在此处进行管理:https://dev.botframework.com/bots

这些机器人不与任何我的Azure订阅相关联,似乎存在于我的租户之外,但我可以查看它们。

为了启用BOT SSO,我需要将OAUTH凭据添加到机器人中。

如果机器人在Azure门户(Azure Bot Service)中,可以按照以下方式操作:
如何将OUATH连接设置添加到BotFramework中的机器人?

然而,该机器人不在Azure门户中,它只存在于这里

我如何为机器人添加OUATH凭据?

英文:

When using TeamsFX to build bots for Microsoft Teams, bots (during development) are provisioned inside the BotFramework and can be managed here: https://dev.botframework.com/bots

These bots are not tied to any (of my) Azure subscriptions and seem to exist outside my tenant, but they are viewable by me.

In order to enable BOT SSO, I need to add OAUTH credentials to the Bot.

If the bot were in the Azure Portal (Azure Bot Service), it is doable as follows:
如何将OUATH连接设置添加到BotFramework中的机器人?

However the Bot is not in the Azure Portal - it only exists here.

How can I add OUATH credentials to the bot?

答案1

得分: 1

以下是已翻译的内容:

有2种启用BOT SSO的方法:

  1. 使用@microsoft/teamsfx包中的TeamsBotSsoPrompt提示。这将配置OAUTH凭据到您的应用程序的应用程序设置,而不是Azure Bot服务,因此您可以在没有Azure订阅的情况下测试您的机器人。您可以参考文档示例来实施它。

  2. 按照您所引用的文档来启用BOT SSO。您需要执行以下手动步骤来创建Azure Bot,以便配置您的OAUTH凭据。成功使用新配置本地调试项目后,您应该能够在您的订阅中找到Azure Bot资源。这些步骤假定您使用VS Code Teams Toolkit V5来创建一个新的机器人项目。请根据需要更新路径和参数值。

    1. 在https://dev.botframework.com/bots上删除您的现有机器人。

    2. infra/botRegistration/azurebot.parameters.json中创建一个新文件,内容如下:

      {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
          "resourceBaseName": {
            "value": "bot${{RESOURCE_SUFFIX}}"
          },
          "botAadAppClientId": {
            "value": "${{BOT_ID}}"
          },
          "botAppDomain": {
            "value": "${{BOT_DOMAIN}}"
          },
          "botDisplayName": {
            "value": "bot-sso"
          }
        }
      }
      
    3. 用新的内容替换teamsapp.local.yml中的原始片段:

      原始片段:

      - uses: botFramework/create
        with:
          botId: ${{BOT_ID}}
          name: sso-bot
          messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages
          description: ""
          channels:
            - name: msteams
      

      新片段:

      - uses: arm/deploy # 并行部署给定的ARM模板。
        with:
          subscriptionId: ${{AZURE_SUBSCRIPTION_ID}}
          resourceGroupName: ${{AZURE_RESOURCE_GROUP_NAME}}
          templates:
            - path: ./infra/botRegistration/azurebot.bicep
              parameters: ./infra/botRegistration/azurebot.parameters.json
              deploymentName: Create-resources-for-bot
          bicepCliVersion: v0.9.1
      
英文:

There're 2 ways to enable BOT SSO:

  1. Using the TeamsBotSsoPrompt prompt in @microsoft/teamsfx package. This configures the OAUTH credentials to your app's app settings instead of the Azure Bot service, so you can test your bot without an Azure subscription. You can refer the document and the sample to implement it.

  2. Follow the document you're referring to enable BOT SSO. You need to take following manual steps to create an Azure Bot so you can configure your OAUTH credentials. After you successfully local debug your project with the new configuration, you should be able to find the Azure Bot resource in your subscription. The steps assume you use VS Code Teams Toolkit V5 to create a new bot project. Please update the paths and parameter values as needed.

    1. Delete your existing bot at https://dev.botframework.com/bots

    2. Create a new file at infra/botRegistration/azurebot.parameters.json with following content:

      {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
          "resourceBaseName": {
            "value": "bot${{RESOURCE_SUFFIX}}"
          },
          "botAadAppClientId": {
            "value": "${{BOT_ID}}"
          },
          "botAppDomain": {
            "value": "${{BOT_DOMAIN}}"
          },
          "botDisplayName": {
            "value": "bot-sso"
          }
        }
      }
      
    3. Replace the original snippet in teamsapp.local.yml with the new one:

      Original snippet:

      - uses: botFramework/create
        with:
          botId: ${{BOT_ID}}
          name: sso-bot
          messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages
          description: ""
          channels:
            - name: msteams
      

      New snippet:

      - uses: arm/deploy # Deploy given ARM templates parallelly.
        with:
          subscriptionId: ${{AZURE_SUBSCRIPTION_ID}}
          resourceGroupName: ${{AZURE_RESOURCE_GROUP_NAME}}
          templates:
            - path: ./infra/botRegistration/azurebot.bicep
              parameters: ./infra/botRegistration/azurebot.parameters.json
              deploymentName: Create-resources-for-bot
          bicepCliVersion: v0.9.1
      

huangapple
  • 本文由 发表于 2023年6月8日 10:05:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76428140.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定