
Sign up to save your podcasts
Or


The AI App Templates let you spin up a working chat application in minutes, complete with AI integration, custom data ingestion, and all the pieces you need to get started. It’s a cool and solid foundation.
But here’s the thing: what if you want to go beyond basic chat? What if you want to build AI agents that can actually reason, make decisions, use tools, and orchestrate complex workflows? That’s where Microsoft Agent Framework comes into play.
In this post, I’m going to show you how I took a standard AI chat app—generated using the .NET AI templates—and enhanced it with Microsoft Agent Framework. Let’s start!
Microsoft Agent Framework is Microsoft’s preview framework for building AI agents in .NET. Think of it as the next evolution beyond simple chatbots. An AI agent can:
What I really like about it is that it’s built on patterns we already know and love as .NET developers: dependency injection, middleware, telemetry—all integrated with Microsoft.Extensions.AI. Check out Luis’ great post about AgentFx for all the details.
Before we start, you’ll need:
Let’s start by creating a baseline chat app using the official .NET AI templates. First, we need to install the templates:
Now let’s create the app. You can do this through Visual Studio or the CLI:
Using Visual Studio:
Using Visual Studio Code or the .NET CLI:
If you prefer VS Code or the command line, check out the official documentation for step-by-step instructions. The process is similar—you’ll use dotnet new commands to scaffold the project with the same configuration options.
The template generates a solution with three projects:
We’ll be working mainly in ChatApp20.Web, which includes:
Let’s look at what the template sets up for us in Program.cs. This is where all the AI pieces come together:
The initial Chat.razor component uses IChatClient directly:
This works great for getting started! But as your app grows, you’ll want more flexibility:
That’s exactly what Microsoft Agent Framework brings to the table. Let’s see how!
Now for the fun part—let’s upgrade this chat app into a proper agent system!
First, we need to add the Microsoft Agent Framework packages to ChatApp20.Web.csproj:
The key Agent Framework packages are:
To promote better separation of concerns and testability, create a new SearchFunctions.cs service that wraps the semantic search functionality:
Why this is important:
Now, let’s configure the AI agent in Program.cs using the Agent Framework’s hosting extensions:
Key points about the agent registration:
Finally, we need to update Chat.razor to use our new AI agent. The changes are pretty straightforward:
Key changes in the code-behind:
That’s it! The agent handles everything else—tool invocation, reasoning, and response generation.
One of the best parts about using the AI templates is that everything runs through .NET Aspire. This gives you:
Run the app. The Aspire dashboard opens automatically in your browser
On first run, you’ll be prompted to configure Azure OpenAI:
The configuration will be saved locally and reused for subsequent runs.
Once everything is running, click on the web endpoint in the Aspire dashboard (usually https://localhost:7001).
Let’s test it out:
Here’s the cool part: check out the Aspire dashboard while the agent is working. You can actually see:
This level of observability is invaluable when you’re debugging or optimizing your agent’s behavior.
You can easily extend your agent with additional capabilities:
Note
You can check out the full running sample in Generative AI for Beginners – .NET.The Agent Framework makes it easy to coordinate multiple specialized agents:
Note
For more examples of multi-agent coordination patterns, check out the Generative AI for Beginners – .NET.You can add custom middleware to agents for logging, caching, or custom behavior:
Note
You can find more examples of custom middleware patterns in the Generative AI for Beginners – .NET.The quality of your agent’s tool invocations depends heavily on good descriptions:
Create unit tests for your agent tools and integration tests for agent workflows:
Use Application Insights or .NET Aspire’s dashboard to monitor:
The Agent Framework supports both streaming and non-streaming responses:
Use streaming when:
Use non-streaming when:
Minimize unnecessary tool calls:
The application is ready for deployment to Azure using .NET Aspire’s Azure provisioning:
This will:
For detailed deployment instructions, see the .NET Aspire Azure deployment documentation.
And there you have it! We’ve taken a standard AI chat app and transformed it into a proper agent system using Microsoft Agent Framework. The upgrade gives you better architecture with clean separation of concerns, easier testing, and built-in observability—all while using the .NET patterns you already know.
What I really appreciate is that Microsoft Agent Framework doesn’t force you to learn a completely new way of doing things. It builds on familiar concepts like dependency injection, middleware, and telemetry, making it feel natural for C# developers.
If you’re building AI applications with .NET, I highly recommend giving the Agent Framework a try. Start with the AI templates, then layer on the agent capabilities as your needs grow. Check out the official documentation and Luis’ announcement post to learn more!
The post Upgrading to Microsoft Agent Framework in Your .NET AI Chat App appeared first on .NET Blog.
By The AI App Templates let you spin up a working chat application in minutes, complete with AI integration, custom data ingestion, and all the pieces you need to get started. It’s a cool and solid foundation.
But here’s the thing: what if you want to go beyond basic chat? What if you want to build AI agents that can actually reason, make decisions, use tools, and orchestrate complex workflows? That’s where Microsoft Agent Framework comes into play.
In this post, I’m going to show you how I took a standard AI chat app—generated using the .NET AI templates—and enhanced it with Microsoft Agent Framework. Let’s start!
Microsoft Agent Framework is Microsoft’s preview framework for building AI agents in .NET. Think of it as the next evolution beyond simple chatbots. An AI agent can:
What I really like about it is that it’s built on patterns we already know and love as .NET developers: dependency injection, middleware, telemetry—all integrated with Microsoft.Extensions.AI. Check out Luis’ great post about AgentFx for all the details.
Before we start, you’ll need:
Let’s start by creating a baseline chat app using the official .NET AI templates. First, we need to install the templates:
Now let’s create the app. You can do this through Visual Studio or the CLI:
Using Visual Studio:
Using Visual Studio Code or the .NET CLI:
If you prefer VS Code or the command line, check out the official documentation for step-by-step instructions. The process is similar—you’ll use dotnet new commands to scaffold the project with the same configuration options.
The template generates a solution with three projects:
We’ll be working mainly in ChatApp20.Web, which includes:
Let’s look at what the template sets up for us in Program.cs. This is where all the AI pieces come together:
The initial Chat.razor component uses IChatClient directly:
This works great for getting started! But as your app grows, you’ll want more flexibility:
That’s exactly what Microsoft Agent Framework brings to the table. Let’s see how!
Now for the fun part—let’s upgrade this chat app into a proper agent system!
First, we need to add the Microsoft Agent Framework packages to ChatApp20.Web.csproj:
The key Agent Framework packages are:
To promote better separation of concerns and testability, create a new SearchFunctions.cs service that wraps the semantic search functionality:
Why this is important:
Now, let’s configure the AI agent in Program.cs using the Agent Framework’s hosting extensions:
Key points about the agent registration:
Finally, we need to update Chat.razor to use our new AI agent. The changes are pretty straightforward:
Key changes in the code-behind:
That’s it! The agent handles everything else—tool invocation, reasoning, and response generation.
One of the best parts about using the AI templates is that everything runs through .NET Aspire. This gives you:
Run the app. The Aspire dashboard opens automatically in your browser
On first run, you’ll be prompted to configure Azure OpenAI:
The configuration will be saved locally and reused for subsequent runs.
Once everything is running, click on the web endpoint in the Aspire dashboard (usually https://localhost:7001).
Let’s test it out:
Here’s the cool part: check out the Aspire dashboard while the agent is working. You can actually see:
This level of observability is invaluable when you’re debugging or optimizing your agent’s behavior.
You can easily extend your agent with additional capabilities:
Note
You can check out the full running sample in Generative AI for Beginners – .NET.The Agent Framework makes it easy to coordinate multiple specialized agents:
Note
For more examples of multi-agent coordination patterns, check out the Generative AI for Beginners – .NET.You can add custom middleware to agents for logging, caching, or custom behavior:
Note
You can find more examples of custom middleware patterns in the Generative AI for Beginners – .NET.The quality of your agent’s tool invocations depends heavily on good descriptions:
Create unit tests for your agent tools and integration tests for agent workflows:
Use Application Insights or .NET Aspire’s dashboard to monitor:
The Agent Framework supports both streaming and non-streaming responses:
Use streaming when:
Use non-streaming when:
Minimize unnecessary tool calls:
The application is ready for deployment to Azure using .NET Aspire’s Azure provisioning:
This will:
For detailed deployment instructions, see the .NET Aspire Azure deployment documentation.
And there you have it! We’ve taken a standard AI chat app and transformed it into a proper agent system using Microsoft Agent Framework. The upgrade gives you better architecture with clean separation of concerns, easier testing, and built-in observability—all while using the .NET patterns you already know.
What I really appreciate is that Microsoft Agent Framework doesn’t force you to learn a completely new way of doing things. It builds on familiar concepts like dependency injection, middleware, and telemetry, making it feel natural for C# developers.
If you’re building AI applications with .NET, I highly recommend giving the Agent Framework a try. Start with the AI templates, then layer on the agent capabilities as your needs grow. Check out the official documentation and Luis’ announcement post to learn more!
The post Upgrading to Microsoft Agent Framework in Your .NET AI Chat App appeared first on .NET Blog.