This project demonstrates a practical Agent2Agent (A2A) scenario using the eShopLite sample as a foundation. The implementation showcases how multiple autonomous agents (microservices) can collaborate to fulfill complex business requests through the official Microsoft A2A .NET SDK.
- A2A .NET SDK Integration: Leverages the A2A NuGet package for agent-to-agent communication.
- Three Autonomous Agents: Inventory, Promotions, and Researcher agents, each with dedicated APIs and A2A message handlers.
- Orchestration Service: The Products API orchestrates agent calls in parallel, aggregates results, and returns enriched product data.
- Blazor Frontend: Store application with a search page supporting A2A search and enhanced results display.
- Aspire Integration: Uses .NET Aspire for service orchestration and deployment.
- Comprehensive Unit Tests: Validates A2A orchestration and agent interactions.
- Store (Frontend): Blazor web application providing the user interface.
- Products API: Main backend API that orchestrates agent communication using the A2A .NET SDK.
- Three Autonomous Agents:
- Inventory Agent: Provides real-time stock levels.
- Promotions Agent: Supplies active promotions and discounts.
- Researcher Agent: Delivers product insights and reviews.
┌────────────┐ ┌──────────────┐ ┌────────────────────┐
│ Store UI │─────▶│ Products API │─────▶│ A2A Orchestration │
└────────────┘ └──────────────┘ └─────────┬──────────┘
│
┌───────────────────────────────┬───────────┴───────────────┐
│ │ │
┌───────────────┐ ┌────────────────┐ ┌──────────────────┐
│ Inventory │ │ Promotions │ │ Researcher │
│ Agent │ │ Agent │ │ Agent │
└───────────────┘ └────────────────┘ └──────────────────┘
User
│
│ 1. Search (A2A)
▼
Store (UI)
│
│ 2. /api/a2asearch/{search}
▼
Products API
│
│ 3. Find products
│
│ 4. For each product:
│ ├─▶ InventoryAgent.HandleInventoryCheckAsync
│ ├─▶ PromotionsAgent.HandlePromotionsAsync
│ └─▶ ResearcherAgent.HandleInsightsAsync
│
│ 5. Aggregate responses
▼
Store (UI)
│
│ 6. Display enriched results
- A2A .NET SDK: GitHub | NuGet | Overview Blog
- Agent Skills: Each agent defines its capabilities using
AgentSkill. - Message Handling: Agents implement message handlers (e.g.,
HandleInventoryCheckAsync) to process A2A messages. - Parallel Calls: The Products API orchestrates parallel calls to all agents and aggregates their responses.
- Service Registration: Agents and orchestration services are registered in the DI container.
- .NET 10
- Git
- Azure Developer CLI (azd)
- Visual Studio Code or Visual Studio
- If using Visual Studio Code, install the C# Dev Kit
- .NET Aspire workload (setup guide)
- Docker Desktop or Podman
- .NET Aspire CLI (
dotnet tool install -g aspire.cli) — used to set local secrets
This scenario reads its Azure OpenAI configuration from Aspire AppHost parameters. Set them as local
secrets with the aspire secret command,
targeting this scenario's AppHost project:
aspire secret set Parameters:AzureOpenAIEndpoint "https://<your-resource>.openai.azure.com/" --apphost ./src/eShopAppHost/eShopAppHost.csproj
aspire secret set Parameters:AzureOpenAIApiKey "<your-api-key>" --apphost ./src/eShopAppHost/eShopAppHost.csproj
aspire secret set Parameters:AzureOpenAIDeploymentName "gpt-4.1-mini" --apphost ./src/eShopAppHost/eShopAppHost.csproj
aspire secret set Parameters:AzureOpenAIEmbeddingsDeploymentName "text-embedding-3-small" --apphost ./src/eShopAppHost/eShopAppHost.csprojTip: run
scripts\Set-AzureOpenAISecrets.ps1from the repo root to set these four common Azure OpenAI values for every scenario at once (use-DryRunto preview).
-
Navigate to the AppHost project:
cd ./src/eShopAppHost/ -
(Codespaces only) Trust HTTPS dev certs:
dotnet dev-certs https --trust
-
Run the solution:
dotnet run
-
Open the Store app in your browser, go to the Search page, select "A2A Search (Agent-to-Agent)", and search for products.
-
Login to Azure:
azd auth login
-
Provision and deploy resources:
azd up
-
Follow the prompts for environment name, subscription, and region.
-
When deployment completes, visit the Store URI to use the app.
{
"response": "Found X products enriched with inventory, promotions, and insights data.",
"products": [
{
"productId": "1",
"name": "Product Name",
"description": "Product Description",
"price": 99.99,
"imageUrl": "image.jpg",
"stock": 42,
"promotions": [
{ "title": "Special Offer", "discount": 15 }
],
"insights": [
{ "review": "Great product!", "rating": 4.5 }
]
}
]
}- A2A .NET SDK GitHub
- A2A .NET SDK NuGet
- A2A .NET SDK Overview Blog
- eShopLite Main Repository
- Deploy a .NET Aspire project to Azure Container Apps using the Azure Developer CLI (in-depth guide)
This scenario is part of the eShopLite sample, demonstrating advanced agent orchestration patterns for .NET developers using the official A2A .NET SDK.