Building a .NET AI Chat App with Microsoft Agent Framework and Aspire Orchestration

Creating a fully functional AI Chat App today doesn’t have to take weeks.
With the new Microsoft Agent Framework and .NET Aspire orchestration, you can set up a complete, observable, and extensible AI solution in just a few minutes — all running locally, with built-in monitoring and Azure OpenAI integration.

If you’ve experimented with modern chat applications, you’ve probably noticed they all share a similar design.
So instead of reinventing the wheel, we’ll leverage the elegant Blazor-based front end included in Microsoft’s AI templates — and focus our energy where it matters most: the intelligence and orchestration behind it.

But where things get truly exciting is behind the scenes — where you can move from a simple chat client to a structured, observable AI system powered by Microsoft Agent Framework and .NET Aspire orchestration.

Why Use the Agent Framework?

The Microsoft Agent Framework brings much-needed architectural depth to your AI solutions. It gives you:

  • Separation of concerns – keep logic and tools outside UI components
  • Testability – verify agent reasoning and tool behavior independently
  • Advanced reasoning – support for multi-step decision flows
  • Agent orchestration – easily coordinate multiple specialized agents
  • Deep observability – gain insight into every AI operation and decision

Essentially, it lets you transform a plain chat app into an intelligent, composable system.

Why .NET Aspire Makes It Even Better

One of the best parts about using the AI templates is that everything runs through .NET Aspire.
That gives you:

  • Service discovery between components
  • Unified logging and telemetry in the Aspire dashboard
  • Health checks for every service
  • Centralized configuration for secrets, environment variables, and connection settings

With Aspire, you get orchestration, observability, and consistency across your entire local or cloud-ready environment — no extra setup required.

Continue reading “Building a .NET AI Chat App with Microsoft Agent Framework and Aspire Orchestration”

Getting Started with the Microsoft Agent Framework and Azure OpenAI – My First Five .NET 9 Samples

Over the last few days, I’ve been exploring Microsoft’s new Agent Framework, a preview library that brings structured, context-aware AI capabilities directly into .NET applications.
To get familiar with its architecture and basic features, I’ve built five small “Getting Started” console samples in .NET 9, all powered by Azure OpenAI and defined via a simple .env configuration.

Each example builds upon the previous one — from a simple agent call to multi-turn conversations, function tools, approvals, and structured object outputs.

01 – SimpleAgent

The most basic example: connecting to Azure OpenAI using AzureKeyCredential, creating a simple AIAgent, and asking a question.

AIAgent agent = new AzureOpenAIClient(
    new Uri(endpoint),
    new AzureKeyCredential(key))
    .GetChatClient(deployment)
    .CreateAIAgent(instructions: "Tell me which language is most popular for development.", name: "Developer Assistant");

Console.WriteLine(await agent.RunAsync("Tell me which language is most popular for development."));

02 – ThreadAgent

Introduces multi-turn conversation threads that preserve context between user messages.

AgentThread thread = agent.GetNewThread();
Console.WriteLine(await agent.RunAsync("Tell me which language is most popular for development.", thread));
Console.WriteLine(await agent.RunAsync("Now tell me which of them to use if I want to build a web application in Microsoft ecosystem.", thread));

03 – FunctionTool

Shows how to extend the agent with function tools (custom methods) that can be invoked automatically by the AI when relevant.

[Description("Talk about dogs and provide interesting facts, tips, or stories.")]
static string TalkAboutDogs(string topic) =>
    topic.ToLower() switch
    {
        "labrador" => "Labradors are friendly and full of energy.",
        "poodle" => "Poodles are smart and hypoallergenic.",
        _ => $"Dogs are amazing companions! 🐶"
    };

var agent = new AzureOpenAIClient(new Uri(endpoint), new AzureKeyCredential(key))
    .GetChatClient(deployment)
    .CreateAIAgent("You are a funny assistant who loves dogs.",
                   tools: [AIFunctionFactory.Create(TalkAboutDogs)]);
Continue reading “Getting Started with the Microsoft Agent Framework and Azure OpenAI – My First Five .NET 9 Samples”

Website Powered by WordPress.com.

Up ↑