Bot Service returns 500 to all channel requests because it calls my bot endpoint with an access token that has no appid claim.

Catalin George Paraschivescu 0 Reputation points
2025-11-20T00:13:59.84+00:00

Issue: Bot Service returns 500 to all channel requests because it calls my bot endpoint with an access token that has no appid claim.

Environment:

  • Bot resource: Bot-snow1 (subscription ***-7c13-4a0b-b646-071ed243f318, region West Europe)
  • App registration: SNow Bot
    • App ID: f3026662-478d-454a-85b9-****
      • Tenant: 75522955-8b41-4784-b9ed-***
      • Client secret: regenerated on 19 Nov 2025 (value begins zt48…)

Symptoms:

  • Diagnostic logs show StartConversationClientToDirectLine, etc., but there are no PostActivityToBotEndpoint entries with a valid BotAppId.
  • Our bot logs show every POST from Bot Service failing with Unauthorized (token app_id=None, aud=f3026662-478d-454a-85b9-4d5911d57969).

Steps already taken:

  1. Regenerated the client secret via Bot-snow1 → Configuration → Manage password, updated Kubernetes secrets with the same value.
  2. Redeployed bot image, confirmed environment variables inside the pod match the new secret.
  3. Enabled diagnostic logs to Log Analytics; they confirm Bot Service is not sending the appid claim.

Request: Please investigate why Bot Service is issuing tokens to Https://<message endpoint> an appid, even though the resource is configured with the new app ID/secret. We need guidance or a fix so Bot Service sends a proper signed token with appid=***-478d-454a-85b9-4d5911d57969.

Issue: Bot Service returns 500 to all channel requests because it calls my bot endpoint with an access token that has no appid claim.

Environment:

  • Bot resource: Bot-snow1 (subscription ***-7c13-4a0b-b646-071ed243f318, region West Europe)
  • App registration: SNow Bot
    • App ID: **-478d-454a-85b9-4d5911d57969
      • Tenant: **-8b41-4784-b9ed-51ffc20599bf
      • Client secret: regenerated on 19 Nov 2025 (value begins zt48…)

Symptoms:

  • Diagnostic logs show StartConversationClientToDirectLine, etc., but there are no PostActivityToBotEndpoint entries with a valid BotAppId.
  • Our bot logs show every POST from Bot Service failing with Unauthorized (token app_id=None, aud=f3026662-478d-454a-85b9-4d5911d57969).

Steps already taken:

  1. Regenerated the client secret via Bot-snow1 → Configuration → Manage password, updated Kubernetes secrets with the same value.
  2. Redeployed bot image, confirmed environment variables inside the pod match the new secret.
  3. Enabled diagnostic logs to Log Analytics; they confirm Bot Service is not sending the appid claim.

Why Bot Service is issuing tokens to https://<messages endpoint> without an appid, even though the resource is configured with the new app ID/secret. I need guidance or a fix so Bot Service sends a proper signed token with appid=f3026662-478d-454a-85b9-XXXX

Log:

2025-11-19 23:37:05,318 - src.echo_main - ERROR - Echo bot error: Unauthorized (token app_id=None, aud=f3026662-478d-454a-85b9-XXXX)

