Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
After you create an agent identity blueprint, the next step is to create one or more agent identities that represent AI agents in your tenant. Agent identity creation is typically performed when provisioning a new AI agent.
You can create agent identities in two ways:
- Microsoft Entra admin center — Use the admin center wizard for quick, individual identity creation.
- Microsoft Graph API — Build a web service that creates agent identities programmatically, which is useful for automated provisioning at scale.
If you want to quickly create agent identities for testing purposes, consider using this Microsoft Entra PowerShell module for creating and using agent identities.
Prerequisites
To create agent identities, you need:
- An agent identity blueprint. Record the agent identity blueprint app ID from the creation process.
- A web service or application (running locally or deployed to Azure) that hosts the agent identity creation logic. This prerequisite applies only if you're creating agent identities programmatically.
Use the Microsoft Entra admin center
You can create an agent identity directly in the Microsoft Entra admin center by selecting an existing blueprint and assigning owners and sponsors.
Sign in to the Microsoft Entra admin center.
Browse to Entra ID > Agents > Agent identities.
Select New agent identity (Preview).
On the Basics tab:
On the Owners & Sponsors tab, optionally add owners and sponsors for the identity:
- Select the pencil icon next to the Owners field to change or add users who can manage this agent identity.
- Select the pencil icon next to the Sponsors field to change or add users who can sponsor this agent identity.
Note
Sponsors can be users, dynamic membership groups, or Microsoft 365 groups. Security groups and role-assignable groups are not supported as sponsors.
Select Next.
Review your settings, and then select Create.
Select Done to exit the wizard or Go to agent identity to view the identity's detail page or configure more settings.
In the following steps, you'll learn how to create agent identities programmatically using Microsoft Graph API and Microsoft.Identity.Web. Get an access token first, then call the creation API.
Get an access token using agent identity blueprint
You use the agent identity blueprint to create each agent identity. Request an access token from Microsoft Entra using your agent identity blueprint:
When using a managed identity as a credential, you must first obtain an access token using your managed identity. Managed identity tokens can be requested from an IP address locally exposed in the compute environment. Refer to the managed identity documentation for details.
GET http://169.254.169.254/metadata/identity/oauth2/token?api-version=2019-08-01&resource=api://AzureADTokenExchange/.default
Metadata: True
After you obtain a token for the managed identity, request a token for the agent identity blueprint:
POST https://login.microsoftonline.com/<my-test-tenant>/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
client_id=<agent-blueprint-id>
scope=https://graph.microsoft.com/.default
client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer
client_assertion=<msi-token>
grant_type=client_credentials
A client_secret parameter can also be used instead of client_assertion and client_assertion_type, when a client secret is being used in local development.
Create an agent identity
Using the access token acquired in the previous step, you can now create agent identities in your tenant. Agent identity creation might occur in response to many different events or triggers, such as a user selecting a button to create a new agent. We recommend you create one agent identity for each agent, but you might choose a different approach based on your needs.
Always include the OData-Version header when using @odata.type.
POST https://graph.microsoft.com/beta/serviceprincipals/Microsoft.Graph.AgentIdentity
OData-Version: 4.0
Content-Type: application/json
Authorization: Bearer <token>
{
"displayName": "My Agent Identity",
"agentIdentityBlueprintId": "<my-agent-blueprint-id>",
"sponsors@odata.bind": [
"https://graph.microsoft.com/v1.0/users/<id>",
"https://graph.microsoft.com/v1.0/groups/<group-id>"
],
}
Note
When assigning a group as sponsor, only supported group types are accepted. Groups aren't supported as owners.
Delete an agent identity
When an agent is deallocated or destroyed, your service should also delete the associated agent identity:
DELETE https://graph.microsoft.com/beta/serviceprincipals/<agent-identity-id>
OData-Version: 4.0
Content-Type: application/json
Authorization: Bearer <token>