---
title: "Comment by Ahmet Özel on \"Invoking Microsoft Foundry Hosted Agent from C# application\" | Hashnode"
description: "Calling out the two subtle Entra and RBAC gotchas—granting the Azure Machine Learning Services API permission so the access token carries the ai.azure.com audie"
url: "https://hashnode.com/posts/invoking-microsoft-foundry-hosted-agent-from-csharp-application/6b102e53997e29119eca0f06/comment/6b11159da9e2267bc241c36b"
---

[Discussion](https://hashnode.com/posts/invoking-microsoft-foundry-hosted-agent-from-csharp-application/6b102e53997e29119eca0f06)

Comment [Invoking Microsoft Foundry Hosted Agent from C# application](https://hashnode.com/posts/invoking-microsoft-foundry-hosted-agent-from-csharp-application/6b102e53997e29119eca0f06)

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[8h ago](https://hashnode.com/posts/invoking-microsoft-foundry-hosted-agent-from-csharp-application/6b102e53997e29119eca0f06/comment/6b11159da9e2267bc241c36b)

Calling out the two subtle Entra and RBAC gotchas—granting the Azure Machine Learning Services API permission so the access token carries the ai.azure.com audience, and scoping IAM to the Foundry Project rather than the hosted agent—will save C# teams hours of opaque 401/403 debugging.

Testing with a separate least-privilege Foundry User account instead of a login that inherits Subscription Owner permissions is also an underrated habit. Inherited owner roles mask missing RBAC grants throughout local development and only blow up the moment you onboard the first real end user.
