Skip to content

LAB 2.1 : Code First Agent in Azure AI Foundry Agent Service

Navigate to the notebooks/ai-foundry/ai-foundry-basic.ipynb notebook in your code repository to start this lab.

This exercise is about creating a code-first agent in Azure AI Foundry Agent Service using Semantic Kernel.

You will create a customer service agent for Contoso, which will assist customers with inquiries about products, order status, returns, and general support.


Using Azure AI Foundry Portal

After completing the lab using the notebook, you can also create an agent directly in the Azure AI Foundry Portal.

Follow the step-by-step instructions to create a new agent. Use the agent details (name, description, instructions) from the notebook as needed.

Create a New Agent in Azure AI Foundry Portal

  1. Navigate to https://ai.azure.com and sign in with your Azure credentials.

Foundry Project

  1. Create a New Agent

    • Select your Azure AI Foundry project from the dashboard.
    • Click on the Agents tab in the left navigation pane. Then click on + New agent.
    • Enter the agent details:
      • Agent Name: Use a meaningful name (e.g. ContosoCustomerServiceAgent-Portal).
      • Description: Provide a brief description of the agent's purpose.
        This agent assists customers with inquiries about products, 
        order status, returns, and general support.
        
      • Instructions: Copy the system instructions below or use your own.
        You are a helpful assistant for Contoso Bikes.
        Answer questions about company policies, especially the 
        return policy, using the provided documentation.
        If a question is not covered by the documentation, 
        politely inform the user.
        
      • Model: Select gpt-4o as the model for the agent.
      • Knowledge: Click Add and upload contoso-bikes.pdf file present in the resources folder of your code repository.
  2. Test your Agent - Click Try in Playground to test your agent in the playground.

    Try the following questions:

    What is the return policy for Contoso Bikes?.
    
    Can I change my order after it has been placed?
    

Agents Playground

When you interact with your agent a new thread is created in the Azure AI Foundry Agent Service. Further interactions with the agent will continue in the same thread as a new run. You can view this by clicking on the Thread Logs tab in the agent details page.

Agents Thread Logs

For more details, see Concepts: Threads, Runs, and Messages.

Run and Thread Model


Further Reading 📚