Building Stateful AI Agents with Microsoft Agent Framework on Azure Functions and .NET 10
Building Stateful AI Agents with Microsoft Agent Framework on Azure Functions and .NET 10
Date: 2026-05-19
Discover how to host intelligent agents on Azure Functions using Microsoft Agent Framework with durable, multi-turn conversations powered by Durable Functions and .NET 10.
Tags: ["Azure", "Microsoft Agent Framework", ".NET 10", "Azure Functions", "Durable Functions"]
Hosting AI agents that can engage in long-running, multi-turn conversations is a cornerstone of modern intelligent applications. While building simple agents as console apps is great for experimentation, production deployment demands scalable, persistent, and HTTP-accessible hosting solutions. Enter the Microsoft Agent Framework hosting integration with Azure Functions, a powerful combination enabling stateful and resilient AI agent endpoints.
In this post, we dive deep into running AI agents on Azure Functions using the Microsoft Agent Framework with .NET 10 in the isolated worker model. We explore how Durable Functions manage conversation state out of the box, how to configure your project, and what you need to know to build robust, conversational AI experiences with minimal plumbing.
We'll cover everything from project setup and hosting integration to how Durable Functions guarantee durability and thread-safe state persistence—plus practical tips gleaned from a real weekend-planner sample agent.
Architecture Overview
┌─────────────────────────────────────────────┐
│ Enterprise Data │
├─────────────────────────────────────────────┤
│ • User Requests (HTTP Messages) │
│ • Conversation State (Durable Storage) │
└─────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────┐
│ Microsoft Agent Framework on Azure │
│ Functions Host │
├─────────────────────────────────────────────┤
│ • HTTP Endpoints for Agents │
│ • Durable Functions Orchestrations │
│ • Agent Instantiation & Tool Integration │
└─────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────┐
│ .NET 10 Agent Logic │
├─────────────────────────────────────────────┤
│ • AI Model Calls (Azure AI Projects) │
│ • Tool Functions for Weather, Activities │
│ • Multi-turn Conversation Management │
└─────────────────────────────────────────────┘
This layered design ensures that user input flows securely and reliably into your AI agent via HTTP, with Durable Functions transparently managing state persistence, orchestrations, and fault tolerance. The Microsoft Agent Framework ties these pieces together seamlessly.
Diagram by Jaliya Udagedara showcasing Azure Functions as the hosting layer
Key Technical Observations
-
Durable Functions for Conversation State — Leveraging Durable Functions as the persistence and orchestration engine means each conversation thread is kept alive across restarts and failures without manual state handling.
-
Automatic HTTP Endpoint Exposure — Adding your agent via
ConfigureDurableAgentsregisters a dedicated HTTP endpoint per agent name automatically, eliminating boilerplate HTTP trigger function code. -
Isolated Worker Model with .NET 10 — The sample shows modern .NET 10 isolated worker hosting for Azure Functions, which enables better control, dependency injection, and performance optimizations.
-
Tool Integration via AIFunctionFactory — Tools like weather lookup and activity suggestions are simple functions annotated with descriptions and integrated into the agent pipeline, showcasing composability.
-
Thread ID for Multi-Turn Conversations — The
x-ms-thread-idheader lets clients continue conversations contextually by passing back the thread ID, backed by Durable Functions maintaining all the conversation state transparently. -
Minimal Code for Complex Orchestration — The pattern abstracts orchestration away so developers focus on writing domain logic and tools, without juggling triggers or state machines.
How It Works: Hosting Agents on Azure Functions with Durable State
Setting up the Azure Functions Project
Create an Azure Functions worker targeting .NET 10 with the isolated worker model. The minimal but essential packages include:
This setup brings in the Microsoft Agent Framework core and the Azure Functions host integration, plus HTTP trigger support.
Configuring Durable Functions Storage
Durable Functions requires storage to persist orchestration state and messages. Locally, Azurite emulator can be used:
{
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"AZURE_AI_ENDPOINT": "https://<your-foundry-resource>.services.ai.azure.com/",
"AZURE_AI_MODEL": ""
}
}
This configuration provides the endpoint and model deployment to leverage Azure AI Projects integration inside the agent.
Defining the Agent and Tools
The agent logic involves creating an AIProjectClient and registering tools like weather info, activity lookup, and current date:
var agent = new AIProjectClient(new Uri(endpoint), credential)
.AsAIAgent(
model: deploymentName,
name: "weekend-planner",
instructions: """
You help users plan their weekends and choose the best activities for the given weather.
If an activity would be unpleasant in weather, don't suggest it.
Include date of the weekend in response.
""",
tools: [
AIFunctionFactory.Create(GetWeather),
AIFunctionFactory.Create(GetActivities),
AIFunctionFactory.Create(GetCurrentDate)
]
);
These tools are simple methods annotated with [Description] attributes enhancing agent capabilities without complex wiring.
Hosting with Durable Agent Integration
The heart of the setup is:
IHost app = FunctionsApplication.CreateBuilder(args)
.ConfigureFunctionsWebApplication()
.ConfigureDurableAgents(options => options.AddAIAgent(agent))
.Build();
app.Run();
Here, ConfigureDurableAgents hooks the agent into the Azure Functions host, automatically exposing HTTP endpoints with durable orchestration backing.
Using the Endpoints: Multi-turn Conversations
The runtime creates HTTP endpoints per agent under:
POST /api/agents/weekend-planner/run
Starting a conversation:
POST http://localhost:7098/api/agents/weekend-planner/run
Content-Type: application/json
{
"message": "What should I do this weekend in Auckland?"
}
The response includes x-ms-thread-id in the response header to continue the conversation statefully:
POST http://localhost:7098/api/agents/weekend-planner/run?thread_id=<x-ms-thread-id>
Content-Type: application/json
{
"message": "What is the weather like there?"
}
Without providing a thread ID, the agent treats it as a fresh conversation, missing prior context.
Example of the "weekend-planner" agent handling multi-turn dialogue leveraging durable state
Quick Tips & Tricks
-
Use Durable Functions for Reliable State Management
Avoid manual conversation state plumbing. Durable Functions persist conversation state transparently across executions, crashes, and redeployments. -
Leverage Agent Framework Hosting Package
Microsoft.Agents.AI.Hosting.AzureFunctionsautomatically wires your agent into Azure Functions with minimal code, exposing HTTP endpoints and handling orchestration lifecycles. -
Adopt .NET 10 Isolated Worker Model
The isolated worker model provides better dependency injection and separation from the runtime, improving maintainability and performance. -
Annotate Tool Methods with Descriptions
Use[Description]attributes on tools to provide metadata that enriches the agent’s functional context and improves clarity. -
Pass and Store Thread IDs for Contextual Conversations
Capture thex-ms-thread-idheader from the agent’s responses and use it for all subsequent calls to maintain conversation continuity. -
Use Credential Classes Like AzureCliCredential Locally
For local development, utilize Azure CLI credentials to simplify authentication without hardcoding secrets.
Conclusion
The Microsoft Agent Framework combined with Azure Functions and Durable Functions offers a compelling platform for hosting intelligent, stateful AI agents at scale. This pattern abstracts away the complex orchestration details, letting developers focus squarely on building rich agent logic and tools.
By adopting the .NET 10 isolated worker model and leveraging built-in hosting packages, you get automatic HTTP endpoint generation, durable conversation state, and seamless AI model integration with minimal boilerplate. This architecture supports resilient, multi-turn conversations essential for production-grade agents.
Looking forward, expanding this foundation to include real-time event-driven triggers, enhanced monitoring with Durable Task Scheduler, and additional AI tool integrations will make for even more powerful agent solutions in the cloud-first era.
References
- Microsoft Agent Framework: Agents on Azure Functions with .NET by Jaliya Udagedara — Original detailed blog post and source analysis
- Sample code repository for Durable Functions Agent — Complete source code example
- Microsoft Agent Framework documentation — Official Microsoft Docs
- Microsoft Agent Framework: Azure Functions (Durable) — Integration guide from Microsoft
- GitHub - microsoft/agent-framework — Official Agent Framework repository with issues and examples
- microsoft/agent-framework issue #5927 — Discussion on dummy orchestrator requirement for Durable extension binding