Share via

Unable to publish hosted agent to Teams & M365 Copilot — identity mismatch error (May 2026, North Central US)

Dibyendu Kankalia 0 Reputation points Microsoft Employee
2026-05-04T14:48:59.1566667+00:00

When I click "Publish → Teams & M365 Copilot" in AI Foundry portal for a hosted agent, the publish fails with:

Failed to publish agent

BotId 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' does not match the application's

default instance identity ClientId 'yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy'.

[Status: 400, Code: UserError]

The agent cannot be published to Teams at all. This blocks the entire Teams channel integration.

Root cause: The publish flow creates a new ServiceIdentity (ClientId Y) in the resource group, but then validates it against the agent's existing identity (BotId X) assigned at creation. These never match

because:

  1. The agent's instance_identity is immutable (PATCH returns 200 but doesn't update)
  2. Publish always creates a new identity instead of reusing the existing one
  3. The Foundry-managed ServiceIdentity cannot be deleted via Graph API

What I tried (all failed):

  • Created a brand new agent — same error with fresh identities
  • Deleted the auto-created bot service and republished — Foundry reuses the conflicting identity
  • Attempted PATCH to update agent identity — silently ignored
  • Granted RBAC to both identities — no effect

This affects every hosted agent in my project, not just one. Confirmed on two separate agents with completely different identities.

Operation IDs for investigation:

  • f927ce5c61c14a188e727e42928040be (request: b05954fe2f2a1a82)
  • 5ffd932c02b74d658a640a02e95aa273 (request: 948993c0406e2111)

Region: North Central US. Happy to provide subscription/tenant details privately if needed.

Foundry Agent Service
Foundry Agent Service

A fully managed platform in Microsoft Foundry for hosting, scaling, and securing AI agents built with any supported framework or model


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.