A unified Azure platform for creating and managing AI models, agents, and applications with built‑in enterprise security, monitoring, and governance
Hi ,
Thanks for reaching out to Microsoft Q&A.
This is almost always an identity mismatch, not a missing role. The object ID in the error is the actual identity used at runtime by DefaultAzureCredential, and it is not the service principal you think you assigned roles to. In most cases it resolves to a different principal (for example a managed identity, VS Code/Azure CLI login, or a different tenant context), which is why it does not show up in your tenant and has no Microsoft.CognitiveServices/accounts/AIServices/agents/write permission. Fix is straightforward: confirm which identity is being picked up (enable AZURE_IDENTITY_LOGGING_ENABLED=1 or log the token), then explicitly force the intended service principal via AZURE_CLIENT_ID / TENANT_ID / CLIENT_SECRET, or assign the required role to the actual object ID being used. Also ensure the role is applied at the correct scope (AI Project / Cognitive Services account) and not just at a higher or unrelated scope.
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.