OfficeDev / teams-toolkit

Developer tools for building Teams apps
Other
433 stars 170 forks source link

Unable to create the bot through `teamsapp provision` #11906

Open tbhaxor opened 3 days ago

tbhaxor commented 3 days ago

Describe the bug

I have configured the teams app and entra id application from the azure portal and using teamsapp cli to create the bot from the information.

To Reproduce Steps to reproduce the behavior:

  1. Scaffold the application teamsapp new -c bot -n bot-app -i false

  2. Configure the env/.env.local

    # This file includes environment variables that can be committed to git. It's gitignored by default because it represents your local development environment.
    
    # Built-in environment variables
    TEAMSFX_ENV=local
    APP_NAME_SUFFIX=local
    
    # Generated during provision, you can also add your own variables.
    TEAMS_APP_ID=<REDACTED>
    BOT_DOMAIN=127.0.0.1:3978
    BOT_ENDPOINT=https://127.0.0.1:3978
    MS_ENTRA_ID_CLIENT_ID=<REDACTED>
    MS_ENTRA_ID_CLIENT_SECRET=<REDACTED>

    Note — Our project demands ignoring env file, so putting secrets directory here would work.

  3. Update the teamsapp.local.yaml

    
    version: v1.5
    provision:
    - uses: devTool/install
    with:
      devCert:
        trust: true
    writeToEnvironmentFile:
      sslCertFile: SSL_CRT_FILE
      sslKeyFile: SSL_KEY_FILE
    
    # Create or update the bot registration on dev.botframework.com
    - uses: botFramework/create
    with:
      botId: ${{MS_ENTRA_ID_CLIENT_ID}}
      name: ms-bot
      messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages
      description: ""
      channels:
        - name: msteams

deploy:

Build Teams app package with latest env value

5. Run the provision command `teamsapp provision --env local`

Error

Executing provision

Lifecycle stage: provision(2 step(s) in total). The following actions will be executed: (1/2) Action devTool/install: installing dependencies (2/2) Action botFramework/create: creates or updates the bot registration on dev.botframework.com

Executing lifecycle provision Skip trusting development certificate for localhost. (✖) Error: Unable to execute action botFramework/create. Error message: Unable to make API call to Developer Portal. Check Output panel for details. (✖) Error: Failed to Execute lifecycle provision due to failed action: botFramework/create. DeveloperPortalAPIFailedError:Unable to make API call to Developer Portal: AxiosError, Request failed with status code 400, API name: create-bot, X-Correlation-ID: bf9b2565-3558-46f1-9143-0fee82b1fcd5. This may be due to a temporary service error. Try again after a few minutes. data: "The bot name is already registered to another bot application.". Env output: {"SSL_CRT_FILE":"/home/tbhaxor/.fx/certificate/localhost.crt","SSL_KEY_FILE":"/home/tbhaxor/.fx/certificate/localhost.key"} Execution summary:

Summary: (×) Error: Lifecycle stage provision failed. (√) Done: devTool/install was executed successfully. (√) Done: Skip trusting development certificate for localhost. (×) Error: botFramework/create failed. (×) Error: Unable to make API call to Developer Portal: AxiosError, Request failed with status code 400, API name: create-bot, X-Correlation-ID: bf9b2565-3558-46f1-9143-0fee82b1fcd5. This may be due to a temporary service error. Try again after a few minutes. data: "The bot name is already registered to another bot application."

███████████████████▒ 96% | [2/2] Provision: Creating or updating bot registration. (✖) Failed. (✖) Error: AppStudioPlugin.DeveloperPortalAPIFailedError: Unable to make API call to Developer Portal: AxiosError, Request failed with status code 400, API name: create-bot, X-Correlation-ID: bf9b2565-3558-46f1-9143-0fee82b1fcd5. This may be due to a temporary service error. Try again after a few minutes. data: "The bot name is already registered to another bot application."



> Note: AFAIK, This is the first time I am creating bot with the registered entra id application. Please help me debug it.

**Expected behavior**

It should not partially fails. It is creating bot but then failing later.

**VS Code Extension Information (please complete the following information):**
 - OS: [e.g. iOS]: Windows
 - Version [e.g. 22]: 11

**CLI Information (please complete the following information):**
 - OS: [e.g. iOS8.1]: Windows
 - Version [e.g. 22]: 3.0.2

**Additional context**

I have tried the following
1. Delete the bot from the dev.botframework.com and then retry
2. Delete all the resources (entra id app, teams app, bot from dev.botframework.com), ask the admin to re-issue me entra id app (id + secret) and teams app id. Then re-config and run the command. 

In all these case I am getting same error.
microsoft-github-policy-service[bot] commented 3 days ago

Thank you for contacting us! Any issue or feedback from you is quite important to us. We will do our best to fully respond to your issue as soon as possible. Sometimes additional investigations may be needed, we will usually get back to you within 2 days by adding comments to this issue. Please stay tuned.

xiaolang124 commented 3 days ago

Hi, based on the error message, you need to use another bot name, or you have to delete the existing bot with the same name from https://dev.botframework.com/, to avoid duplicate. (Not all bots will be shown in here, and it requires manually deletion by calling graph API) The bot name is already registered to another bot application.

To use another bot name, you can find botFramework/create action from teamsapp.local.yml, update the name and try local debug again. Thanks! image

tbhaxor commented 2 days ago

Does the name need to be globally unique, because I was getting error even from the fresh start (deleting all bots).

I will try again with different account to validate it.