Forum Discussion

ShwetaI's avatar
ShwetaI
Icon for Microsoft rankMicrosoft
Dec 27, 2025
Solved

Unable to publish Foundry agent to M365 copilot or Teams

I’m encountering an issue while publishing an agent in Microsoft Foundry to M365 Copilot or Teams. After creating the agent and Foundry resource, the process automatically created a Bot Service resou...
  • Surya_Narayana's avatar
    Dec 28, 2025

    hi ShwetaI​  you’re not alone, and yes, parts of what you’re seeing are expected, but the 401 Unauthorized means something important is missing or misaligned in the setup.

    About the Bot Service / Application ID

    Yes — this is expected behavior.

    When you publish a Foundry agent to M365 Copilot or Teams, Foundry automatically creates:

    An Azure Bot Service

    An Entra ID (Azure AD) App Registration

    Both will share the same Application (Client) ID.
    This is by design — the bot and the app registration are tightly coupled and represent the same identity.

    So the matching IDs are not the problem

    401 Unauthorized error

    A 401 during publishing almost always points to permissions or consent issues, not a broken resource.

    The most common causes are:

    1.Missing Entra ID permissions or admin consent

    The auto-created App Registration often does not have all required permissions granted.

    Check the App Registration:

    • Go to Azure Portal → Entra ID → App registrations
    • Open the app with the same Application ID
    • Verify API permissions, especially:
      • Microsoft Graph permissions required for Copilot / Teams
    • Make sure Admin consent has been granted

    If admin consent is missing, publishing will fail with 401.

    2.You’re not signed in as the correct tenant admin

    To publish to M365 Copilot or Teams, you must be signed in as:

    • Global Administrator or
    • Teams Administrator

    Being a subscription owner or resource contributor is not enough.

    Double-check:

    • The tenant you’re signed into
    • Your directory role at publish time

    3.Bot Service not fully configured

    Sometimes the Bot Service exists but isn’t fully ready.

    Verify:

    • Bot Service → Configuration
    • Microsoft App ID matches the App Registration
    • Messaging endpoint is present
    • No errors in the Bot Service overview

    4.Tenant-level restrictions

    Some tenants block:

    • Third-party or custom apps in Teams
    • Copilot extensibility without explicit allow rules

    Check:

    • Teams Admin Center
    • Custom app and Copilot extensibility policies
    • App publishing permissions

    Next steps :

    1. Confirm you’re logged in as Global Admin or Teams Admin
    2. Open the App Registration → grant Admin consent
    3. Verify Bot Service configuration is complete
    4. Check Teams Admin Center app policies
    5. Retry publishing after waiting ~5–10 minutes (propagation delay is real)

    This is a very common issue right now with Foundry agent publishing, especially in newly created tenants or when permissions were auto-generated but not consented.

    If everything looks correct and it still fails:

    • Try re-publishing after deleting and recreating only the Bot Service
    • Or open a Microsoft support ticket with the Request ID you shared (that’s useful)

    Hope this helps

     

Resources