Skip to content

Lab 2: Using Azure AI Foundry Agent Service

Welcome to Lab 2! πŸŽ‰

In this lab, you’ll learn how to build and extend the capabilities of your AI agents using Azure AI Foundry Agent Service.

Info

Azure AI Hub provides a unified interface for managing datasets, models, prompts, and workflows. It streamlines collaboration across teams, ensures compliance and governance, and offers monitoring tools to track the lifecycle of your AI assets from development to production.

Azure Foundry Project is a structured workspace that brings together all the resources, code, and configurations needed to build, train, and deploy AI solutions. It leverages best practices for organizing your AI workloads and integrates seamlessly with Azure AI Hub.


Setting up your environment πŸ”§

  1. Complete the steps in Getting Started to set up your environment.
  2. In this lab, you’ll use Azure AI Foundry Agents to build AI agents. To get started, you’ll need to deploy the required resources to your Azure subscription.

    • Open a terminal and navigate to the root of your project.

    • Log in to your Azure account - Run the following command to authenticate with Azure. This command will prompt you to open a browser and enter a device code displayed in your terminal. After successful authentication, return to the terminal to continue.

      azd auth login --use-device-code
    
    • Create a new environment called dev and set it as the current environment:
    azd env new dev
    azd env select dev
    
    • Set the Azure region for your resources (you can change australiaeast to your preferred region):
    azd env set AZURE_LOCATION australiaeast
    
    • Deploy the Azure resources using the Infrastructure as Code (IaC) files in the infra directory:
    azd up
    

    This command will provision all the necessary Azure resources required for this lab. You can browse the resources in the Azure portal once the deployment is complete.

  3. You will be connecting to these resources when running the code in this lab.

    After deployment, copy all environment variables from .azure/dev/.env into the .env file in the root of your code repository.

    cp .azure/dev/.env .env
    
  4. In this lab, you will make external API calls from your AI agent to a mock service called Contoso Store API which simulates a store's backend operations.

    The Contoso Store API is already deployed as part of the Azure resources you set up in the previous step.

    For your agent to interact with this API, you need to update the API specification (Swagger file) with the correct endpoint URL:

    • Got to swagger.json file in the resources directory of your project.
    • Replace <APP-SERVICE-URL> with the actual URL of the Contoso Store API.

      You can find this URL in your .env file under the variable name CONTOSO_STORE_API_URL.

      contoso-api.png


Let's get started πŸ‘©β€πŸ’»πŸ€–

You’re now ready to start building AI agents using Azure AI Foundry Agent Service!

Start your first exercise for this lab here:

πŸ‘‰ LAB 2.1 : Code First Agent in Azure AI Foundry Agent Service

Happy coding!

Info

The samples uses DefaultAzureCredential to authenticate with Azure services. This would check for environment variables, managed identity, or Azure CLI credentials to authenticate.

When running from VS Code, ensure you have the logged-in Azure account by running:

az login --use-device-code

Further Reading πŸ“š