Microsoft Agent Framework Tutorial: Build AI Agents and Workflows in .NET
Learn how to build AI agent workflows in .NET using Microsoft Agent Framework. Step-by-step beginner-friendly tutorial with real-world examples.
Artificial Intelligence is no longer something separate from day-to-day development. It’s slowly becoming a native part of how we build modern applications, especially in the .NET ecosystem.
With the Microsoft Agent Framework (Preview), Microsoft has taken a big step toward making agent-based AI systems easy to build, structured, and production-ready — directly inside .NET applications.
In this article, we’ll break everything down from scratch, so even if you’re new to AI agents, you’ll feel comfortable by the end.
You’ll learn:
- What the Microsoft Agent Framework is
- What Agents and Workflows really mean (in simple terms)
- How to build a multi-agent AI workflow in .NET 9
- A real-world example: a multi-language translation pipeline
What Is Microsoft Agent Framework?
The Microsoft Agent Framework is an open-source SDK that allows you to build AI agents and connect them together using workflows.
Think of it as a way to create AI-powered pipelines, where:
- Each agent has a specific responsibility
- Agents can reason, process data, and call APIs
- Outputs from one agent can flow into another
The framework works with .NET and Python and integrates smoothly with:
- Azure OpenAI
- GitHub Models
- Other OpenAI-compatible APIs
Under the hood, it builds upon Microsoft’s earlier AI efforts like Semantic Kernel and AutoGen, but with:
- Better structure
- Strong typing
- Clear orchestration
- Scalability for real-world apps
What Can You Do With It?
Using Microsoft Agent Framework, you can:
- Create task-specific AI agents
- Connect agents using predictable workflows
- Build multi-step reasoning systems
- Run everything locally or in the cloud
In short, it’s Microsoft’s answer to agentic AI for .NET developers.
What Is an AI Agent?
An Agent is a focused AI unit designed to perform one specific task.
Instead of one giant AI doing everything, you break responsibilities into smaller, smarter components.
Each agent has:
- Name → its identity
- Instructions → what it should do
- Model → the AI engine behind it
Example Agents
- A Translator Agent that converts text into French
- A Reviewer Agent that checks grammar and tone
- A Summary Agent that creates a final report
Agents can work:
- Independently
- Or together inside a workflow
This separation makes systems easier to maintain, debug, and scale.
What Is a Workflow?
A Workflow defines how multiple agents interact with each other.
If agents are workers, then a workflow is the assembly line.
You can imagine it like a flowchart:
- Agent A runs first
- Its output goes to Agent B
- Then Agent C processes the result
Workflows can be:
- Sequential (one after another)
- Parallel (multiple agents at once)
In this article, we’ll build a sequential workflow, which is perfect for beginners and very predictable.
What We’re Building: Multi-Language Translator Workflow
We’ll create a .NET console app where:
- User enters English text
- French Agent translates it
- Spanish Agent translates it
- Reviewer Agent checks quality
- Summary Agent creates a final report
All of this will run automatically using a single workflow.
Step 1: Create the .NET Project
Create a new .NET 9 console application:
dotnet new console -n MultiLanguageTranslator
cd MultiLanguageTranslator
Now install the required NuGet packages:
dotnet add package Microsoft.Agents.AI --prerelease
dotnet add package Microsoft.Agents.AI.Workflows --prerelease
dotnet add package Microsoft.Extensions.AI.OpenAI
These packages give us:
- Core agent functionality
- Workflow orchestration
- OpenAI-compatible model support
Step 2: Connect to a GitHub Model
For this demo, we’ll use GPT-4o-mini from GitHub Models.
IChatClient chatClient =
new ChatClient(
"gpt-4o-mini",
new ApiKeyCredential("YOUR_GITHUB_API_KEY"),
new OpenAIClientOptions
{
Endpoint = new Uri("https://models.github.ai/inference")
})
.AsIChatClient();
This step:
- Authenticates using your GitHub API key
- Connects your app to the AI model
- Prepares the client for agent usage
Step 3: Create Individual AI Agents
French Translator Agent
AIAgent frenchAgent = new ChatClientAgent(
chatClient,
new ChatClientAgentOptions
{
Name = "FrenchAgent",
Instructions = "Translate the provided text into French."
});
Spanish Translator Agent
AIAgent spanishAgent = new ChatClientAgent(
chatClient,
new ChatClientAgentOptions
{
Name = "SpanishAgent",
Instructions = "Translate the provided text into Spanish."
});
Quality Reviewer Agent
string reviewerInstructions = """
You are a multilingual translation reviewer.
Check grammar, tone, and cultural accuracy.
Return a quality rating (Excellent / Good / Needs Review)
with short feedback.
""";
AIAgent qualityReviewerAgent = new ChatClientAgent(
chatClient,
new ChatClientAgentOptions
{
Name = "QualityReviewerAgent",
Instructions = reviewerInstructions
});
Summary Agent
string summaryInstructions = """
Summarize the translation results.
Mention quality and overall readiness for publishing.
""";
AIAgent summaryAgent = new ChatClientAgent(
chatClient,
new ChatClientAgentOptions
{
Name = "SummaryAgent",
Instructions = summaryInstructions
});
Each agent does one job only, which keeps the system clean and modular.
Step 4: Build the Workflow
Now we connect all agents into a sequential workflow:
AIAgent workflowAgent = await AgentWorkflowBuilder
.BuildSequential(
frenchAgent,
spanishAgent,
qualityReviewerAgent,
summaryAgent)
.AsAgentAsync();
This ensures:
- Translations happen first
- Review happens next
- Summary is generated last
Step 5: Run the Workflow
Console.Write("You: ");
string userInput = Console.ReadLine() ?? string.Empty;
AgentRunResponse response = await workflowAgent.RunAsync(userInput);
Console.WriteLine();
foreach (var message in response.Messages)
{
Console.WriteLine($"{message.AuthorName}:");
Console.WriteLine(message.Text);
Console.WriteLine();
}
Sample Input
Welcome to our application! Please verify your email before continuing.
Output
FrenchAgent:
Bienvenue dans notre application ! Veuillez vérifier votre adresse e-mail avant de continuer.
SpanishAgent:
¡Bienvenido a nuestra aplicación! Por favor, verifica tu correo electrónico antes de continuar.
QualityReviewerAgent:
French: Excellent — natural tone.
Spanish: Good — slightly formal.
SummaryAgent:
Both translations reviewed successfully. Ready for publishing.
Every step runs automatically — no manual coordination needed.
Why This Approach Is Powerful
- Clear separation of responsibilities
- Easy to add more agents later
- Predictable execution flow
- Perfect for real-world automation scenarios
You can extend this workflow to:
- Add more languages
- Perform sentiment analysis
- Push results to APIs or databases
- Integrate with localization pipelines
Final Thoughts
The Microsoft Agent Framework makes it surprisingly simple to build intelligent, multi-agent systems inside .NET.
With just a few agents and a workflow, you created a complete AI-powered translation pipeline — something that previously required complex orchestration.
This is only the beginning, but it already shows how AI + .NET can work beautifully together.
Key Takeaways
- Agents are focused AI components with one responsibility
- Workflows define how agents collaborate
- Microsoft Agent Framework brings agentic AI to .NET
- Ideal for building scalable, production-ready AI systems
