Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
After you create an agent identity blueprint, the next step is to create one or more agent identities that represent AI agents in your test tenant. Agent identity creation is typically performed when provisioning a new AI agent.
This article guides you through the process of building a simple web service that creates agent identities via Microsoft Graph APIs.
If you want to quickly create agent identities for testing purposes, consider using this Microsoft Entra PowerShell module for creating and using agent identities.
Important
Microsoft Entra Agent ID is currently in PREVIEW. This information relates to a prerelease product that may be substantially modified before it's released. Microsoft makes no warranties, expressed or implied, with respect to the information provided here.
Prerequisites
Microsoft Entra Agent ID is part of Microsoft Agent 365. Both are available through the Frontier program in Microsoft 365. To access these features you must have a license for Microsoft 365 Copilot and have enabled Frontier for your users.
Follow the Frontier getting started guide or use the following steps to check if Frontier is enabled:
- Sign in to the Microsoft 365 admin center as a Billing Administrator.
- Browse to Copilot > Settings > User access > Copilot Frontier and make sure it's enabled for users. If you don't see these options, contact your administrator to check your Microsoft 365 Copilot licensing.
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.
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 test 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/<id>"
],
}
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>