Option
HeimHeim Skill Sicherheit entra-agent-id

entra-agent-id

microsoft/skills microsoft/skills

Erstellen und verwalten Sie OAuth2-fähige Identitäten für KI-Agenten mithilfe der Microsoft Graph Beta-API.

...Alle erweitern
23
Zeit aktualisiert 10. September 2026

Microsoft Entra-Agent-ID

Erstellen und verwalten Sie OAuth2-fähige Identitäten für KI-Agenten mithilfe der Microsoft Graph Beta-API.

Vorschau-API – Alle Endpunkte für Agentenidentitäten befinden sich ausschließlich unter /beta nur. Nicht verfügbar in /v1.0.

Bevor Sie beginnen

Suchen microsoft-docs im MCP nach der neuesten Dokumentation zu Agentenidentitäten:

  • Abfrage: „Microsoft Entra Agent Identity Setup“
  • Überprüfen Sie, ob die API-Parameter dem aktuellen Preview-Verhalten entsprechen

Konzeptionelles Modell

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-3

Voraussetzungen

PowerShell (empfohlen für die interaktive Einrichtung)

# Requires PowerShell 7+
Install-Module Microsoft.Graph.Beta.Applications -Scope CurrentUser -Force

Python (für die programmgesteuerte Bereitstellung)

pip install azure-identity requests

Erforderliche Entra-Rollen

Eine der folgenden Rollen: Agent Identity Developer, Agent Identity Administrator oder Application Administrator.

Umgebungsvariablen

AZURE_TENANT_ID=
AZURE_CLIENT_ID=
AZURE_CLIENT_SECRET=

Authentifizierung

⚠️ „DefaultAzureCredential“ wird NICHT unterstützt. Azure-CLI-Token enthalten Directory.AccessAsUser.All, was von den Agent-Identity-APIs ausdrücklich abgelehnt wird (403). Sie MÜSSEN eine dedizierte App-Registrierung mit client_credentials Flow oder eine Verbindung über Connect-MgGraph mit explizit delegierten Bereichen verbinden.

PowerShell (delegierte Berechtigungen)

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).Id

Python (Anwendungsberechtigungen)

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
}

Kern-Workflow

Schritt 1: Blueprint für die Agentenidentität erstellen

Sponsoren sind erforderlich und müssen Benutzerobjekte sein – ServicePrincipals und Gruppen werden abgelehnt.

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"]

Schritt 2: BlueprintPrincipal erstellen

Dieser Schritt ist obligatorisch. Durch das Erstellen eines Blueprints wird dessen Service Principal NICHT automatisch erstellt. Ohne diesen Schritt schlägt die Erstellung der Agent-Identität mit folgender Fehlermeldung fehl: 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()

Bei der Implementierung idempotenter Skripte sollte geprüft und der „BlueprintPrincipal“ erstellt werden, selbst wenn der Blueprint bereits existiert (möglicherweise wurde der Blueprint bei einem früheren Durchlauf erstellt, der jedoch vor der Erstellung des Service Principals abgestürzt ist).

Schritt 3: Agent-Identitäten erstellen

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-Referenz

Operation Methode Endpunkt OData-Typ
Blueprint erstellen POST /applications Microsoft.Graph.AgentIdentityBlueprint
BlueprintPrincipal erstellen POST /servicePrincipals Microsoft.Graph.AgentIdentityBlueprintPrincipal
Agentenidentität erstellen POST /servicePrincipals Microsoft.Graph.AgentIdentity
Agentenidentitäten auflisten GET /servicePrincipals?$filter=...
Agentenidentität löschen DELETE /servicePrincipals/{id}
Blueprint löschen DELETE /applications/{id}

Alle Endpunkte verwenden die Basis-URL: https://graph.microsoft.com/beta

Erforderliche Berechtigungen

Berechtigung Zweck
Application.ReadWrite.All Blueprint-CRUD (Anwendungsobjekte)
AgentIdentityBlueprint.Create Neue Blueprints erstellen
AgentIdentityBlueprint.ReadWrite.All Blueprints lesen/aktualisieren
AgentIdentityBlueprintPrincipal.Create Blueprint-Principals erstellen
AgentIdentity.Create.All Agentenidentitäten erstellen
AgentIdentity.ReadWrite.All Agentenidentitäten lesen/aktualisieren

Es gibt 18 Graph-Anwendungsberechtigungen, die sich speziell auf Agent-Identitäten beziehen. Alle anzeigen:

az ad sp show --id 00000003-0000-0000-c000-000000000000 \
  --query "appRoles[?contains(value, 'AgentIdentity')].{id:id, value:value}" -o json

Administratorzustimmung erteilen (für Anwendungsberechtigungen erforderlich):

az ad app permission admin-consent --id 

Die Administratorzustimmung kann mit dem Fehlercode 404 fehlschlagen, wenn der Dienstprinzipal noch nicht repliziert wurde. Versuchen Sie es erneut mit einer Wartezeit von 10–40 Sekunden.

Bereinigung

# 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)

