Entra Agent User

Entra Agent User

Explains how to create Agent Users in Microsoft Entra ID from agent identities so AI agents can act as digital workers, covering prerequisites, permissions and API calls.

Skill files1 file
SKILL.md271 lines
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)
271

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 13,704 prompts

More by @OpenSourceBuffGuy

See all
Seated woman over giant graphite watercolor face prompt image

Seated woman over giant graphite watercolor face

Paints an elegant watercolor fashion portrait of a seated woman in lavender and ivory in front of a giant graphite-and-watercolor close-up of her own face.

image-prompt, gpt-image, watercolor, portrait, woman, fashion, fashion-shoot, editorial, double-exposure, black-and-white, muted-colors, soft-lighting, full-body, vertical-format, negative-prompt, illustration, sketch, negative-space, fine-art, character-design, structured-output, for-artists, jewelry, long-form

Woman with hot cup at Christmas market prompt image

Woman with hot cup at Christmas market

Creates a candid smartphone-style photo of a woman in a white fur coat holding a hot drink at an evening Christmas market, keeping the face from a reference photo.

image-prompt, gpt-image, nano-banana, face-reference, reference-image, negative-prompt, photorealistic, portrait, woman, christmas, holiday, winter, night-scene, candid, smartphone-photo, medium-shot, fashion, street-photography, cozy, warm-colors, structured-output, for-photographers, long-form, guardrails, cityscape

Suited man enters glowing elevator, floor display at 13 prompt image

Suited man enters glowing elevator, floor display at 13

Writes a 30-second Korean mystery thriller in which a man's elevator opens onto an impossible floor 0, with scene beats, cinematography and sound design.

video-prompt, seedance, horror, thriller, short-film, cinematic, multi-shot, timed-beats, character-consistency, camera-movement, sound-effects, guardrails, structured-output, photorealistic, korea, night-scene, symmetry, moody, for-filmmakers, long-form, advanced, film-noir

Reviews

Loading reviews…

Discussion

Loading comments…