Azure Bot automatic App Registration not syncing with Bot Framework directory - Error 700016

oblin denis 0 Reputation points
2025-08-16T13:38:25.3533333+00:00

I'm experiencing a persistent authentication error (AADSTS700016) with an Azure Bot created using automatic App Registration. The bot successfully receives messages but fails when attempting to send responses.

Error Details:

  • Error Code: AADSTS700016
  • Message: "Application with identifier '4d031594-d402-4ac9-8740-37e56dd45a4f' was not found in the directory 'Bot Framework'"
  • This happens when the bot tries to respond to any message

Configuration:

  • Azure Bot: bot-teams-us-prod
  • Resource Group: rg-memo (East US region)
  • Creation Method: Automatic (selected "Create new Microsoft App ID" during bot creation)
  • App Type: Single Tenant
  • Bot Framework SDK: botbuilder@4.22.1
  • Node.js: v20.18.0
  • Local testing with ngrok

What Works:

  • Bot starts successfully and listens on port 3978
  • Ngrok tunnel established and configured in Azure Bot messaging endpoint
  • Bot RECEIVES messages (200 OK in ngrok logs)
  • Message content is correctly logged in the bot

What Fails:

  • When bot tries to send response using context.sendActivity()
  • Error occurs during authentication with Bot Framework
  • Results in 502 error returned to Web Chat client

Steps to Reproduce:

  1. Create Azure Bot with automatic App Registration in East US
  2. Configure bot with generated App ID and secret in .env file
  3. Start bot locally with npm start
  4. Configure ngrok endpoint in Azure Bot
  5. Test in Web Chat - type any message
  6. Bot receives message but fails to respond with error 700016

Attempted Solutions:

  • Waited 45+ minutes for synchronization
  • Tried both SingleTenant and MultiTenant configurations
  • Recreated bot in US region (initially tried Europe)
  • Verified App ID and secret multiple times
  • Enabled Teams channel
  • Modified adapter configuration to force tenant authentication

Azure Diagnostics Result:

  • Critical insight detected: "Bot Service requests to the bot are being rejected as unauthorized, resulting in 502 errors"
  • Confirms authentication configuration issue

The core issue appears to be that the automatically created App Registration is not being recognized by the Bot Framework directory, despite being created through the official Azure Bot creation process.

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Vinodh247 37,216 Reputation points MVP Volunteer Moderator
    2025-08-16T16:13:57.8166667+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    This is a known issue with Azure Bot Service when using automatic app registration, especially in certain regions (East US is one of them). The error AADSTS700016 means that the App ID created during "automatic" registration is not propagating correctly into the Bot Framework tenant directory that the channel service uses. That explains why your bot can receive messages (the incoming webhook does not require token validation), but cannot respond (outbound requires token exchange against AAD and Bot Framework, which fails because the app is missing).

    Here is what you need to do:

    Root Cause

    • When you select "Create new Microsoft App ID" during azure bot creation, the portal automatically provisions an App Registration in your tenant.
    • In some cases, that app registration is not properly synced to the Bot Framework service directory (a separate multitenant directory used by Bot Service).
    • As a result, outbound calls from your bot to the channel service fail with AADSTS700016: Application not found.

    Workaround:

    1. Manually create an App Registration in AAD:
      • Go to Azure Active Directory > App registrations > New registration.
      • Give it a name (ex: bot-teams-us-prod-manual).
      • Supported account types: Single tenant (or Multitenant if you plan crosstenant usage).
      • Redirect URI: leave blank (not needed for bots).
      • Register the app.
    2. Generate a client secret:
      • In the App Reg, go to Certificates & Secrets > New client secret.
      • Copy the secret value.
    3. Update the Bot Channel Registration:
      • Go to your Azure Bot resource (bot-teams-us-prod).
      • Under Configuration > Microsoft App ID and password, replace the auto gen App ID with your manually created App ID.
      • Paste the client secret.
    4. Update your local bot code:
      • In .env, update & restart the bot

        MicrosoftAppId=<your-manual-app-id> MicrosoftAppPassword=<your-client-secret>

    Please 'Upvote'(Thumbs-up) and 'Accept' as answer if the reply was helpful. This will be benefitting other community members who face the same issue.


  2. Sina Salam 24,096 Reputation points Volunteer Moderator
    2025-08-16T16:15:12.34+00:00

    Hello oblin denis,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that your Azure Bot error means that the bot's App Registration is not properly recognized by the Bot Framework directory. Try to do the followings:

    1. Verify App Registration and confirm the App ID matches the one in your .env file, and make sure the app is listed and not deleted or expired.
    2. Set Correct Tenant Authority in your bot’s .env file or adapter config, set:
          MICROSOFT_APP_TYPE=SingleTenant
           MICROSOFT_APP_ID=<Your App ID>
           MICROSOFT_APP_PASSWORD=<Your Secret>
           MICROSOFT_APP_TENANT_ID=<Your Tenant ID>
           MICROSOFT_APP_CHANNEL_SERVICE=https://smba.trafficmanager.net/amer/
      
      • In code (Node.js):
         const credentials = new MicrosoftAppCredentials(appId, appPassword, tenantId);
           adapter.credentials = credentials;
      
      This ensures the bot authenticates against your tenant.
    3. Check Redirect URIs to ensure the following URI is present: https://token.botframework.com/.auth/web/redirect This is required for Bot Framework authentication.
    4. Review API Permissions by adding:
      • Bot Framework delegated permissions
      • Microsoft Graph if needed and "Grant admin consent"
    5. Recreate Bot Registration (if needed) and especially, if the app still isn’t recognized:
    6. Use Bot Framework Emulator with App ID and password to test token acquisition and ngrok, and Web Chat to confirm outbound messages work.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.


  3. Abhilash Hota 5 Reputation points
    2025-08-20T03:35:34.44+00:00

    I recreated the app id and it worked for a day. Then it stopped working again.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.