Microsoft.Agents.Hosting.AspNetCore
1.9.191-beta
Prefix Reserved
dotnet add package Microsoft.Agents.Hosting.AspNetCore --version 1.9.191-beta
NuGet\Install-Package Microsoft.Agents.Hosting.AspNetCore -Version 1.9.191-beta
<PackageReference Include="Microsoft.Agents.Hosting.AspNetCore" Version="1.9.191-beta" />
<PackageVersion Include="Microsoft.Agents.Hosting.AspNetCore" Version="1.9.191-beta" />
<PackageReference Include="Microsoft.Agents.Hosting.AspNetCore" />
paket add Microsoft.Agents.Hosting.AspNetCore --version 1.9.191-beta
#r "nuget: Microsoft.Agents.Hosting.AspNetCore, 1.9.191-beta"
#:package Microsoft.Agents.Hosting.AspNetCore@1.9.191-beta
#addin nuget:?package=Microsoft.Agents.Hosting.AspNetCore&version=1.9.191-beta&prerelease
#tool nuget:?package=Microsoft.Agents.Hosting.AspNetCore&version=1.9.191-beta&prerelease
Microsoft.Agents.Hosting.AspNetCore
About
ASP.NET Core hosting for agents built with the Microsoft 365 Agents SDK. This package connects the SDK's agent and adapter abstractions to ASP.NET Core dependency injection, middleware, and endpoint routing so applications can receive Activity Protocol requests from Azure Bot Service and other channels.
Main APIs
- Host setup:
AddAgentDefaults(),AddAgentCore(),AddAgent<T>(), andAddAgentAuthorization()register the common ASP.NET Core services, configured connections, an agent with itsCloudAdapter, and an application-selected authentication scheme. - Request pipeline:
UseAgents()adds authentication, authorization, and header propagation middleware. - Endpoint mapping:
MapDefaultAgentEndpoints()provides conventional root and Activity Protocol endpoints.MapAgentApplicationEndpoints(),MapAgentEndpoints(), andMapAgentProactiveEndpoints<TAgent>()support custom and proactive routing. - Adapters:
CloudAdapterandIAgentHttpAdaptertranslate ASP.NET Core HTTP requests and responses to the SDK activity-processing pipeline, including invoke, expect-replies, and streaming responses. - Optional integrations: Host extensions register agent middleware, HTTP or Microsoft 365 attachment downloaders, background activity processing, and request-header propagation.
Authentication enforcement integrates with ASP.NET Core, but this package does not provide a concrete authentication scheme.
Custom connection configuration sections
By default, configured token providers and their routing map are read from the top-level
Connections and ConnectionsMap sections. To use nested or differently named sections, register
the custom paths before adding the agent:
builder
.AddAgentCore(
connectionsKey: "Agent:Authentication:Connections",
mapKey: "Agent:Authentication:ConnectionsMap")
.AddAgent<MyAgent>();
When using a custom CloudAdapter, specify the same adapter type in both calls:
builder
.AddAgentCore<MyAdapter>(
connectionsKey: "Agent:Authentication:Connections",
mapKey: "Agent:Authentication:ConnectionsMap")
.AddAgent<MyAgent, MyAdapter>();
Error handling
CloudAdapter logs unhandled exceptions with their full server-side stack traces. Its default error handler sends the exception-message chain to the customer and emits a diagnostic trace activity without a stack trace.
To replace the default handler without deriving from CloudAdapter, register an ICloudAdapterErrorHandler before the agent services:
builder.Services.AddSingleton<ICloudAdapterErrorHandler, MyErrorHandler>();
builder.AddAgent<MyAgent>();
Stack traces in diagnostic trace activities are disabled by default. To opt in while developing, add the following setting to appsettings.Development.json:
{
"CloudAdapterOptions": {
"EmitStackTrace": true
}
}
EmitStackTrace does not affect server-side exception logging.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Agents.Builder (>= 1.9.191-beta)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.29)
- Microsoft.IdentityModel.Validators (>= 8.22.0)
- System.IdentityModel.Tokens.Jwt (>= 8.22.0)
-
net8.0
- Microsoft.Agents.Builder (>= 1.9.191-beta)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.29)
- Microsoft.IdentityModel.Validators (>= 8.22.0)
- System.IdentityModel.Tokens.Jwt (>= 8.22.0)
- System.Text.Json (>= 10.0.12)
NuGet packages (15)
Showing the top 5 NuGet packages that depend on Microsoft.Agents.Hosting.AspNetCore:
| Package | Downloads |
|---|---|
|
Microsoft.TeamsFx
This package aims to reduce the developer tasks of implementing identity and access to cloud resources down to single-line statements with "zero configuration". |
|
|
Microsoft.Agents.A365.Runtime
Runtime utilities for Microsoft Agent 365 SDK, providing HttpContext-based tenant and worker ID extraction for multi-tenant agent applications. |
|
|
Microsoft.Agents.Hosting.AspNetCore.A2A.Preview
Library adding A2A handling to a SDK Agent |
|
|
Microsoft.Agents.A365.Tooling
Microsoft Agent 365 Tooling SDK, providing functionality to work with Agent 365 Tools. |
|
|
Microsoft.Agents.A365.Observability
Common observability components for Microsoft Agent 365 SDK, providing base OpenTelemetry tracing and monitoring functionality for AI agents and tools. |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on Microsoft.Agents.Hosting.AspNetCore:
| Repository | Stars |
|---|---|
|
microsoft/copilot-camp
Hands-on labs for extending Microsoft 365 Copilot and building custom engine agents
|
|
|
microsoft/Agent365-Samples
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.9.191-beta | 73 | 10/16/2026 |
| 1.9.190-beta | 119 | 10/15/2026 |
| 1.9.185-beta | 215 | 10/13/2026 |
| 1.9.179-beta | 193 | 10/10/2026 |
| 1.9.172-beta | 170 | 10/9/2026 |
| 1.9.167-beta | 402 | 10/3/2026 |
| 1.9.69-beta | 152 | 10/2/2026 |
| 1.9.66-beta | 385 | 9/26/2026 |
| 1.9.64-beta | 172 | 9/25/2026 |
| 1.9.59-beta | 313 | 9/22/2026 |
| 1.9.50-beta | 594 | 9/18/2026 |
| 1.9.42-beta | 234 | 9/17/2026 |
| 1.9.40-beta | 270 | 9/15/2026 |
| 1.9.38-beta | 223 | 9/12/2026 |
| 1.9.35-beta | 10,820 | 9/11/2026 |
| 1.9.28-beta | 650 | 9/5/2026 |
| 1.9.25-beta | 154 | 9/4/2026 |
| 1.9.15-beta | 592 | 8/27/2026 |
| 1.9.8-beta | 157 | 8/26/2026 |
| 1.9.3-beta | 240 | 8/25/2026 |