Prerequisites
Set up variables
The REST API examples in this article useaz rest to call the Foundry Agent Service endpoints directly. Set the following variables before running the commands:
The
--resource parameter is required for all az rest calls to Foundry Agent Service data-plane endpoints. Without it, az rest can’t derive the correct Azure AD audience from the URL and authentication fails.View agents and versions
Use the following commands to list agents and inspect version details.List all agents in a project
Get agent details
Get a specific version
List all versions of an agent
Create a new version
Create a new agent version when you need to update the container image, change resource allocation, or modify environment variables.Version status values
After you create or update an agent version, poll the version endpoint until the status reachesactive:
| Status | Description |
|---|---|
creating | Infrastructure is being provisioned (typically 2-5 minutes). |
active | Agent is ready to serve requests. |
failed | Provisioning failed. Check the error field in the response for details. |
deleting | Version is being cleaned up. |
deleted | Version has been fully removed. |
Delete an agent
You can delete a specific version or an entire agent with all its versions.Delete a specific version
Delete an agent and all versions
View logs and monitor
Access container logs for debugging provisioning and runtime issues.Example log output
Configure agent endpoint routing
Agent endpoints control how traffic is distributed across agent versions. Use version selectors to route a percentage of traffic to specific versions, enabling canary deployments or gradual rollouts.Retrieve the agent identity for role assignments
Each Hosted agent has an instance identity — a Microsoft Entra ID service principal that the agent uses at runtime to authenticate to downstream resources. To grant the agent access to services such as Azure Storage or Azure Cosmos DB, you need the identity’s principal ID so you can create RBAC role assignments. For more information on how agent identities work, see Agent identity concepts.Extract the agent identity principal ID
Assign roles to the agent identity
After you have the principal ID, assign RBAC roles to the agent identity at the appropriate resource scope. Use--assignee-object-id with --assignee-principal-type ServicePrincipal to avoid Microsoft Graph lookup issues with agent identity service principals.
The agent identity works with any Azure resource that supports RBAC. The following examples show two common scenarios: granting access to the Foundry project and granting access to a storage account.