Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 19 of 30
❮Prev Next❯

Create and Test an Agent in the Foundry Portal

Module 2: Microsoft Foundry ⏱ 8 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    An agent in Microsoft Foundry is a model + instructions + tools that can plan, call a tool, look at the result and then answer. In the Foundry portal you go to Agents, create an agent, give it a name, pick a model deployment, write its instructions, add knowledge (file search) and tools such as code interpreter or web search, then chat with it in the agent playground. Every save creates a new version of the agent.

    Simulate it » No Azure account needed

    Exam objective: 2.1.4 Create and test a single-agent solution in the Foundry portal. (Skills measured as of April 15, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    Azure portal: Create and test an agent Create an agent, add a tool and test it in the agent playground.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    Go to <strong>Build ➜ Agents</strong> and create a new agent.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. Go to Build ➜ Agents and create a new agent.
    2. Name it, pick the model deployment and write clear instructions: role, rules and limits.
    3. Add knowledge (file search over your policy) and tools (code interpreter, a function that checks orders). Saving creates version 2.
    4. Test it in the agent playground with a question that needs two tools.
    5. Open the trace: the agent planned, called each tool, read the results and wrote one answer. That loop is what makes it agentic.

    🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.

    😟 THE PROBLEM

    Support wants a bot that checks orders and applies the refund policy.

    😊 THE SOLUTION

    Create an agent with instructions, knowledge and tools, then test it.

    • Policy lives in a PDF✓ File search
    • Order status in another system✓ A function tool
    • Will it behave?✓ Agent playground and traces
    🛠️ Solved with: Foundry Agent Service

    Start with a question

    What if your chatbot could look things up and do sums before it replied?

    Ask a plain chat model “How many leave days do I have left if I’ve taken 7 out of our policy’s allowance?” and it’ll guess the policy. It’s never seen your HR handbook.

    Now picture a new hire on the HR desk. They open the handbook, find the allowance, work out the subtraction and then reply. That’s an agent: a model that’s allowed to open files and use tools before it answers.

    Explain it like I’m 10

    The technical explanation

    In Microsoft Foundry an agent is defined by three parts: the model it runs on, the instructions that shape its behaviour, and the tools it may call. Foundry Agent Service runs the loop for you: read the user’s message, decide whether a tool is needed, call it, look at the result, and either call another tool or answer. The conversation keeps the history, so the next question can say “and what about next year?” and the agent knows what “next year” refers to.

    1. 1 You ask

      How many leave days do I have left?

    2. 2 Agent plans

      The model reads its instructions and decides it needs the policy.

    3. 3 Tool call

      File search finds the leave section in the handbook.

    4. 4 Observe

      The model reads the snippet (24 days a year).

    5. 5 Answer

      You have 17 days left, with a note on where that comes from.

    What happens when you send the agent one message

    Building one in the portal

    You need a Foundry project with a chat model already deployed (for example gpt-4.1-mini). Then, in the Foundry portal at ai.azure.com:

    1. Open your project and go to Build → Agents → Create agent.
    2. Give it a name (letters, numbers and hyphens, like hr-helper). Your code will use this name later.
    3. Pick the model deployment it should run on.
    4. Write the instructions. This is the agent’s system prompt: who it is, what it may answer, the tone, and what to do when it doesn’t know.
    5. Add knowledge and tools (below).
    6. Save, then type a question in the agent playground on the right and watch the reply, including which tools it called.
    ToolWhat it gives the agentTypical use
    File searchSearches files you upload (PDF, Word, text)Answer from a policy handbook or product manual
    Azure AI SearchSearches an existing search indexLarge or shared company knowledge bases
    Web search (grounding)Fresh public web results with citationsNews, prices, anything newer than the model
    Code interpreterWrites and runs Python in a sandboxMaths, charts, cleaning an uploaded CSV
    Function callingAsks your app to run a function you described with a JSON schemaLook up an order in your own database
    OpenAPI / MCPCalls an external API or MCP serverBooking systems, ticketing tools

    Good instructions make or break an agent. Say which tool to prefer (“Use the attached handbook for any policy question”), what’s off-topic, and what to say when the answer isn’t in the files. Then test the awkward cases in the playground: an off-topic question, a question the handbook doesn’t cover, and a follow-up that depends on the last turn.

    Versions

    Every time you save, Foundry creates a new version of the agent. A version is immutable: the model, instructions and tools inside it never change. You can compare versions, and apps can keep using a known good one while you try changes. If version 5 starts answering worse, you go back to version 4.

    Architect level Function calling doesn't run your code

    With function calling you describe a function (name, description, parameters as JSON schema). When the model decides it needs it, the response contains a function call with arguments, not a result. Your client app runs the real function, sends the output back, and the agent carries on. That keeps your database credentials in your app, never in the model. In the playground you can type the function’s output by hand to test the flow.

    Real-world business scenario

    Retail

    Contoso Retail India

    The problem
    Store managers phoned head office dozens of times a day with questions about return rules, festival discount limits and stock transfer forms. The answers were all in three long PDFs nobody read.
    What they used
    An agent in a Foundry project running on a gpt-4.1-mini deployment, with the three PDFs attached through file search, code interpreter for discount maths, and instructions to answer only from the files and cite the section.
    Why that choice
    File search keeps answers tied to the real policy, and the playground let the operations team test tricky questions before a developer wrote any code.
    The result
    Managers got answers with a section reference in seconds, and head office calls about policy dropped sharply in the first month.

    When to use it and when not to

    ✓ Use it when…

    • The task needs a model to look something up, calculate or call a system before it answers.
    • You want to prototype and test behaviour in the portal before anyone writes code.
    • Answers must come from your own documents, with the agent saying when it doesn't know.

    ✕ Think twice when…

    • A single prompt-and-reply is enough. A plain chat deployment is simpler and cheaper.
    • The job is a fixed, predictable workflow. Ordinary code or Logic Apps is easier to test.
    • You need guaranteed, exact outputs such as tax calculations without a human check.

    ↔ Alternatives to consider

    • A chat completion with a good system prompt for simple Q&A.
    • Azure Language or Content Understanding when you only need one specific analysis.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the AI-901 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    A human resources team wants an agent in Microsoft Foundry that answers employee questions by using the content of three policy documents that the team uploads.

    Which tool should you add to the agent?

    Question 2

    Question 2 of 5 · Select 2

    Which TWO components must you specify when you create a prompt agent in the Microsoft Foundry portal?

    Question 3

    Question 3 of 5

    You need an agent to calculate totals from a CSV file that a user uploads and to return a chart. Which tool should you add?

    Question 4

    Question 4 of 5

    You modify the instructions of an existing agent in the Microsoft Foundry portal and save the change. What happens?

    Question 5

    Question 5 of 5

    You want to test how an agent responds to questions and which tools it calls before any client application code is written. What should you use?

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner What's the difference between a chat model and an agent?

    Model answer

    A chat model takes a prompt and returns text. An agent wraps a model with instructions and tools, so it can decide to search a file, run some Python or call an API before it answers. It also keeps the conversation going across turns.

    Interviewer follows up

    Does an agent need a deployed model?

    You

    Yes. When you create the agent you pick a model deployment from your project, for example a gpt-4.1-mini deployment. The agent runs on that model.

    Intermediate When would you add file search versus web search to an agent?

    Model answer

    File search when the answers live in your own documents, like an HR policy PDF, because the agent can quote them. Web search when the agent needs fresh public information, like today's exchange rate. I wouldn't use web search for internal policies, the web doesn't have them.

    Experienced developer Why do agent versions matter?

    Model answer

    Each version is a frozen copy of the model, instructions and tools. That means I can test version 4 while version 3 keeps serving users, and roll back if the new instructions make answers worse. It's the same idea as tagging a release in source control.

    Scenario Your agent keeps inventing a return policy. What would you check first?

    Model answer

    I'd check that the policy document is actually attached through file search, and tighten the instructions to say it must answer only from the attached files and say "I don't know" otherwise. Then I'd retest the same question in the playground and look at whether file search was called.

    Quick revision

    Key points

    • An agent = model + instructions + tools. It plans, calls tools, observes results and answers.
    • Create it in the Foundry portal under Agents, inside a project.
    • Knowledge comes from file search (your files) or grounding tools like web search and Azure AI Search.
    • Tools include code interpreter, function calling, OpenAPI and MCP servers.
    • Test in the agent playground. Every save makes a new, immutable version.

    Important terminology

    Agent
    A model plus instructions plus tools that can decide which tool to call, use the result and answer, across several turns.
    Agent playground
    The chat panel in the Foundry portal where you test an agent and see which tools it called.
    File search
    A knowledge tool that indexes files you upload so the agent can quote from them instead of guessing.
    Code interpreter
    A tool that lets the agent write and run Python in a sandbox, for maths, charts and file processing.
    Function calling
    A tool where you describe a function with a JSON schema; the agent asks for it to be called and your code runs it.
    Agent version
    An immutable snapshot of an agent's definition. Each create or update makes a new version.

    Common mistakes

    • Thinking an agent works without a model deployment. It always runs on a deployed model.
    • Expecting function calling to run your code by itself. The agent only asks; your app runs the function.

    Exam tips

    • "Answer from our own PDFs" = file search tool.
    • "Do maths or make a chart from a CSV" = code interpreter tool.
    • "Test the agent before writing any code" = agent playground in the Foundry portal.

    Five quick revision questions

    1. 1.What three things make up an agent?Show

      A model, instructions and tools.

    2. 2.Which tool lets an agent answer from documents you upload?Show

      File search.

    3. 3.Which tool lets an agent run Python?Show

      Code interpreter.

    4. 4.Where do you test an agent in the portal?Show

      The agent playground.

    5. 5.What happens each time you save changes to an agent?Show

      A new version of the agent is created.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: Build a Client App for an Agent

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.