Blogs

Building AI Agents on Microsoft Foundry

What is Microsoft Foundry?

Microsoft Foundry (ai.azure.com) is Microsoft's studio for building AI applications. From a single place you deploy models, create agents, connect your own data, add tools, and ship to production - no separate infrastructure to wire up.

The key choice is how you create the agent. Foundry offers two paths: Build an agent (the Prompt Agent) and Code an agent (the Hosted Agent). This post covers both - and how to set each one up.

 

Microsoft Foundry Screen

 

Two Ways to Build an Agent

Prompt Agent - you configure everything in the portal: instructions, tools, and knowledge.

Hosted Agent - your own Python code runs as a container inside Foundry.

Which one should you pick? Here is the short version:

Prompt Agent
Hosted Agent
When to use
Quick assistants, internal Q&A, and prototypes - when no custom code is needed.
When you need your own code: custom tools, libraries, RAG, or special logic.
Advantages
No code; add knowledge, memory and tools in a few clicks; nothing to host; lowest cost.
Full control; run your own code and libraries; custom tools and RAG; framework-agnostic.
Disadvantages
You cannot run your own code or libraries; limited to portal options.
A container to run and a deploy step; a small fixed add-on cost; a brief cold start on the first message.

Creating Your Foundry Project

Before building any agent, you create a project - the workspace that holds your agents, models, tools, and knowledge. Give it a name and, under advanced options, choose the region. We picked East US 2, since hosted agents are region-limited and not available everywhere.

 

Creating Your Foundry Project

 

Once the project is created, its home screen gives you the two paths - Build an agent and Code an agent - along with the project endpoint and model selection.

 

Build an Agent

Setup 1: Build an Agent (Prompt Agent)

You can configure everything through the portal.

  1. Open ai.azure.com and select (or create) your project.
  2. Go to Agents -> New agent -> Build an agent.
  3. Write the Instructions - the agent's behavior and rules.
  4. Add Tools and Knowledge (web search, file upload, etc.) as needed.
  5. Test it in the Playground.
  6. Connect from your app via the project endpoint and Responses API.

Build an Agent

Setup 2: Code an Agent (Hosted Agent)

Here you write code and deploy it as a container. Foundry handles the hosting; you use the Azure Developer CLI (azd).

  1. Install the Azure Developer CLI (azd).
  2. In Agents -> New agent -> Code an agent, copy the commands shown.
  3. Run azd ai agent init to download a sample and scaffold the project (azure.yaml, the infra files, the Dockerfile, and the agent code).
  4. Customize the code - add your own tools, instructions, and RAG.
  5. Run azd up to build the container and deploy it to Foundry, provisioning any missing resources automatically.
  6. The agent appears in the Agents list with type hosted, next to any prompt agents.

Code an Agent

 

Code an Agent 2

Example: A Sample Hosted Agent

Here is a sample hosted agent that combines RAG, custom tools, and memory - running on the gpt-5.4-mini model. A single user message can trigger several tools at once.

 

A Sample Hosted Agent

 

The trace shows exactly what ran: file search over the MDP document, exchange_rate, and get_weather each appear as a separate step before the model writes the final answer.

 

A Sample Hosted Agent2

Evaluating the Agent

Foundry has a built-in Evaluations feature to test the agent automatically - quality, tool use, and safety - with no separate test harness. You pick the target agent, the test data (synthetic, an existing dataset, or real traces), and the evaluators; it then runs and reports a pass rate per metric.

 

Evaluating the Agent

 

Monitoring and Cost on Azure

Every resource lives in an Azure resource group, the Monitor dashboard reports agent runs, token usage, and estimated cost out of the box.

 

Monitoring and Cost on Azure

 

Azure Cost Management then breaks the spend down by service and resource - set a budget on the resource group to catch surprises early.

 

Azure Cost Management

 

Conclusion

Microsoft Foundry makes building AI agents approachable from both ends. If you just need a quick assistant, a Prompt Agent gives you knowledge, memory, and tools in a few clicks. When you outgrow that and need your own code, custom tools, or tailored RAG, a Hosted Agent gives you full control on the same platform - with hosting, identity, evaluations, and cost tracking handled for you.


Similar
Blog

Your mail has been sent successfully. You will be contacted as soon as possible.

Your message could not be delivered! Please try again later.