AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Microsoft Entra Agent ID provides a framework for creating and managing secure, OAuth2-capable identities for AI agents. This skill covers the lifecycle of agent identities, including the creation of Agent Identity Blueprints, BlueprintPrincipals, and individual Agent Identities. It details the necessary Microsoft Graph beta API interactions, required permissions, and authentication patterns such as Workload Identity Federation for production or client secrets for development.
What it does
- Provision Agent Identity Blueprints to define agent types.
- Create BlueprintPrincipals to enable agent identity functionality.
- Generate individual Agent Identities for specific agent instances.
- Configure Workload Identity Federation for secure production authentication.
- Manage permissions and admin consent for Agent ID operations.
- Perform cleanup of blueprints, principals, and agent identities.
When to use it
- When building AI agents that require secure, OAuth2-based authentication within the Microsoft Entra ecosystem.
- When deploying polyglot agents in containerized environments like Docker or Kubernetes.
- When implementing autonomous or interactive agent patterns that need distinct service identities.
- When managing third-party agent integrations that require standard identity provisioning.
Advantages
- Enables standardized OAuth2 authentication for AI agents.
- Supports secure production workflows via Workload Identity Federation.
- Provides granular control over agent identity lifecycles.
- Integrates directly with Microsoft Graph for programmatic management.
Usage examples
- “How do I create an Agent Identity Blueprint using the Microsoft Graph API?”
- The agent provides the JSON structure for a POST request to the /applications endpoint, including the required sponsor binding and OData type.
- “What are the steps to set up Workload Identity Federation for my agent?”
- The agent outlines the process of setting identifierUris, creating a federated identity credential on the blueprint, and configuring the Managed Identity for token exchange.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/microsoft/entra-agent-id/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip entra-agent-id.zip -d .agents/skills
Documentation by Microsoft
Microsoft Entra Agent ID
Create and manage OAuth2-capable identities for AI agents using Microsoft Graph beta API.
Preview API — All Agent Identity endpoints are under
/betaonly. Not available in/v1.0.
Before You Start
Search microsoft-docs MCP for the latest Agent ID documentation:
Query: "Microsoft Entra agent identity setup"
Verify: API parameters match current preview behavior
Conceptual Model
Agent Identity Blueprint (application) ← one per agent type/project
└── BlueprintPrincipal (service principal) ← MUST be created explicitly
├── Agent Identity (SP): agent-1 ← one per agent instance
├── Agent Identity (SP): agent-2
└── Agent Identity (SP): agent-3Prerequisites
PowerShell (recommended for interactive setup)
# Requires PowerShell 7+
Install-Module Microsoft.Graph.Beta.Applications -Scope CurrentUser -ForcePython (for programmatic provisioning)
pip install azure-identity requestsRequired Entra Roles
One of: Agent Identity Developer, Agent Identity Administrator, or Application Administrator.
Environment Variables
AZURE_TENANT_ID=<your-tenant-id>
AZURE_CLIENT_ID=<app-registration-client-id>
AZURE_CLIENT_SECRET=<app-registration-secret>Authentication
⚠️
DefaultAzureCredentialis NOT supported. Azure CLI tokens containDirectory.AccessAsUser.All, which Agent Identity APIs explicitly reject (403). You MUST use a dedicated app registration withclient_credentialsflow or connect viaConnect-MgGraphwith explicit delegated scopes.
PowerShell (delegated permissions)
Connect-MgGraph -Scopes @(
"AgentIdentityBlueprint.Create",
"AgentIdentityBlueprint.ReadWrite.All",
"AgentIdentityBlueprintPrincipal.Create",
"User.Read"
)
Set-MgRequestContext -ApiVersion beta
$currentUser = (Get-MgContext).Account
$userId = (Get-MgUser -UserId $currentUser).IdPython (application permissions)
import os
import requests
from azure.identity import ClientSecretCredential
credential = ClientSecretCredential(
tenant_id=os.environ["AZURE_TENANT_ID"],
client_id=os.environ["AZURE_CLIENT_ID"],
client_secret=os.environ["AZURE_CLIENT_SECRET"],
)
token = credential.get_token("https://graph.microsoft.com/.default")
GRAPH = "https://graph.microsoft.com/beta"
headers = {
"Authorization": f"Bearer {token.token}",
"Content-Type": "application/json",
"OData-Version": "4.0", # Required for all Agent Identity API calls
}Core Workflow
Step 1: Create Agent Identity Blueprint
Sponsors are required and must be User objects — ServicePrincipals and Groups are rejected.
import subprocess
# Get sponsor user ID (client_credentials has no user context, so use az CLI)
result = subprocess.run(
["az", "ad", "signed-in-user", "show", "--query", "id", "-o", "tsv"],
capture_output=True, text=True, check=True,
)
user_id = result.stdout.strip()
blueprint_body = {
"@odata.type": "Microsoft.Graph.AgentIdentityBlueprint",
"displayName": "My Agent Blueprint",
"[email protected]": [
f"https://graph.microsoft.com/beta/users/{user_id}"
],
}
resp = requests.post(f"{GRAPH}/applications", headers=headers, json=blueprint_body)
resp.raise_for_status()
blueprint = resp.json()
app_id = blueprint["appId"]
blueprint_obj_id = blueprint["id"]Step 2: Create BlueprintPrincipal
This step is mandatory. Creating a Blueprint does NOT auto-create its service principal. Without this, Agent Identity creation fails with:
400: The Agent Blueprint Principal for the Agent Blueprint does not exist.
sp_body = {
"@odata.type": "Microsoft.Graph.AgentIdentityBlueprintPrincipal",
"appId": app_id,
}
resp = requests.post(f"{GRAPH}/servicePrincipals", headers=headers, json=sp_body)
resp.raise_for_status()If implementing idempotent scripts, check for and create the BlueprintPrincipal even when the Blueprint already exists (a previous run may have created the Blueprint but crashed before creating the SP).
Step 3: Create Agent Identities
agent_body = {
"@odata.type": "Microsoft.Graph.AgentIdentity",
"displayName": "my-agent-instance-1",
"agentIdentityBlueprintId": app_id,
"[email protected]": [
f"https://graph.microsoft.com/beta/users/{user_id}"
],
}
resp = requests.post(f"{GRAPH}/servicePrincipals", headers=headers, json=agent_body)
resp.raise_for_status()
agent = resp.json()API Reference
| Operation | Method | Endpoint | OData Type |
|---|---|---|---|
| Create Blueprint | POST | /applications | Microsoft.Graph.AgentIdentityBlueprint |
| Create BlueprintPrincipal | POST | /servicePrincipals | Microsoft.Graph.AgentIdentityBlueprintPrincipal |
| Create Agent Identity | POST | /servicePrincipals | Microsoft.Graph.AgentIdentity |
| List Agent Identities | GET | /servicePrincipals?$filter=... | — |
| Delete Agent Identity | DELETE | /servicePrincipals/{id} | — |
| Delete Blueprint | DELETE | /applications/{id} | — |
All endpoints use base URL: https://graph.microsoft.com/beta
Required Permissions
| Permission | Purpose |
|---|---|
Application.ReadWrite.All | Blueprint CRUD (application objects) |
AgentIdentityBlueprint.Create | Create new Blueprints |
AgentIdentityBlueprint.ReadWrite.All | Read/update Blueprints |
AgentIdentityBlueprintPrincipal.Create | Create BlueprintPrincipals |
AgentIdentity.Create.All | Create Agent Identities |
AgentIdentity.ReadWrite.All | Read/update Agent Identities |
There are 18 Agent Identity-specific Graph application permissions. Discover all:
az ad sp show --id 00000003-0000-0000-c000-000000000000 \
--query "appRoles[?contains(value, 'AgentIdentity')].{id:id, value:value}" -o jsonGrant admin consent (required for application permissions):
az ad app permission admin-consent --id <client-id>Admin consent may fail with 404 if the service principal hasn't replicated. Retry with 10–40s backoff.
Cleanup
# Delete Agent Identity
requests.delete(f"{GRAPH}/servicePrincipals/{agent['id']}", headers=headers)
# Delete BlueprintPrincipal (get SP ID first)
sps = requests.get(
f"{GRAPH}/servicePrincipals?$filter=appId eq '{app_id}'",
headers=headers,
).json()
for sp in sps.get("value", []):
requests.delete(f"{GRAPH}/servicePrincipals/{sp['id']}", headers=headers)
# Delete Blueprint
requests.delete(f"{GRAPH}/applications/{blueprint_obj_id}", headers=headers)Best Practices
Always create BlueprintPrincipal after Blueprint — not auto-created; implement idempotent checks on both
Use User objects as sponsors — ServicePrincipals and Groups are rejected
Handle permission propagation delays — after admin consent, wait 30–120s; retry with backoff on 403
Include
OData-Version: 4.0header on every Graph requestUse Workload Identity Federation for production auth — for local dev, use a client secret on the Blueprint (see references/oauth2-token-flow.md)
Set
identifierUrison Blueprint before using OAuth2 scoping (api://{app-id})Never use Azure CLI tokens for API calls — they contain
Directory.AccessAsUser.Allwhich is hard-rejectedCheck for existing resources before creating — implement idempotent provisioning
References
| File | Contents |
|---|---|
| references/oauth2-token-flow.md | Production (Managed Identity + WIF) and local dev (client secret) token flows |
| references/known-limitations.md | 29 known issues organized by category (from official preview known-issues page) |
| references/sdk-sidecar.md | Microsoft Entra SDK for AgentID — endpoints, 3P agent patterns, Docker/K8s deployment, security |
External Links
| Resource | URL |
|---|---|
| Official Setup Guide | https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/agent-id-setup-instructions |
| AI-Guided Setup | https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/agent-id-ai-guided-setup |
| Microsoft Entra SDK for AgentID — Overview | https://learn.microsoft.com/en-us/entra/msidweb/agent-id-sdk/overview |
| Microsoft Entra SDK for AgentID — Endpoints | https://learn.microsoft.com/en-us/entra/msidweb/agent-id-sdk/endpoints |
Files
- ATTRIBUTION.mdAdded by AutoGineer859 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md9.2 KiB
- references/known-limitations.md4.8 KiB
- references/oauth2-token-flow.md4.9 KiB
- references/sdk-sidecar.md13.0 KiB
references/oauth2-token-flow.md
OAuth2 Token Flow
Source: Agent ID Setup Instructions
Agent Identities authenticate at runtime using credentials configured on the Blueprint (not the Agent Identity itself). Two options are available:
| Option | Use case | Credential type |
|---|---|---|
| Managed Identity + WIF | Production (Azure-hosted) | Federated Identity Credential |
| Client secret | Local development / testing | Password credential on Blueprint |
Option A: Managed Identity + Workload Identity Federation (Production)
Architecture
Container App (user-assigned MI)
-> ManagedIdentityCredential.get_token("api://{blueprint-app-id}/.default")
-> Azure AD token exchange (MI token -> Agent ID token)
-> JWT with oid = MI principal, aud = api://{blueprint-app-id}
-> Backend validates JWT signature + claims1. Set Application ID URI on Blueprint
Required for OAuth2 scope resolution:
requests.patch(
f"{GRAPH}/applications/{blueprint_obj_id}",
headers=headers,
json={"identifierUris": [f"api://{app_id}"]},
)2. Create Federated Identity Credential
Create on the Blueprint (not the Agent Identity):
fic_body = {
"name": "my-fic-name",
"issuer": f"https://login.microsoftonline.com/{tenant_id}/v2.0",
"subject": "{mi-principal-id}", # The MI's object ID (principalId), NOT client ID
"audiences": ["api://AzureADTokenExchange"],
}
requests.post(
f"{GRAPH}/applications/{blueprint_obj_id}/microsoft.graph.agentIdentityBlueprint/federatedIdentityCredentials",
headers=headers,
json=fic_body,
)3. Acquire Token (Caller Side)
from azure.identity import ManagedIdentityCredential
cred = ManagedIdentityCredential(client_id=mi_client_id)
token = cred.get_token(f"api://{blueprint_app_id}/.default")
# Include in requests: Authorization: Bearer {token.token}4. Validate Token (Backend)
import jwt
from jwt import PyJWKClient
jwks_uri = f"https://login.microsoftonline.com/{tenant_id}/discovery/v2.0/keys"
jwks_client = PyJWKClient(jwks_uri)
signing_key = jwks_client.get_signing_key_from_jwt(token_str)
claims = jwt.decode(
token_str,
signing_key.key,
algorithms=["RS256"],
audience=f"api://{blueprint_app_id}",
issuer=f"https://sts.windows.net/{tenant_id}/",
)Key Rules (WIF)
Federated credentials go on the Blueprint, not the Agent Identity SP. Use the
.../microsoft.graph.agentIdentityBlueprint/federatedIdentityCredentialspath.subjectis the MI's principalId (object ID), not its client ID.audiencesmust be["api://AzureADTokenExchange"], not your API audience.Issuer format:
https://login.microsoftonline.com/{tenant}/v2.0Token issuer (for validation):
https://sts.windows.net/{tenant}/(note the trailing slash and different domain)
Option B: Client Secret (Local Development / Testing Only)
For local development where no Managed Identity is available.
1. Add a Password Credential to the Blueprint
Via PowerShell:
$secretBody = @{
"passwordCredential" = @{
"displayName" = "Dev Secret"
"endDateTime" = "2027-01-01T00:00:00Z"
}
}
$credential = Invoke-MgGraphRequest -Method POST `
-Uri "https://graph.microsoft.com/beta/applications/<BLUEPRINT_OBJECT_ID>/addPassword" `
-Headers @{"OData-Version"="4.0"; "Content-Type"="application/json"} `
-Body ($secretBody | ConvertTo-Json -Depth 5) -OutputType PSObject
$credential.secretText # Save NOW — cannot be retrieved laterOr via Python (with an existing token):
secret_body = {
"passwordCredential": {
"displayName": "Dev Secret",
"endDateTime": "2027-01-01T00:00:00Z",
}
}
resp = requests.post(
f"{GRAPH}/applications/{blueprint_obj_id}/addPassword",
headers=headers,
json=secret_body,
)
secret_text = resp.json()["secretText"] # Save NOW2. Acquire Token Locally
from azure.identity import ClientSecretCredential
credential = ClientSecretCredential(
tenant_id=TENANT_ID,
client_id=BLUEPRINT_APP_ID, # Blueprint's appId
client_secret=SECRET_TEXT, # From step 1
)
token = credential.get_token(f"api://{BLUEPRINT_APP_ID}/.default")Key Rules (Client Secret)
Save
secretTextimmediately — it cannot be retrieved after creation.Secrets belong on the Blueprint only — agent identities cannot have password credentials (
PropertyNotCompatibleWithAgentIdentity).NOT for production — use Managed Identity + WIF in production.
Respect org policy — if
endDateTimeexceeds your tenant's credential lifetime policy, reduce it.Use
ClientSecretCredential, notDefaultAzureCredential. Azure CLI tokens containDirectory.AccessAsUser.Allwhich is rejected by Agent ID APIs.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs a command-line tool, Needs Python
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/skills · .github/skills/entra-agent-id · commit 0696600
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Microsoft or Microsoft.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download entra-agent-id.zip