Make sure you are using the latest version of the Microsoft.Azure.Functions.Worker NuGet package (2.2.0 or greater) in your function app. For existing apps, you will need to manually upgrade the package version. Starting November 12, 2025, new apps created using our templates will automatically include version 2.2.0 or greater.
To enable the ability to define durable agents and register them with the function app, you need to reference the following NuGet packages:
Core Agent Packages:
Microsoft.Agents.AI.Hosting.AzureFunctions- Provides methods to register AI Agents with Azure FunctionsMicrosoft.Agents.AI.OpenAI- Defines types required to create and configure AI Agents
Azure Functions Packages:
Microsoft.Azure.Functions.Worker(v2.2.0 or greater) - Core Azure Functions worker runtimeMicrosoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged- Enables Durable Task scheduler for managing agent workflows
Azure Integration Packages:
Azure.AI.OpenAI- Azure OpenAI client SDK for connecting to OpenAI servicesAzure.Identity- Provides authentication methods and classes. In the example, we useAzureCliCredentialfor local development
Note: Some packages (like Microsoft.Agents.AI.Hosting.AzureFunctions) are available only from the internal NuGet feed. See the configuration section below for setup instructions.
To add agents to .NET isolated function apps, you need to add a package reference to Microsoft.Agents.AI.Hosting.AzureFunctions with version 1.0.0-preview.251109.1. This package is not available in the public NuGet gallery, but is published to the internal feed. When you restore the package in your app, you must use the internal feed as the package source.
Add a nuget.config file to your project in the same folder as your .csproj file with the following content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="durabletask-internal" value="https://azfunc.pkgs.visualstudio.com/internal/_packaging/durabletask-internal/nuget/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>Now run dotnet restore to restore packages from the NuGet feed defined in the config above.
Here is a minimal startup code example that bootstraps an isolated function app, creates an AI Agent, and registers it:
using Azure;
using Azure.AI.OpenAI;
using Azure.Identity;
using Microsoft.Azure.Functions.Worker.Builder;
using Microsoft.Extensions.Hosting;
using Microsoft.Agents.AI;
// Get the Azure OpenAI endpoint and deployment name from environment variables.
string endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")
?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set.");
string deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT")
?? throw new InvalidOperationException("AZURE_OPENAI_DEPLOYMENT is not set.");
// Use Azure Key Credential if provided, otherwise use Azure CLI Credential.
string? azureOpenAiKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_KEY");
AzureOpenAIClient client = !string.IsNullOrEmpty(azureOpenAiKey)
? new AzureOpenAIClient(new Uri(endpoint), new AzureKeyCredential(azureOpenAiKey))
: new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential());
AIAgent agent1 = client.GetChatClient(deploymentName).CreateAIAgent("You are good at telling jokes.", "Joker");
var builder = FunctionsApplication.CreateBuilder(args);
builder.ConfigureFunctionsWebApplication();
// Configure the Durable Agents extension and register the AI agent.
builder.ConfigureDurableAgents(options =>
{
options.AddAIAgent(agent1);
});
builder.Build().Run();The ConfigureDurableAgents method registers the AIAgent as a durable agent. This method is provided by the Microsoft.Agents.AI.Hosting.AzureFunctions package.
For more samples demonstrating different use cases, check the GitHub repository samples directory: https://github.com/microsoft/agent-framework/tree/feature-azure-functions/dotnet/samples/AzureFunctions
Below is the project file of a minimal app showing the required package references:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
<PackageReference Include="Azure.Identity" Version="1.17.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.5" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged" Version="1.0.0" />
<PackageReference Include="Microsoft.Agents.AI.Hosting.AzureFunctions" Version="1.0.0-preview.251109.1" />
<PackageReference Include="Microsoft.Agents.AI.OpenAI" Version="1.0.0-preview.251105.1" />
</ItemGroup>
</Project>- Ensure the
nuget.configfile is properly configured before runningdotnet restore - The internal NuGet feed requires appropriate authentication/access
- Use environment variables for Azure OpenAI configuration to keep credentials secure
- The
ConfigureDurableAgentsmethod is the key integration point for registering AI agents