Create and Test an Agent in the Foundry Portal
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 neededExam 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.
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
- Go to Build ➜ Agents and create a new agent.
- Name it, pick the model deployment and write clear instructions: role, rules and limits.
- Add knowledge (file search over your policy) and tools (code interpreter, a function that checks orders). Saving creates version 2.
- Test it in the agent playground with a question that needs two tools.
- 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.
🖱️ Drag to rotate · scroll or pinch to zoom
An agent: model + instructions + tools
An agent is a model with instructions and tools that can decide what to do next. Foundry Agent Service keeps the conversation and runs the tools for you.
🤔 What happens if…
Read this tour as text
- Resource and project. A Foundry resource is the Azure resource that holds your models, tools, security and billing. Inside it, a project is the workspace where a team builds one app: its deployments, agents, files and evaluations.
- The model catalog. The model catalog lists thousands of models: OpenAI GPT models, Microsoft Phi, Meta Llama, Mistral, DeepSeek and more. Each has a model card, benchmarks and the deployment types it supports.
- Deploy a model. Before an app can call a model you deploy it and give the deployment a name. Global Standard (pay per token, the default), Data Zone (keeps processing in the US or EU), Provisioned (reserved throughput) and Batch (cheaper, within 24 hours) trade price, speed and data location.
- Test in the playground. The chat playground lets you try a deployment with no code. The system message sets the rules, the user message asks the question, and parameters such as temperature tune the answer.
- Call it from your app. Your Python app uses the Foundry SDK (
azure-ai-projects): connect to the project endpoint with Microsoft Entra ID, get an OpenAI-compatible client and call the deployment by its name. - An agent: model + instructions + tools. An agent is a model with instructions and tools that can decide what to do next. Foundry Agent Service keeps the conversation and runs the tools for you.
- Tools in action. Ask "What is our refund limit, and what is 15% of ₹4,200?" The agent uses file search for the policy and the code interpreter for the maths, then answers in one reply. That loop of plan, act and observe is what makes it agentic.
- Guardrails and monitoring. Every request passes guardrails (content filters) on the way in and out. Tracing and evaluations show what the agent did, how long it took and whether answers are grounded and safe.
Give a model instructions and tools and it becomes an agent. Build a support agent, then watch it pick the right tool for each question.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 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
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 You ask
How many leave days do I have left?
-
2 Agent plans
The model reads its instructions and decides it needs the policy.
-
3 Tool call
File search finds the leave section in the handbook.
-
4 Observe
The model reads the snippet (24 days a year).
-
5 Answer
You have 17 days left, with a note on where that comes from.
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:
- Open your project and go to Build → Agents → Create agent.
- Give it a name (letters, numbers and hyphens, like
hr-helper). Your code will use this name later. - Pick the model deployment it should run on.
- 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.
- Add knowledge and tools (below).
- Save, then type a question in the agent playground on the right and watch the reply, including which tools it called.
| Tool | What it gives the agent | Typical use |
|---|---|---|
| File search | Searches files you upload (PDF, Word, text) | Answer from a policy handbook or product manual |
| Azure AI Search | Searches an existing search index | Large or shared company knowledge bases |
| Web search (grounding) | Fresh public web results with citations | News, prices, anything newer than the model |
| Code interpreter | Writes and runs Python in a sandbox | Maths, charts, cleaning an uploaded CSV |
| Function calling | Asks your app to run a function you described with a JSON schema | Look up an order in your own database |
| OpenAPI / MCP | Calls an external API or MCP server | Booking 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
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.
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.
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.What three things make up an agent?Show
A model, instructions and tools.
-
2.Which tool lets an agent answer from documents you upload?Show
File search.
-
3.Which tool lets an agent run Python?Show
Code interpreter.
-
4.Where do you test an agent in the portal?Show
The agent playground.
-
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
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.