One of them is the Durable Task extension for Microsoft Agent Framework going GA.
Setup
<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>
docker run `
--detach `
--name dts-emulator `
--publish 8080:8080 `
--publish 8082:8082 `
mcr.microsoft.com/dts/dts-emulator:latest
{
"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>"
}
}
{
"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
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
Workflow workflow = new WorkflowBuilder(weatherAssessor) .WithName("WeekendPlan") .AddEdge(weatherAssessor, itineraryPlanner) .Build();
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();
History ownership 'Service' requires an explicit stable logical provider key. Set ProviderKey in the agent registration's history options before running this durable session.
Running it
@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}}
|
| Function App: Workflow |
dotnet-http-file DurableWorkflow.http --name status
A few things to note
Durable Task extension for Microsoft Agent Framework is now Generally Available
Durable Workflows Azure Functions Samples
Hope this helps.
Happy Coding.
Regards,
Jaliya









