Sunday, November 22, 2026

Microsoft Agent Framework: Durable Workflows on Azure Functions with .NET

In Microsoft Ignite 2026, there are a lot of new announcements for Azure Functions: What's new in Azure Functions and Durable Task Scheduler at Microsoft Ignite 2026.

One of them is the Durable Task extension for Microsoft Agent Framework going GA.

Earlier I blogged about running agents on Azure Functions (with Durable Functions, with Durable Task Scheduler) and about coordinating multiple agents from a Durable Functions orchestrator, where we wrote the orchestrator ourselves. I have also blogged about workflows: handoff, hosting it in Microsoft Foundry and human in the loop. Those were built with AgentWorkflowBuilder, where the agents decide among themselves who answers next.

In this post, let's see how we can run a Microsoft Agent Framework Workflow durably on Azure Functions. This time the workflow is built with WorkflowBuilder, where we connect the steps ourselves with edges, and the Durable Task extension runs it as an orchestration, so there is no orchestrator code to write.

A workflow in Agent Framework is a graph: agents and executors are the nodes, edges connect them, and the output of one node becomes the input of the next. The Durable Task extension can run that graph as a Durable Functions orchestration.

We are going to build a small weekend planner with two agents. The first one checks whether the weather is good for outdoor activities, and the second one builds an itinerary based on that.

Setup

Let's start by creating an Azure Functions worker project targeting .NET 10 (isolated worker model). These are the packages we need (latest as of today, it will change).
<ItemGroup>
  <PackageReference Include="Microsoft.Agents.AI.Foundry" Version="1.28.0-preview.261106.1" />
  <PackageReference Include="Microsoft.Agents.AI.Hosting.AzureFunctions" Version="1.16.0" />
  <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.52.0" />
  <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.22.0" />
  <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged" Version="1.12.0" />
  <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.1.1" />
  <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.1.0" />
</ItemGroup>
Microsoft.Agents.AI.Hosting.AzureFunctions is the package that does the heavy lifting. Note that Microsoft.Agents.AI.Foundry is still in preview.

