LoopAI-103

Exercise - Connect to remote Azure AI Agents with the A2A protocol

Unit 6 of 7 · Module 15: Discover Azure AI Agents with A2A

Before you start

Short explainers for ideas this lesson builds on. Watch these first if they're new to you.

0 of 1 watched · about 2 min
Read this lesson

The plan

In this lab, you'll build the blog team: a title agent, an outline agent, and a routing agent that coordinates them over A2A. You'll need VS Code, Python, Git, and an Azure subscription, and it takes about thirty minutes. Deploy a model in a Foundry project, clone the lab repository, install the packages, and fill in the dot env file. Each agent runs as its own server on its own port, and a client script sends your request to the routing agent.

The code

First, the title agent. Its code creates a Foundry agent that writes headlines, and runs it on a conversation thread when a request arrives. Next, its server. Define a skill for generating blog titles, create the agent card with that skill and the server's URL, create the executor, a request handler with an in-memory task store, and the Starlette application. Then the routing agent. It fetches each remote agent's card, builds a message for the right agent, sends it over A2A, and reads the reply. Its executor marks the task as working, runs the conversation, and marks it complete with the final text.

Run it

Start all the servers with run_all, then run the client, and ask for a blog post, for example about getting started with AI agents. You'll see the routing agent call the title agent, pass the title to the outline agent, and return a title and outline. One thing to know: the lab pins version zero point three of the A2A SDK. Version one point zero renamed a few pieces, like the server application class and the client, but the ideas are exactly the same. When you're done, delete the resource group. Practice first in the Coding exercise, which runs the three servers against a simulated Foundry project.

Facts from Microsoft's documentation: Agent Framework: host agents with A2A (CC BY 4.0), rewritten in Loop's own words and examples. Narration, animation, and quiz by Loop. The coding lab is based on Microsoft's lab files for the agent exercises (MicrosoftLearning/mslearn-ai-agents, MIT License; notice). Microsoft, Azure, and Microsoft Foundry are trademarks of Microsoft. Loop is independent and not affiliated with or endorsed by Microsoft.