Exercise - Develop an Azure AI agent with the Microsoft Agent Framework SDK
Unit 5 of 6 · Module 13: Develop an AI agent with Microsoft Agent Framework
Read this lesson
The plan
In this lab, you'll build an expense claim agent with Agent Framework. You'll need VS Code, Python, Git, and an Azure subscription, and it takes about thirty minutes. In VS Code, install the Foundry Toolkit extension, create a Foundry project, deploy a gpt-5 model, and copy the project endpoint. Clone the lab repository, install the packages, and put the endpoint and model name in the dot env file.
The code
Open agent-framework.py. It already loads three receipts from a data file, a taxi, a dinner, and a hotel, and asks what you'd like done with them. First, add the imports: tool and Agent from agent_framework, the Foundry chat client, the Azure CLI credential, and Field and Annotated for describing parameters. Then write the tool: a function called submit_claim, marked with the tool decorator, that takes who the email goes to, a subject, and a body. It just prints the email, pretending to send it. Next, create a Foundry chat client with your endpoint, model, and credential. Create an agent called ExpenseClaimAgent, with instructions to itemize the expenses with a total and email them to the expenses team, and pass it your tool. Finally, run the agent with your prompt and the data, and print its reply.
Run it
Sign in with az login, run the script, and when it asks, type: submit an expense claim. You should see the email the agent wrote through your tool, followed by its confirmation. When you're done, delete the model deployment and the resource group. Before the real thing, practice in the Coding exercise, where the same code runs against a simulated Foundry project.
Facts from Microsoft's documentation: Microsoft Agent Framework Overview (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.