Bewährte Vorgehensweisen

  1. Erstellen Sie „BlueprintPrincipal“ immer nach „Blueprint“ – es wird nicht automatisch erstellt; führen Sie bei beiden idempotente Prüfungen durch
  2. Verwenden Sie User-Objekte als Sponsoren – ServicePrincipals und Gruppen werden abgelehnt
  3. Berücksichtigen Sie Verzögerungen bei der Berechtigungsweitergabe – warten Sie nach der Administratorzustimmung 30–120 Sekunden; wiederholen Sie den Versuch mit einer Wartezeit bei einem 403-Fehler
  4. Fügen Sie bei jeder Graph-Anfrage den Header „OData-Version: 4.0“ hinzu
  5. Verwenden Sie „Workload Identity Federation“ für die Authentifizierung in der Produktion – für die lokale Entwicklung verwenden Sie ein Client-Secret im Blueprint (siehe references/oauth2-token-flow.md)
  6. Legen Sie „identifierUris“ im Blueprint fest, bevor Sie OAuth2-Scoping verwenden (api://{app-id})
  7. Verwende niemals Azure-CLI-Token für API-Aufrufe – sie enthalten Directory.AccessAsUser.All , was zu einer sofortigen Ablehnung führt
  8. Prüfen Sie vor der Erstellung, ob Ressourcen bereits vorhanden sind – implementieren Sie idempotente Bereitstellung

Referenzen

Datei Inhalt
references/oauth2-token-flow.md Token-Abläufe in der Produktion (Managed Identity + WIF) und in der lokalen Entwicklung (Client-Secret)
references/known-limitations.md 29 bekannte Probleme, nach Kategorien geordnet (aus der offiziellen Preview-Seite „Known Issues“)
references/sdk-sidecar.md Microsoft Entra SDK für AgentID – Endpunkte, 3P-Agent-Muster, Docker-/K8s-Bereitstellung, Sicherheit

Externe Links

Ressource URL
Offizielle Einrichtungsanleitung https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/agent-id-setup-instructions
KI-gestützte Einrichtung https://learn.microsoft.com/en-us/entra/agent-id/identity-platform/agent-id-ai-guided-setup
Microsoft Entra SDK für AgentID – Übersicht https://learn.microsoft.com/en-us/entra/msidweb/agent-id-sdk/overview
Microsoft Entra SDK für AgentID – Endpunkte https://learn.microsoft.com/en-us/entra/msidweb/agent-id-sdk/endpoints
Auf GitHub ansehen
---
name: entra-agent-id
description: Create and manage OAuth2-capable identities for AI agents using Microsoft Graph beta API.
---

# 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 `/beta` only. 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-3
```

## Prerequisites

### PowerShell (recommended for interactive setup)

```powershell
# Requires PowerShell 7+
Install-Module Microsoft.Graph.Beta.Applications -Scope CurrentUser -Force
```

### Python (for programmatic provisioning)

```bash
pip install azure-identity requests
```

### Required Entra Roles

One of: **Agent Identity Developer**, **Agent Identity Administrator**, or **Application Administrator**.

## Environment Variables

```bash
AZURE_TENANT_ID=<your-tenant-id>
AZURE_CLIENT_ID=<app-registration-client-id>
AZURE_CLIENT_SECRET=<app-registration-secret>
```

## Authentication

> **⚠️ `DefaultAzureCredential` is NOT supported.** Azure CLI tokens contain
> `Directory.AccessAsUser.All`, which Agent Identity APIs explicitly reject (403).
> You MUST use a dedicated app registration with `client_credentials` flow or
> connect via `Connect-MgGraph` with explicit delegated scopes.

### PowerShell (delegated permissions)

```powershell
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).Id
```

### Python (application permissions)

```python
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.

```python
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.`

```python
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

```python
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:
```bash
az ad sp show --id 00000003-0000-0000-c000-000000000000 \
  --query "appRoles[?contains(value, 'AgentIdentity')].{id:id, value:value}" -o json
```

Grant admin consent (required for application permissions):
```bash
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

```python
# 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

1. **Always create BlueprintPrincipal after Blueprint** — not auto-created; implement idempotent checks on both
2. **Use User objects as sponsors** — ServicePrincipals and Groups are rejected
3. **Handle permission propagation delays** — after admin consent, wait 30–120s; retry with backoff on 403
4. **Include `OData-Version: 4.0` header** on every Graph request
5. **Use Workload Identity Federation for production auth** — for local dev, use a client secret on the Blueprint (see [references/oauth2-token-flow.md](references/oauth2-token-flow.md))
6. **Set `identifierUris` on Blueprint** before using OAuth2 scoping (`api://{app-id}`)
7. **Never use Azure CLI tokens** for API calls — they contain `Directory.AccessAsUser.All` which is hard-rejected
8. **Check for existing resources** before creating — implement idempotent provisioning

## References

| File | Contents |
|------|----------|
| [references/oauth2-token-flow.md](references/oauth2-token-flow.md) | Production (Managed Identity + WIF) and local dev (client secret) token flows |
| [references/known-limitations.md](references/known-limitations.md) | 29 known issues organized by category (from official preview known-issues page) |
| [references/sdk-sidecar.md](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 |

Alle Dateien

0 Dateien

entra-agent-id installieren

Laden Sie die Skill-Dateien herunter und entpacken Sie sie in Ihr Verzeichnis „.claude/skills/“.

ZIP herunterladen

Klonen Sie das Repository und kopieren Sie die Skill-Dateien in Ihr Projekt.

git clone https://github.com/microsoft/skills/tree/main/.github/skills/entra-agent-id # Copy SKILL.md to your .claude/skills/ directory

Kopieren Kopieren
Schnelle Einrichtung: Kopiere den Skill-Ordner nach .claude/skills/ Claude erkennt den Skill automatisch und nutzt ihn.
Repository microsoft/skills

Ähnliche Skills

gmgn-portfolio
Zeit aktualisiert 1. Juli 2026
zeroize-audit
Zeit aktualisiert 1. Juli 2026
device-integrity
Zeit aktualisiert 29. Juni 2026
flutter-use-http-package
Zeit aktualisiert 30. Juni 2026
OR