![]() |
VOOZH | about |
dotnet add package Microsoft.Agents.AI.Hosting.AzureFunctions --version 1.10.0-preview.260610.1
NuGet\Install-Package Microsoft.Agents.AI.Hosting.AzureFunctions -Version 1.10.0-preview.260610.1
<PackageReference Include="Microsoft.Agents.AI.Hosting.AzureFunctions" Version="1.10.0-preview.260610.1" />
<PackageVersion Include="Microsoft.Agents.AI.Hosting.AzureFunctions" Version="1.10.0-preview.260610.1" />Directory.Packages.props
<PackageReference Include="Microsoft.Agents.AI.Hosting.AzureFunctions" />Project file
paket add Microsoft.Agents.AI.Hosting.AzureFunctions --version 1.10.0-preview.260610.1
#r "nuget: Microsoft.Agents.AI.Hosting.AzureFunctions, 1.10.0-preview.260610.1"
#:package Microsoft.Agents.AI.Hosting.AzureFunctions@1.10.0-preview.260610.1
#addin nuget:?package=Microsoft.Agents.AI.Hosting.AzureFunctions&version=1.10.0-preview.260610.1&prereleaseInstall as a Cake Addin
#tool nuget:?package=Microsoft.Agents.AI.Hosting.AzureFunctions&version=1.10.0-preview.260610.1&prereleaseInstall as a Cake Tool
This package adds Azure Functions integration and serverless hosting for Microsoft Agent Framework on Azure Functions. It builds upon the Microsoft.Agents.AI.DurableTask package to provide the following capabilities:
From the command-line:
dotnet add package Microsoft.Agents.AI.Hosting.AzureFunctions
Or directly in your project file:
<ItemGroup>
<PackageReference Include="Microsoft.Agents.AI.Hosting.AzureFunctions" Version="[CURRENTVERSION]" />
</ItemGroup>
For a comprehensive tour of all the functionality, concepts, and APIs, check out the Azure Functions samples in the Microsoft Agent Framework GitHub repository.
This package provides a ConfigureDurableAgents extension method on the FunctionsApplicationBuilder class to configure the application to host Microsoft Agent Framework agents. These hosted agents are automatically registered as durable entities with the Durable Task runtime and can be invoked via HTTP or Durable Task orchestrator functions.
// Create agents using the standard Microsoft Agent Framework.
// Invocable via HTTP via http://localhost:7071/api/agents/SpamDetectionAgent/run
AIAgent spamDetector = new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential())
.GetChatClient(deploymentName)
.AsAIAgent(
instructions: "You are a spam detection assistant that identifies spam emails.",
name: "SpamDetectionAgent");
AIAgent emailAssistant = new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential())
.GetChatClient(deploymentName)
.AsAIAgent(
instructions: "You are an email assistant that helps users draft responses to emails with professionalism.",
name: "EmailAssistantAgent");
// Configure the Functions application to host the agents.
using IHost app = FunctionsApplication
.CreateBuilder(args)
.ConfigureFunctionsWebApplication()
.ConfigureDurableAgents(options =>
{
options.AddAIAgent(spamDetector);
options.AddAIAgent(emailAssistant);
})
.Build();
app.Run();
By default, each agent can be invoked via a built-in HTTP trigger function at the route http[s]://[host]/api/agents/{agentName}/run.
This package also provides a set of extension methods such as GetAgent on the TaskOrchestrationContext class for interacting with hosted agents within orchestrations.
[Function(nameof(SpamDetectionOrchestration))]
public static async Task<string> SpamDetectionOrchestration(
[OrchestrationTrigger] TaskOrchestrationContext context)
{
Email email = context.GetInput<Email>() ?? throw new InvalidOperationException("Email is required");
// Get the spam detection agent
DurableAIAgent spamDetectionAgent = context.GetAgent("SpamDetectionAgent");
AgentSession spamSession = await spamDetectionAgent.CreateSessionAsync();
// Step 1: Check if the email is spam
AgentResponse<DetectionResult> spamDetectionResponse = await spamDetectionAgent.RunAsync<DetectionResult>(
message:
$"""
Analyze this email for spam content and return a JSON response with 'is_spam' (boolean) and 'reason' (string) fields:
Email ID: {email.EmailId}
Content: {email.EmailContent}
""",
session: spamSession);
DetectionResult result = spamDetectionResponse.Result;
// Step 2: Conditional logic based on spam detection result
if (result.IsSpam)
{
// Handle spam email
return await context.CallActivityAsync<string>(nameof(HandleSpamEmail), result.Reason);
}
else
{
// Generate and send response for legitimate email
DurableAIAgent emailAssistantAgent = context.GetAgent("EmailAssistantAgent");
AgentSession emailSession = await emailAssistantAgent.CreateSessionAsync();
AgentResponse<EmailResponse> emailAssistantResponse = await emailAssistantAgent.RunAsync<EmailResponse>(
message:
$"""
Draft a professional response to this email. Return a JSON response with a 'response' field containing the reply:
Email ID: {email.EmailId}
Content: {email.EmailContent}
""",
session: emailSession);
EmailResponse emailResponse = emailAssistantResponse.Result;
return await context.CallActivityAsync<string>(nameof(SendEmail), emailResponse.Response);
}
}
Agents can also schedule and interact with orchestrations from custom code tools. This is useful for long-running tool use cases where orchestrations need to be executed in the context of the agent.
The DurableAgentContext.Current AsyncLocal property provides access to the current agent context, which can be used to schedule and interact with orchestrations.
class Tools
{
[Description("Starts a content generation workflow and returns the instance ID for tracking.")]
public string StartContentGenerationWorkflow(
[Description("The topic for content generation")] string topic)
{
// ContentGenerationWorkflow is an orchestrator function defined in the same project.
string instanceId = DurableAgentContext.Current.ScheduleNewOrchestration(
name: nameof(ContentGenerationWorkflow),
input: topic);
// Return the instance ID so that it gets added to the LLM context.
return instanceId;
}
[Description("Gets the status of a content generation workflow.")]
public async Task<OrchestrationMetadata> GetContentGenerationStatus(
[Description("The instance ID of the workflow to check")] string instanceId,
[Description("Whether to include detailed information")] bool includeDetails = true)
{
OrchestrationMetadata? status = await DurableAgentContext.Current.Client.GetOrchestrationStatusAsync(
instanceId,
includeDetails);
return status ?? throw new InvalidOperationException($"Workflow instance '{instanceId}' not found.");
}
}
These tools are registered with the agent using the tools parameter when creating the agent.
Tools tools = new();
AIAgent agent = new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential())
.GetChatClient(deploymentName)
.AsAIAgent(
instructions: "You are a content generation assistant that helps users generate content.",
name: "ContentGenerationAgent",
tools: [
AIFunctionFactory.Create(tools.StartContentGenerationWorkflow),
AIFunctionFactory.Create(tools.GetContentGenerationStatus)
]);
using IHost app = FunctionsApplication
.CreateBuilder(args)
.ConfigureFunctionsWebApplication()
.ConfigureDurableAgents(options => options.AddAIAgent(agent))
.Build();
app.Run();
We welcome feedback and contributions in our GitHub repo.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Microsoft.Agents.AI.Hosting.AzureFunctions:
| Package | Downloads |
|---|---|
|
ANcpLua.Agents.Hosting.Azure
Preview-channel Azure Functions hosting facades for Microsoft Agent Framework consumers. |
Showing the top 1 popular GitHub repositories that depend on Microsoft.Agents.AI.Hosting.AzureFunctions:
| Repository | Stars |
|---|---|
|
rwjdk/MicrosoftAgentFrameworkSamples
Samples demonstrating the Microsoft Agent Framework in C#
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.10.0-preview.260610.1 | 194 | 6/10/2026 |
| 1.9.0-preview.260603.1 | 1,108 | 6/3/2026 |
| 1.8.0-preview.260528.1 | 364 | 5/28/2026 |
| 1.7.0-preview.260526.1 | 148 | 5/26/2026 |
| 1.6.2-preview.260521.1 | 120 | 5/22/2026 |
| 1.6.1-preview.260514.1 | 522 | 5/14/2026 |
| 1.6.0-preview.260512.1 | 62 | 5/13/2026 |
| 1.5.0-preview.260507.1 | 1,121 | 5/8/2026 |
| 1.4.0-preview.260505.1 | 1,422 | 5/5/2026 |
| 1.3.0-preview.260423.1 | 1,312 | 4/24/2026 |
| 1.2.0-preview.260421.1 | 95 | 4/21/2026 |
| 1.1.0-preview.260410.1 | 527 | 4/10/2026 |
| 1.0.0-preview.260402.1 | 1,163 | 4/2/2026 |
| 1.0.0-preview.260330.1 | 554 | 3/31/2026 |
| 1.0.0-preview.260311.1 | 1,231 | 3/11/2026 |
| 1.0.0-preview.260304.1 | 167 | 3/4/2026 |
| 1.0.0-preview.260225.1 | 359 | 2/25/2026 |
| 1.0.0-preview.260219.1 | 168 | 2/20/2026 |
| 1.0.0-preview.260212.1 | 472 | 2/12/2026 |
| 0.0.1-preview.260417.2 | 58 | 4/17/2026 |