Secure Agent Access with Foundry Roles
Lab overview
One account has done everything so far. In this lab, you create two Entra ID security groups, give developers the Foundry User role on the project through the Foundry portal, give the help desk the Foundry Agent Consumer role on the resource through Azure IAM, and verify both assignments and their scopes. You finish by attaching contoso-helpdesk-guardrail directly to the agent, which had been inheriting it from its model.
Why you'd do this
Building and using an agent are different jobs, and in any real tenant they're done by different people. The developers who tune instructions and attach knowledge should not be the same identities that help desk staff sign in with to ask questions, and neither group needs to be a subscription Owner. Foundry has its own roles for exactly this split: Foundry User can build inside a project (deploy models, create agents, run evaluations), and Foundry Agent Consumer can only invoke agents that already exist. Being an Owner on the subscription, as you saw in lab 1, gets you neither of those; Owner manages the Azure resource, not what happens inside it.
Assigning the roles to Entra ID security groups rather than individual accounts is the habit that makes this maintainable. When a new developer joins, you add them to SG-Foundry-Developers and they inherit everything; when someone leaves the help desk, you remove them from one group instead of hunting through role assignments on every resource. This is standard Azure practice, and it's also what lab 12 depends on: the help desk group you create here is the audience the agent gets published to.
Notice that the two assignments happen in different places, and that's not an accident. The developer role is granted from the Foundry portal and lands on the project, so developers can work in contoso-knowledge-assistant without touching other projects on the same resource. The consumer role is granted from Azure IAM and lands on the resource, which is the scope an application or Teams integration authenticates against. The Check access step at the end is how you confirm which scope each group actually got, and it's the first thing to check when someone reports "I can see the project but can't do anything."
The last step closes a gap from lab 4. The guardrail was assigned to the model deployment, so the agent inherited it indirectly; attaching it to the agent itself means the control follows the agent even if someone later swaps its model. Saving produces version 4. For certification prep, role-based access to Foundry resources and projects is AI-103 material, and the resource-versus-project scoping question is a classic exam pattern.
Lab details
- Security Groups:
SG-Foundry-DevelopersandSG-HelpDesk-AgentUsers - Developer Access: Reader and Foundry User on the project, assigned from the Foundry portal
- Help Desk Access: Foundry Agent Consumer on
contoso-foundry-01, assigned through Azure IAM - Guardrail:
contoso-helpdesk-guardrailapplied to bothcontoso-chatandcontoso-helpdesk-agent - Agent:
contoso-helpdesk-agent, version 4
Learning objectives
- Explain why subscription Owners still need a Foundry role to build in a project.
- Create Entra ID security groups and assign Foundry roles to them.
- Compare the Foundry User and Foundry Agent Consumer roles and their assignment scopes.
- Attach a guardrail directly to an agent.
Exam relevance
- AI-901 — Microsoft Azure AI Fundamentals — AI agents and their components, grounding with your own data.
- AI-103 — Developing AI Apps and Agents on Azure — create a prompt agent in Foundry Agent Service, agent instructions, tools, and versions.
How this lab fits into the project
This is lab 10 of 12 in the Contoso Knowledge Assistant project. Contoso's IT help desk fields the same policy questions all day, so over this series you'll build an AI agent that answers them from the company's own documents, then ground it, secure it, evaluate it, monitor it, and publish it to Teams. This lab separates the people who build the agent from the people who use it, and creates the help desk group that lab 12 publishes to.
Step-by-step instructions
- Review who has access today:
- In the Foundry portal, click Manage.
- On the Users tab of the Project details page, note your account with the Foundry User role assigned in lab 1. Subscription Owners can manage the resource but need Foundry User to build in it.
- Create two security groups:
- Click the Microsoft Azure browser tab.
- In the search bar, type
Microsoft Entra IDand select Microsoft Entra ID. - Expand Manage and click Groups.
- Click New group, ensure Group type is Security, type
SG-Foundry-Developersas the name, and click Create. - Click New group, type
SG-HelpDesk-AgentUsersas the name, and click Create.
- Give developers build access to the project:
- Return to the Manage page in the Foundry portal.
- On the Users tab, click Add user.
- Type
sg-foundryto search and select SG-Foundry-Developers. - Note that the Reader and Foundry User roles are assigned to the group automatically.
- Click Add user, then Close.
- Give the help desk access to use the agent:
- Click the Microsoft Azure browser tab, click Home, and click
contoso-foundry-01. - Click Access control (IAM), then + Add, then Add role assignment.
- Search for
Foundry Agent Consumer, select it, and click Next. - Click + Select members, search for
SG-HelpDesk, click SG-HelpDesk-AgentUsers, and click Select. - Click Review + assign twice.
- Click the Microsoft Azure browser tab, click Home, and click
- Verify the assignments:
- Click the Role assignments tab and scroll down to find SG-HelpDesk-AgentUsers with the Foundry Agent Consumer role.
- Scroll back up and click the Check access tab, then the Check access button.
- Search for
SG-Foundryand click SG-Foundry-Developers. - Note the Foundry User role and its scope, which is the project rather than the whole resource.
- Attach the guardrail to the agent:
- Click the Foundry portal browser tab, click Build, then Guardrails.
- Click the
contoso-helpdesk-guardrailrow, then Edit. - Click Next, select
contoso-helpdesk-agentto add your agent, and click Next. - Click Save.
- Note that Applied to now lists both
contoso-chatandcontoso-helpdesk-agent. - Click Microsoft Foundry in the upper left to return to the home page.