For the durable backend, we will be using the Durable Task Scheduler emulator, along with Azurite for the Functions host storage.
docker run `
    --detach `
    --name dts-emulator `
    --publish 8080:8080 `
    --publish 8082:8082 `
    mcr.microsoft.com/dts/dts-emulator:latest
The local.settings.json looks like below.
{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
    "DTS_CONNECTION_STRING": "Endpoint=http://localhost:8080;Authentication=None",
    "TASKHUB_NAME": "default",
    "AZURE_AI_ENDPOINT": "https://<resource>.services.ai.azure.com/api/projects/<project>",
    "AZURE_AI_MODEL": "<model-deployment-name>"
  }
}
And in host.json, we point Durable Functions to the scheduler.
{
  "version": "2.0",
  "logging": {
    "logLevel": {
      "default": "Error",
      "Host.Function.Console": "Information"
    }
  },
  "extensions": {
    "durableTask": {
      "hubName": "%TASKHUB_NAME%",
      "storageProvider": {
        "type": "azureManaged",
        "connectionStringName": "DTS_CONNECTION_STRING"
      }
    }
  }
}

The agents

The agents are created the usual way. Each one has a couple of tools: GetWeather and GetCurrentDate for the first one, GetActivities and GetCurrentDate for the second one. GetWeather and GetActivities return hard-coded values, and every tool prints a line to the console when it gets called.
var endpoint = Environment.GetEnvironmentVariable("AZURE_AI_ENDPOINT")!;
var deploymentName = Environment.GetEnvironmentVariable("AZURE_AI_MODEL")!;

// For local development, using AzureCliCredential
var credential = new AzureCliCredential();
var projectClient = new AIProjectClient(new Uri(endpoint), credential);

AIAgent weatherAssessor = projectClient
    .AsAIAgent(
        model: deploymentName,
        name: "WeatherAssessor",
        instructions: """
            You are given a city. Determine whether the weather there is suitable for outdoor leisure activities this weekend.
            Use the available tools to check the weather and current date.
            Respond with the city, the weather, and whether it is suitable for outdoor activities.
            """,
        tools: [
            AIFunctionFactory.Create(Tools.GetWeather),
            AIFunctionFactory.Create(Tools.GetCurrentDate)
        ]);

AIAgent itineraryPlanner = projectClient
    .AsAIAgent(
        model: deploymentName,
        name: "ItineraryPlanner",
        instructions: """
            You are given a weather assessment for a city. Build a weekend itinerary using the available activities for that city.
            If the weather is not suitable for outdoor activities, only include indoor activities.
            Include the date of the weekend in the itinerary.
            """,
        tools: [
            AIFunctionFactory.Create(Tools.GetActivities),
            AIFunctionFactory.Create(Tools.GetCurrentDate)
        ]);

The workflow

Now the workflow. We start from the first agent and add an edge to the second one, so the answer of WeatherAssessor becomes the input of ItineraryPlanner.
Workflow workflow = new WorkflowBuilder(weatherAssessor)
    .WithName("WeekendPlan")
    .AddEdge(weatherAssessor, itineraryPlanner)
    .Build();
Then we register the workflow with the Functions host.
using IHost app = FunctionsApplication
    .CreateBuilder(args)
    .ConfigureFunctionsWebApplication()
    .ConfigureDurableAgents(options =>
    {
        options.AddAIAgent(weatherAssessor, timeToLive: null, configureHistory: h => h.ProviderKey = new("foundry.v1"));
        options.AddAIAgent(itineraryPlanner, timeToLive: null, configureHistory: h => h.ProviderKey = new("foundry.v1"));
    })
    .ConfigureDurableWorkflows(options => options.AddWorkflow(workflow, enableStatusEndpoint: true))
    .Build();

app.Run();
ConfigureDurableWorkflows is where the magic happens. It turns the workflow into an orchestration, each agent into a durable entity, and creates the HTTP endpoints to run it. We don't write an orchestrator function or an HTTP trigger ourselves.

So why ConfigureDurableAgents? The workflow registers its agents on its own, but Foundry agents keep their conversation history in Foundry, and the durable session needs a stable key to know who owns that history. Registering the agents explicitly lets us set that key through ProviderKey. Without it, every agent call fails with:
History ownership 'Service' requires an explicit stable logical provider key. Set ProviderKey in the agent registration's history options before running this durable session.
The key can be any stable value, just don't change it once you have sessions, since it gets saved with them.

Running it

When we run the Function App, we can see the functions that got created for us.
Functions
The workflow is exposed at /api/workflows/WeekendPlan/run. Because we registered the agents explicitly, each agent also gets its own endpoint. Let's call the workflow using the following .http file.
@host = http://localhost:7071

### Run the WeekendPlan workflow and wait up to 60 seconds for the result
# @name startWithWait
POST {{host}}/api/workflows/WeekendPlan/run?waitForResponse=true&timeoutSeconds=60
Content-Type: text/plain
Accept: text/plain

Auckland

### Run it without waiting, the response has the run id
# @name start
POST {{host}}/api/workflows/WeekendPlan/run
Content-Type: text/plain

Auckland

### Check the status of the run started above
# @name status
GET {{host}}/api/workflows/WeekendPlan/status/{{start.response.body.$.runId}}
With waitForResponse=true, the request waits for the workflow to finish, but only for 10 seconds by default. Two agents with tool calls can take longer than that, so we set timeoutSeconds (up to 200). If it times out, we get a 202 with the run id instead, same as the second request, and we can check the status with the third one.

The first request comes back with the itinerary.
POST {{host}}/api/workflows/WeekendPlan/run?waitForResponse=true&timeoutSeconds=60
And in the Function App console, we can see the tools ran in order: the weather first, then the activities.
Function App: Workflow
We can also open the Durable Task Scheduler dashboard (http://localhost:8082) and see the run. In its History tab, we can see the input and output of each step.

Tip: you can run .http files from the command line using dotnet-http-file. When a request depends on another one, like the status request here, it runs that one first.
dotnet-http-file DurableWorkflow.http --name status

A few things to note

At the time of writing, there's an issue where agent names with hyphens (for example, weather-assessor) don't work in a workflow. The workflow can't find the agent and the run fails with Agent 'weather_assessor' not found. It's easy to miss, because with waitForResponse=true, the response is still a 200 with the error as the body. The status endpoint shows the run as Failed. Until it's fixed, use names without hyphens.

Agents in a workflow pass plain text to each other. Here, it's the ItineraryPlanner that decides indoor or outdoor based on the weather assessment. If you need that decision to be made in code, have a look at conditional edges.

The complete sample is here:

More read:

Hope this helps.

Happy Coding.

Regards,
Jaliya

No comments:

Post a Comment