How can I fix a server error when publishing an Agent to Microsoft Teams and Copilot via Azure AI Foundry?

Brendan Hart 20 Reputation points
2025-11-21T16:59:34.2533333+00:00

Has anyone been able to successfully publish a nocode agent to Teams or Co Pilot. Whenever I try publishing, I get this error message: There was a problem preparing the agentAn error occurred while preparing the agent. Please try again. Status Code: 500 Request ID: 092b2fb0-8b01-4991-be9a-6ba3068f854c

I'm wondering if anyone knows the proper RBAC configuration for the resources?Screenshot 2025-11-21 102118

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
{count} votes

Answer accepted by question author
  1. Adam Zachary 2,255 Reputation points
    2025-11-21T18:00:26.4966667+00:00

    Hi Brendan

    A while ago I ran into this exact 500-error when trying to publish an agent from Azure AI Foundry to Teams and Microsoft 365 Copilot, and the issue was not the agent itself. It turned out to be a combination of missing RBAC permissions and a backend publishing failure on Microsoft’s side.

    Here are the things I followed to fix it:

    1. Make sure the App Registration has the required permissions The app you’re publishing must have a service principal in the tenant and the following roles assigned at the resource group level (minimum):

    Cognitive Services OpenAI Contributor

    Cognitive Services User

    Bot Channels Registration Contributor

    Application Administrator (for the publish step)

    The publishing step needs rights to create or update the Bot Service registration in your tenant.

    1. Verify Azure Bot Service exists and is healthy Your screenshot shows a bot name, but make sure:

    The bot resource actually exists

    The bot is linked to the same app registration (client ID matches)

    The Messaging endpoint is valid (even if it’s not used yet)

    If the bot is missing or mismatched, the publish step fails with a 500 error.

    1. Check Teams Admin Center policies In your tenant, make sure:

    Custom apps are allowed

    Uploading apps is enabled

    App publishing is not restricted to specific groups

    If these policies block publishing, AI Foundry returns a 500 instead of a clear error.

    1. Retry after a few minutes There are still backend issues with the preview publishing pipeline. Sometimes the Publishing API responds with 500 even when permissions are correct. Retrying after a few minutes often succeeds.
    2. If it keeps failing, open a support ticket
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.