INFO: 10.0.1.**:41026 - "POST /api/messages HTTP/1.1" 500 Internal Server Error

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

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2025-11-20T00:14:18.5066667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The issue you're experiencing, where the Bot Service returns a 500 error due to an access token that lacks the appid claim, can be attributed to several potential causes. Here are some steps and considerations to help troubleshoot and resolve the problem:

    1. Check App Registration: Ensure that the app registration in Azure for your bot is correctly configured with the appropriate permissions and that the MicrosoftAppId and MicrosoftAppPassword are correctly set in your bot's configuration files (e.g., appsettings.json, .env, or config.py). The appid claim in the token should match the MicrosoftAppId.
    2. Token Acquisition: Verify that the token being issued by the Bot Service is being generated correctly. The absence of the appid claim suggests that there may be an issue with how the token is being requested or generated. Ensure that the Bot Framework SDK is properly set up to request the token with the correct parameters.
    3. Redeploy and Validate: Since you've already regenerated the client secret and redeployed the bot, ensure that the deployment process correctly includes all necessary configuration files and environment variables. Double-check that the bot is running the latest version of the code with the updated credentials.
    4. Enable Application Insights: If you haven't already, enable Application Insights for your bot. This can provide more detailed logs and telemetry data that may help identify where the failure is occurring in the token acquisition process.
    5. Check for Configuration Errors: Review the configuration settings in the Azure portal for your bot service. Ensure that there are no typos or misconfigurations that could lead to the Bot Service not sending the correct token.
    6. Consult Documentation: Refer to the official Microsoft documentation for troubleshooting authentication issues with the Bot Framework. This may provide additional insights or steps specific to your situation.

    If these steps do not resolve the issue, consider reaching out to Microsoft support for further assistance, as they can provide more in-depth analysis based on your specific configuration and logs.


    References:

    0 comments No comments

  2. Manas Mohanty 13,340 Reputation points Moderator
    2025-11-26T06:30:12.8466667+00:00

    Hi Catalin George Paraschivescu

    Sorry for the delay in response. I have tried to analyze above error trace and symptoms.

    Here is analysis and recommendation.

    Issue Summary

    Your bot (Azure Bot Service + Direct Line) returns HTTP 500 for all channel requests. Diagnostic logs show entries like StartConversationClientToDirectLine, but no PostActivityToBotEndpoint with a valid BotAppId.\ Bot logs confirm every POST from Bot Service fails with 401 Unauthorized because the incoming token has:

    app_id=None
    aud=f3026662-478d-454a-85b9-4d5911d57969
    

    The resource is configured with the correct App ID and secret, yet Bot Service calls our endpoint with a token missing the appid claim.

    Root Cause

    • Bot Service issues v2 tokens, which do not include appid.
    • In v2 tokens:
      • Caller App ID is in the azp (Authorized Party) claim.
        • Audience (aud) equals your bot’s App ID (GUID).
        • If your bot’s validation logic expects appid and ignores azp, it will reject all requests.

    This is by design: Microsoft identity guidance says not to hard-depend on specific claims. V2 tokens legitimately omit appid.

    Resolution

    Update your bot’s token validation to support v2 tokens:

    If using Bot Framework SDK

    • Use the built-in authentication (BotFrameworkHttpAdapter / BotFrameworkAuthentication).
    • Upgrade to the latest SDK packages (Microsoft.Bot.Connector.Authentication, Microsoft.Bot.Builder).
    • The SDK automatically checks azp for v2 and appid for v1.

    If using custom JWT validation

    • Validate:
      • Signature & issuer against Bot Framework OpenID metadata.
      • Audience (aud) matches your bot’s App ID.
    • For caller App ID:
      • Read azp first; fall back to appid if present.
    • Do not fail because appid is missing.

    Example (.NET):

    string callerAppId = JwtTokenValidation.GetAppIdFromClaims(claims);
    string audience = claims.FirstOrDefault(c => c.Type == "aud")?.Value;
    if (audience != Environment.GetEnvironmentVariable("MicrosoftAppId"))
    {
        throw new UnauthorizedAccessException("Invalid audience for bot endpoint.");
    }
    

    Checklist

    1. Confirm your bot uses the correct App ID and secret in environment variables.
    2. Decode an incoming token (jwt.ms) → expect ver=2.0, aud=<your bot App ID>, azp=<caller App ID>.
    3. Switch to SDK defaults or update custom validation logic.

    Why not Force Appid?

    Bot Service aligns with Microsoft Entra v2 standards. azp replaces appid in v2 tokens. Forcing appid would break modern token flows.

    References

    Hope it helps address the issue.

    Thank you.



    0 comments No comments

Your answer

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