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:

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.

Learn more →

Create the project in the portal

  1. In a web browser, open the Foundry portal at https://ai.azure.com and 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.

  2. In the top banner, select Start building.

  3. When prompted, create a new project and enter a valid name (for example, agents-lab-project).

  4. 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.

  5. Select Create and wait for your project to be created. When prompted, continue through the welcome dialog and select Create agent.

  6. Set the Agent name to caldova-agent and create the agent. The playground opens with a deployed model already selected for you.

  7. Raise the model’s rate limit. In the left pane, select Models, select the deployed caldova-agent model, 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_exceeded errors.

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.

  1. Install the Azure Developer CLI.

  2. From the Labfiles/A-build-and-extend-ai-agents folder, run:

     azd auth login
     azd up
    
  3. Answer the prompts (environment name, region). When it finishes, azd writes PROJECT_ENDPOINT and MODEL_DEPLOYMENT_NAME into Python/.env for 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.py from the Python folder after azd up to create it. When you’re done with the lab, run azd down to delete everything it created.

Get the starter code

  1. In VS Code, open the Command Palette (Ctrl+Shift+P), run Git: Clone, and enter:

     https://github.com/MicrosoftLearning/mslearn-ai-agents.git
    
  2. 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 .env throughout.

  3. 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
    
  4. Open the .env file and set PROJECT_ENDPOINT to your project endpoint and MODEL_DEPLOYMENT_NAME to your model deployment name. Save the file. (If you used azd 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 install and 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