Getting started
Prepare the shared cloud resources and local Python environment for the Build and extend AI agents lab. Complete this setup once before starting a task.
The case
Caldova is a pharmaceutical manufacturer preparing an early product launch. Its three factories cannot produce everything the launch requires, so you will build a supply chain assistant to help the planning team evaluate its options.
Before you add capabilities to the assistant, you need a Microsoft Foundry project, a deployed model, and the starter code. You reuse this setup throughout the lab, whether you complete one task or the full sequence.
Note: Some of the technologies used in this lab are in preview or in active development. You may experience some unexpected behavior, warnings, or errors.
Prerequisites
Before starting, ensure you have:
- An Azure subscription with sufficient permissions and quota to provision Azure AI resources
- Visual Studio Code installed on your local machine
- Python 3.13 installed
- Git installed on your local machine
- Basic familiarity with Python
Note: Python 3.14 isn’t supported yet because some dependencies have no 3.14 build. This lab was tested with Python 3.13.12.
Create a Microsoft Foundry project
You need a Foundry project and a deployed model for every code task. You can create these
in the portal (the default), or provision them with one command using the Azure Developer
CLI (azd).
What is a Microsoft Foundry project?
A Microsoft Foundry project is a workspace for building and managing an AI application. It gives you one place to work with the application’s agents, models, tools, and evaluations. In this lab, the project contains the model deployment and agents used by the Caldova assistant.
Create the project in the portal
-
In a web browser, open the Foundry portal at
https://ai.azure.comand sign in using your Azure credentials. Close any tips or quick start panes, and if necessary use the Foundry logo at the top left to navigate to the home page.Important: For this lab, you’re using the New Foundry experience.
-
In the top banner, select Start building.
-
When prompted, create a new project and enter a valid name (for example,
agents-lab-project). - Expand Advanced options and specify:
- Microsoft Foundry resource: A valid name for your Foundry resource
- Region: Select one available near you*
- Subscription: Your Azure subscription
- Resource group: Select or create a resource group
* Some Azure AI resources are constrained by regional model quotas. If you hit a quota limit later, you may need to create another resource in a different region.
-
Select Create and wait for your project to be created. When prompted, continue through the welcome dialog and select Create agent.
-
Set the Agent name to
caldova-agentand create the agent. The playground opens with a deployed model already selected for you. -
Raise the model’s rate limit. In the left pane, select Models, select the deployed
caldova-agentmodel, select details tab, and select Edit. Set Tokens per minute rate limit to 100,000 and save.Important: The default rate limit is often too low for the tool-calling tasks in this lab. Reasoning models such as gpt-5 and the remote MCP server in Task 2 use many tokens per request, which can cause
429 rate_limit_exceedederrors.
Keep this browser tab open — you’ll use it in Task 1.
Provision with azd
Choose this option if you prefer to set up the Azure resources from the terminal. The
included azd template creates the Foundry resource, project, and model deployment for you.
-
Install the Azure Developer CLI.
-
From the
Labfiles/A-build-and-extend-ai-agentsfolder, run:azd auth login azd up -
Answer the prompts (environment name, region). When it finishes,
azdwritesPROJECT_ENDPOINTandMODEL_DEPLOYMENT_NAMEintoPython/.envfor you.Note: These commands create the Azure resources, but they don’t create the grounded agent used in Task 1. If you’re starting at Task 3, run
python ../setup/bootstrap_agent.pyfrom thePythonfolder afterazd upto create it. When you’re done with the lab, runazd downto delete everything it created.
Get the starter code
-
In VS Code, open the Command Palette (Ctrl+Shift+P), run Git: Clone, and enter:
https://github.com/MicrosoftLearning/mslearn-ai-agents.git -
Open the cloned repo, then File > Open Folder and select
mslearn-ai-agents/Labfiles/A-build-and-extend-ai-agents/Python. This single folder holds the starter code for every task in this lab — you use one virtual environment and one.envthroughout. -
Right-click requirements.txt and choose Open in Integrated Terminal. Then create a virtual environment and install packages:
python -m venv labenv .\labenv\Scripts\Activate.ps1 pip install -r requirements.txt -
Open the .env file and set
PROJECT_ENDPOINTto your project endpoint andMODEL_DEPLOYMENT_NAMEto your model deployment name. Save the file. (If you usedazd up, these are already filled in.)Tip: In the Foundry Toolkit VS Code extension, right-click your project deployment and select Copy Project Endpoint to get the endpoint URL.
Check you’re ready for a task
Each task needs specific values in your .env. Before starting a task, run the preflight
check from the Python folder you opened in VS Code — it reads your .env and
tells you what (if anything) is missing:
python ../setup/check_env.py --task 2
Swap 2 for the task number you’re about to start.
Tip: The preflight check uses only the Python standard library, so it’s safe to run before
pip installand without the virtual environment active.
That’s it — head to any task:
| Task | Page |
|---|---|
| Task 1 – Create and ground an agent (portal) | A1 |
| Task 2 – Connect a remote MCP server | A2 |
| Task 3 – Call your agent from a client app | A3 |
| Task 4 – Add custom function tools | A4 |
| Task 5 – Capstone: build your own MCP server | A5 |
| Task 6 – Promote your assistant to a hosted agent | A6 |