Skip to content

Commit 068a95f

Browse files
authored
Merge pull request #787 from fizamusthafa/add-entra-agent-user-skill
feat: add entra-agent-user skill
2 parents 63faa5b + a0c26e1 commit 068a95f

2 files changed

Lines changed: 271 additions & 0 deletions

File tree

docs/README.skills.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Skills differ from other primitives by supporting bundled assets (scripts, code
3636
| [copilot-sdk](../skills/copilot-sdk/SKILL.md) | Build agentic applications with GitHub Copilot SDK. Use when embedding AI agents in apps, creating custom tools, implementing streaming responses, managing sessions, connecting to MCP servers, or creating custom agents. Triggers on Copilot SDK, GitHub SDK, agentic app, embed Copilot, programmable agent, MCP server, custom agent. | None |
3737
| [copilot-usage-metrics](../skills/copilot-usage-metrics/SKILL.md) | Retrieve and display GitHub Copilot usage metrics for organizations and enterprises using the GitHub CLI and REST API. | `get-enterprise-metrics.sh`<br />`get-enterprise-user-metrics.sh`<br />`get-org-metrics.sh`<br />`get-org-user-metrics.sh` |
3838
| [create-web-form](../skills/create-web-form/SKILL.md) | Create robust, accessible web forms with best practices for HTML structure, CSS styling, JavaScript interactivity, form validation, and server-side processing. Use when asked to "create a form", "build a web form", "add a contact form", "make a signup form", or when building any HTML form with data handling. Covers PHP and Python backends, MySQL database integration, REST APIs, XML data exchange, accessibility (ARIA), and progressive web apps. | `references/accessibility.md`<br />`references/aria-form-role.md`<br />`references/css-styling.md`<br />`references/form-basics.md`<br />`references/form-controls.md`<br />`references/form-data-handling.md`<br />`references/html-form-elements.md`<br />`references/html-form-example.md`<br />`references/hypertext-transfer-protocol.md`<br />`references/javascript.md`<br />`references/php-cookies.md`<br />`references/php-forms.md`<br />`references/php-json.md`<br />`references/php-mysql-database.md`<br />`references/progressive-web-app.md`<br />`references/python-as-web-framework.md`<br />`references/python-contact-form.md`<br />`references/python-flask-app.md`<br />`references/python-flask.md`<br />`references/security.md`<br />`references/styling-web-forms.md`<br />`references/web-api.md`<br />`references/web-performance.md`<br />`references/xml.md` |
39+
| [entra-agent-user](../skills/entra-agent-user/SKILL.md) | Create Agent Users in Microsoft Entra ID from Agent Identities, enabling AI agents to act as digital workers with user identity capabilities in Microsoft 365 and Azure environments. | None |
3940
| [excalidraw-diagram-generator](../skills/excalidraw-diagram-generator/SKILL.md) | Generate Excalidraw diagrams from natural language descriptions. Use when asked to "create a diagram", "make a flowchart", "visualize a process", "draw a system architecture", "create a mind map", or "generate an Excalidraw file". Supports flowcharts, relationship diagrams, mind maps, and system architecture diagrams. Outputs .excalidraw JSON files that can be opened directly in Excalidraw. | `references/element-types.md`<br />`references/excalidraw-schema.md`<br />`scripts/.gitignore`<br />`scripts/README.md`<br />`scripts/add-arrow.py`<br />`scripts/add-icon-to-diagram.py`<br />`scripts/split-excalidraw-library.py`<br />`templates/business-flow-swimlane-template.excalidraw`<br />`templates/class-diagram-template.excalidraw`<br />`templates/data-flow-diagram-template.excalidraw`<br />`templates/er-diagram-template.excalidraw`<br />`templates/flowchart-template.excalidraw`<br />`templates/mindmap-template.excalidraw`<br />`templates/relationship-template.excalidraw`<br />`templates/sequence-diagram-template.excalidraw` |
4041
| [fabric-lakehouse](../skills/fabric-lakehouse/SKILL.md) | Use this skill to get context about Fabric Lakehouse and its features for software systems and AI-powered functions. It offers descriptions of Lakehouse data components, organization with schemas and shortcuts, access control, and code examples. This skill supports users in designing, building, and optimizing Lakehouse solutions using best practices. | `references/getdata.md`<br />`references/pyspark.md` |
4142
| [finnish-humanizer](../skills/finnish-humanizer/SKILL.md) | Detect and remove AI-generated markers from Finnish text, making it sound like a native Finnish speaker wrote it. Use when asked to "humanize", "naturalize", or "remove AI feel" from Finnish text, or when editing .md/.txt files containing Finnish content. Identifies 26 patterns (12 Finnish-specific + 14 universal) and 4 style markers. | `references/patterns.md` |

skills/entra-agent-user/SKILL.md

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
---
2+
name: entra-agent-user
3+
description: 'Create Agent Users in Microsoft Entra ID from Agent Identities, enabling AI agents to act as digital workers with user identity capabilities in Microsoft 365 and Azure environments.'
4+
---
5+
6+
# SKILL: Creating Agent Users in Microsoft Entra Agent ID
7+
8+
## Overview
9+
10+
An **agent user** is a specialized user identity in Microsoft Entra ID that enables AI agents to act as digital workers. It allows agents to access APIs and services that strictly require user identities (e.g., Exchange mailboxes, Teams, org charts), while maintaining appropriate security boundaries.
11+
12+
Agent users receive tokens with `idtyp=user`, unlike regular agent identities which receive `idtyp=app`.
13+
14+
---
15+
16+
## Prerequisites
17+
18+
- A **Microsoft Entra tenant** with Agent ID capabilities
19+
- An **agent identity** (service principal of type `ServiceIdentity`) created from an **agent identity blueprint**
20+
- One of the following **permissions**:
21+
- `AgentIdUser.ReadWrite.IdentityParentedBy` (least privileged)
22+
- `AgentIdUser.ReadWrite.All`
23+
- `User.ReadWrite.All`
24+
- The caller must have at minimum the **Agent ID Administrator** role (in delegated scenarios)
25+
26+
> **Important:** The `identityParentId` must reference a true agent identity (created via an agent identity blueprint), NOT a regular application service principal. You can verify by checking that the service principal has `@odata.type: #microsoft.graph.agentIdentity` and `servicePrincipalType: ServiceIdentity`.
27+
28+
---
29+
30+
## Architecture
31+
32+
```
33+
Agent Identity Blueprint (application template)
34+
35+
├── Agent Identity (service principal - ServiceIdentity)
36+
│ │
37+
│ └── Agent User (user - agentUser) ← 1:1 relationship
38+
39+
└── Agent Identity Blueprint Principal (service principal in tenant)
40+
```
41+
42+
| Component | Type | Token Claim | Purpose |
43+
|---|---|---|---|
44+
| Agent Identity | Service Principal | `idtyp=app` | Backend/API operations |
45+
| Agent User | User (`agentUser`) | `idtyp=user` | Act as a digital worker in M365 |
46+
47+
---
48+
49+
## Step 1: Verify the Agent Identity Exists
50+
51+
Before creating an agent user, confirm the agent identity is a proper `agentIdentity` type:
52+
53+
```http
54+
GET https://graph.microsoft.com/beta/servicePrincipals/{agent-identity-id}
55+
Authorization: Bearer <token>
56+
```
57+
58+
Verify the response contains:
59+
```json
60+
{
61+
"@odata.type": "#microsoft.graph.agentIdentity",
62+
"servicePrincipalType": "ServiceIdentity",
63+
"agentIdentityBlueprintId": "<blueprint-id>"
64+
}
65+
```
66+
67+
### PowerShell
68+
69+
```powershell
70+
Connect-MgGraph -Scopes "Application.Read.All" -TenantId "<tenant>" -UseDeviceCode -NoWelcome
71+
Invoke-MgGraphRequest -Method GET `
72+
-Uri "https://graph.microsoft.com/beta/servicePrincipals/<agent-identity-id>" | ConvertTo-Json -Depth 3
73+
```
74+
75+
> **Common mistake:** Using an app registration's `appId` or a regular application service principal's `id` will fail. Only agent identities created from blueprints work.
76+
77+
---
78+
79+
## Step 2: Create the Agent User
80+
81+
### HTTP Request
82+
83+
```http
84+
POST https://graph.microsoft.com/beta/users/microsoft.graph.agentUser
85+
Content-Type: application/json
86+
Authorization: Bearer <token>
87+
88+
{
89+
"accountEnabled": true,
90+
"displayName": "My Agent User",
91+
"mailNickname": "my-agent-user",
92+
"userPrincipalName": "my-agent-user@yourtenant.onmicrosoft.com",
93+
"identityParentId": "<agent-identity-object-id>"
94+
}
95+
```
96+
97+
### Required Properties
98+
99+
| Property | Type | Description |
100+
|---|---|---|
101+
| `accountEnabled` | Boolean | `true` to enable the account |
102+
| `displayName` | String | Human-friendly name |
103+
| `mailNickname` | String | Mail alias (no spaces/special chars) |
104+
| `userPrincipalName` | String | UPN — must be unique in the tenant (`alias@verified-domain`) |
105+
| `identityParentId` | String | Object ID of the parent agent identity |
106+
107+
### PowerShell
108+
109+
```powershell
110+
Connect-MgGraph -Scopes "User.ReadWrite.All" -TenantId "<tenant>" -UseDeviceCode -NoWelcome
111+
112+
$body = @{
113+
accountEnabled = $true
114+
displayName = "My Agent User"
115+
mailNickname = "my-agent-user"
116+
userPrincipalName = "my-agent-user@yourtenant.onmicrosoft.com"
117+
identityParentId = "<agent-identity-object-id>"
118+
} | ConvertTo-Json
119+
120+
Invoke-MgGraphRequest -Method POST `
121+
-Uri "https://graph.microsoft.com/beta/users/microsoft.graph.agentUser" `
122+
-Body $body -ContentType "application/json" | ConvertTo-Json -Depth 3
123+
```
124+
125+
### Key Notes
126+
127+
- **No password** — agent users cannot have passwords. They authenticate via their parent agent identity's credentials.
128+
- **1:1 relationship** — each agent identity can have at most one agent user. Attempting to create a second returns `400 Bad Request`.
129+
- The `userPrincipalName` must be unique. Don't reuse an existing user's UPN.
130+
131+
---
132+
133+
## Step 3: Assign a Manager (Optional)
134+
135+
Assigning a manager allows the agent user to appear in org charts (e.g., Teams).
136+
137+
```http
138+
PUT https://graph.microsoft.com/beta/users/{agent-user-id}/manager/$ref
139+
Content-Type: application/json
140+
Authorization: Bearer <token>
141+
142+
{
143+
"@odata.id": "https://graph.microsoft.com/beta/users/{manager-user-id}"
144+
}
145+
```
146+
147+
### PowerShell
148+
149+
```powershell
150+
$managerBody = '{"@odata.id":"https://graph.microsoft.com/beta/users/<manager-user-id>"}'
151+
Invoke-MgGraphRequest -Method PUT `
152+
-Uri "https://graph.microsoft.com/beta/users/<agent-user-id>/manager/`$ref" `
153+
-Body $managerBody -ContentType "application/json"
154+
```
155+
156+
---
157+
158+
## Step 4: Set Usage Location and Assign Licenses (Optional)
159+
160+
A license is needed for the agent user to have a mailbox, Teams presence, etc. Usage location must be set first.
161+
162+
### Set Usage Location
163+
164+
```http
165+
PATCH https://graph.microsoft.com/beta/users/{agent-user-id}
166+
Content-Type: application/json
167+
Authorization: Bearer <token>
168+
169+
{
170+
"usageLocation": "US"
171+
}
172+
```
173+
174+
### List Available Licenses
175+
176+
```http
177+
GET https://graph.microsoft.com/beta/subscribedSkus?$select=skuPartNumber,skuId,consumedUnits,prepaidUnits
178+
Authorization: Bearer <token>
179+
```
180+
181+
Requires `Organization.Read.All` permission.
182+
183+
### Assign a License
184+
185+
```http
186+
POST https://graph.microsoft.com/beta/users/{agent-user-id}/assignLicense
187+
Content-Type: application/json
188+
Authorization: Bearer <token>
189+
190+
{
191+
"addLicenses": [
192+
{ "skuId": "<sku-id>" }
193+
],
194+
"removeLicenses": []
195+
}
196+
```
197+
198+
### PowerShell (all in one)
199+
200+
```powershell
201+
Connect-MgGraph -Scopes "User.ReadWrite.All","Organization.Read.All" -TenantId "<tenant>" -NoWelcome
202+
203+
# Set usage location
204+
Invoke-MgGraphRequest -Method PATCH `
205+
-Uri "https://graph.microsoft.com/beta/users/<agent-user-id>" `
206+
-Body '{"usageLocation":"US"}' -ContentType "application/json"
207+
208+
# Assign license
209+
$licenseBody = '{"addLicenses":[{"skuId":"<sku-id>"}],"removeLicenses":[]}'
210+
Invoke-MgGraphRequest -Method POST `
211+
-Uri "https://graph.microsoft.com/beta/users/<agent-user-id>/assignLicense" `
212+
-Body $licenseBody -ContentType "application/json"
213+
```
214+
215+
> **Tip:** You can also assign licenses via the **Entra admin center** under Identity → Users → All users → select the agent user → Licenses and apps.
216+
217+
---
218+
219+
## Provisioning Times
220+
221+
| Service | Estimated Time |
222+
|---|---|
223+
| Exchange mailbox | 5–30 minutes |
224+
| Teams availability | 15 min – 24 hours |
225+
| Org chart / People search | Up to 24–48 hours |
226+
| SharePoint / OneDrive | 5–30 minutes |
227+
| Global Address List | Up to 24 hours |
228+
229+
---
230+
231+
## Agent User Capabilities
232+
233+
- ✅ Added to Microsoft Entra groups (including dynamic groups)
234+
- ✅ Access user-only APIs (`idtyp=user` tokens)
235+
- ✅ Own a mailbox, calendar, and contacts
236+
- ✅ Participate in Teams chats and channels
237+
- ✅ Appear in org charts and People search
238+
- ✅ Added to administrative units
239+
- ✅ Assigned licenses
240+
241+
## Agent User Security Constraints
242+
243+
- ❌ Cannot have passwords, passkeys, or interactive sign-in
244+
- ❌ Cannot be assigned privileged admin roles
245+
- ❌ Cannot be added to role-assignable groups
246+
- ❌ Permissions similar to guest users by default
247+
- ❌ Custom role assignment not available
248+
249+
---
250+
251+
## Troubleshooting
252+
253+
| Error | Cause | Fix |
254+
|---|---|---|
255+
| `Agent user IdentityParent does not exist` | `identityParentId` points to a non-existent or non-agent-identity object | Verify the ID is an `agentIdentity` service principal, not a regular app |
256+
| `400 Bad Request` (identityParentId already linked) | The agent identity already has an agent user | Each agent identity supports only one agent user |
257+
| `409 Conflict` on UPN | The `userPrincipalName` is already taken | Use a unique UPN |
258+
| License assignment fails | Usage location not set | Set `usageLocation` before assigning licenses |
259+
260+
---
261+
262+
## References
263+
264+
- [Agent identities](https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/agent-identities)
265+
- [Agent users](https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/agent-users)
266+
- [Agent service principals](https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/agent-service-principals)
267+
- [Create agent identity blueprint](https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/create-blueprint)
268+
- [Create agent identities](https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/create-delete-agent-identities)
269+
- [agentUser resource type (Graph API)](https://learn.microsoft.com/en-us/graph/api/resources/agentuser?view=graph-rest-beta)
270+
- [Create agentUser (Graph API)](https://learn.microsoft.com/en-us/graph/api/agentuser-post?view=graph-rest-beta)

0 commit comments

Comments
 (0)