Add an A2A agent endpoint to Foundry Agent Service (preview)
Items marked (preview) in this article are currently in public preview. This preview is provided without a service-level agreement, and we don’t recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
For information on optimizing tool usage, see best practices.
- Using the A2A tool: When Agent A calls Agent B through the A2A tool, Agent B’s answer goes back to Agent A. Agent A then summarizes the answer and generates a response for the user. Agent A keeps control and continues to handle future user input.
- Using a multi-agent workflow: When Agent A calls Agent B through a workflow or other multi-agent orchestration, Agent B takes full responsibility for answering the user. Agent A is out of the loop. Agent B handles all subsequent user input. For more information, see Build a workflow in Microsoft Foundry.
Usage support
The following table shows SDK and setup support. A checkmark (✔️) indicates support; a dash (-) indicates the feature isn’t available.| Microsoft Foundry support | Python SDK | C# SDK | JavaScript SDK | Java SDK | REST API | Basic agent setup | Standard agent setup |
|---|---|---|---|---|---|---|---|
| ✔️ | ✔️ | ✔️ | ✔️ | - | ✔️ | ✔️ | ✔️ |
Prerequisites
- An Azure subscription with an active Foundry project.
- A model deployment (for example, gpt-4) in your Foundry project.
- Required Azure role: On the Foundry resource, Contributor or Owner for management and Azure AI User for building an agent.
- SDK installation:
- Python:
pip install azure-ai-projects[agents](latest prerelease) - C#:
Azure.AI.ProjectsNuGet package - TypeScript:
@azure/ai-projectsnpm package
- Python:
- Environment variables configured:
FOUNDRY_PROJECT_ENDPOINT: Your project endpoint URL.FOUNDRY_MODEL_DEPLOYMENT_NAME: Your model deployment name.A2A_PROJECT_CONNECTION_NAME: Your A2A connection name (created in the Foundry portal).A2A_BASE_URI(optional): The base URI for the A2A endpoint.
- An A2A connection configured in your Foundry project. For connection setup and REST examples, see Create an A2A connection.
Create an A2A connection
Create a project connection for your A2A endpoint so you can store authentication securely and reuse it across agent versions. For details about supported authentication approaches, see Agent2Agent (A2A) authentication.Create the connection in the Foundry portal
- Sign in to Microsoft Foundry. Make sure the New Foundry toggle is on. These steps refer to Foundry (new).

- Select Tools.
- Select Connect tool.
- Select the Custom tab.
- Select Agent2Agent (A2A), and then select Create.
- Enter a Name and an A2A Agent Endpoint.
- Under Authentication, select an authentication method. For key-based authentication, set the credential name (for example,
x-api-key) and the corresponding secret value.
Get the connection identifier for code
Store your connection name in theA2A_PROJECT_CONNECTION_NAME environment variable. Your code uses this name to retrieve the full connection ID at runtime:
- Python/C#/TypeScript: Call
project.connections.get(connection_name)to get the connection object, then accessconnection.id. - REST API: Include the connection ID in the
project_connection_idfield of the A2A tool definition.
Verify your connection
Before running the full sample, confirm your environment setup is correct. This verification script checks that your credentials work and the A2A connection exists in your project.Code example
You need the latest prerelease package. See the quickstart for details.
Create an agent with the A2A tool
Expected output
The agent responds with information about the secondary agent’s capabilities, demonstrating successful A2A communication. You see streaming delta text as the response is generated, followed by completion messages. The output includes the follow-up response ID, text deltas, and a final summary of what the secondary agent can do.Create an agent with the A2A tool
This example creates an agent that can call a remote A2A endpoint. For the connection setup steps, see Create an A2A connection.Expected output
The console displays the agent’s response text from the A2A endpoint. After completion, the agent version is deleted to clean up resources.Create an A2A connection by using the REST API
Use these examples to create a project connection that stores your authentication information. To get an access token for the Azure Resource Manager endpoint:Key-based
Managed OAuth Identity Passthrough
This option is supported when you select Managed OAuth in the Foundry tool catalog.Custom OAuth Identity Passthrough
Custom OAuth doesn’t support the update operation. Create a new connection if you want to update certain values. If your OAuth app doesn’t require a client secret, omitClientSecret.
Foundry Project Managed Identity
Agent identity
Add A2A tool to Foundry Agent Service
Create an agent version with the A2A tool
DELETE request to the same endpoint with the agent name and version.
This sample demonstrates how to create an AI agent with A2A capabilities by using the A2ATool and the Azure AI Projects client. The agent can communicate with other agents and provide responses based on inter-agent interactions by using the A2A protocol.
Expected output
The console displays streamed response text as the A2A agent processes the request. You see the follow-up response ID, text deltas printed to stdout, and completion messages. The agent version is deleted after the interaction completes.Troubleshooting
| Issue | Cause | Resolution |
|---|---|---|
| Agent doesn’t invoke the A2A tool | Agent definition doesn’t include A2A tool configuration | Confirm your agent definition includes the A2A tool and that you configured the connection. If you’re using responses, confirm you’re not forcing a different tool. |
| Agent doesn’t invoke the A2A tool | Prompt doesn’t require remote agent | Update your prompt to require calling the remote agent, or remove conflicting tool choice settings. |
| Authentication failures (401 or 403) | Connection authentication type mismatch | Confirm the connection’s authentication type matches your endpoint requirements. For key-based auth, confirm the credential name matches what the endpoint expects (x-api-key or Authorization). |
| SDK sample can’t find the connection | Environment variable mismatch | Confirm A2A_PROJECT_CONNECTION_NAME matches the connection name in Foundry. |
| Network or TLS errors | Endpoint unreachable or invalid certificate | Confirm the endpoint is publicly reachable and uses a valid TLS certificate. Check firewall rules and proxy settings. |
| Remote agent returns unexpected response | Response format incompatibility | Confirm the remote agent follows A2A protocol specifications. Check that response content types match expected formats. |
| Connection timeout | Remote agent slow to respond | Increase timeout settings or verify the remote agent’s performance. Consider implementing retry logic with exponential backoff. |
| Missing A2A tool in response | Tool not enabled for the agent | Recreate the agent with the A2A tool explicitly enabled, and verify the connection is active and properly configured. |