microsoft/agents/agents-sdk-dotnet

Claude Code and agent skill by microsoft/agents

Trust tier 4
  • vendor
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when any code imports Microsoft.Agents.Hosting.AspNetCore, Microsoft.Agents.Builder, or related Agents SDK packages, or when the user is building, configuring, or asking questions about a Microsoft 365 Agents SDK agent in C# / .NET. Trigger on questions about appsettings.json, connection configuration, AgentApplication patterns, OAuth sign-in flows, storage backends, cards, streaming, or local testing with the Agents Playground — even if no code exists yet and the user is planning or asking how to get started.

Install

npx vskill@latest install microsoft/agents/agents-sdk-dotnet

SKILL.md

The same SKILL.md was published earlier as microsoft/agents/agents-sdk-dotnet.

Overview

The Microsoft 365 Agents SDK builds multichannel agents for Teams, Copilot Studio, and web chat.

PackagePurpose
Microsoft.Agents.Hosting.AspNetCoreASP.NET Core hosting, auth, endpoint mapping
Microsoft.Agents.Authentication.MsalMSAL-based auth (client credentials, OBO)
Microsoft.Agents.BuilderCore: AgentApplication, ITurnContext, ITurnState
Microsoft.Agents.CoreModels, activity types, channel accounts
Microsoft.Agents.StorageIStorage, MemoryStorage
Microsoft.Agents.Extensions.MSTeamsTeams-specific models and AgentExtension
Microsoft.Agents.Extensions.A2AAgent-to-agent (A2A) protocol AgentExtension
Microsoft.Agents.Extensions.SlackSlack AgentExtension
Microsoft.Agents.Builder.DialogsDialog system (waterfall, prompts)

Minimal project requires only: Microsoft.Agents.Hosting.AspNetCore + Microsoft.Agents.Authentication.Msal. Core builder, model, and memory-storage dependencies are transitive. Install optional AgentExtensions, dialogs, and persistent storage providers explicitly when needed.

Always use the latest non-beta (stable) version. Do not use --prerelease unless specifically needed.

Requires .NET 8+.

Azure Resources Required

For Teams and other Azure Bot Service channels:

Microsoft Entra App Registration

  • ClientId — Application (client) ID
  • ClientSecret — Certificates & secrets
  • TenantId — Directory (tenant) ID

Azure Bot Resource

  • Messaging endpoint: https://<your-host>/api/messages
  • Microsoft App ID must match ClientId

Anonymous local testing with Agents Playground does not require an Azure Bot. With the Quick Start hosting setup, authentication is disabled by default in the Development environment.

Configuration (appsettings.json)

See Configure authentication in your agent (.NET) for MSAL credential types and configuration settings. Connection settings acquire outbound tokens; the TokenValidation section configures validation of inbound tokens.

Single connection (most common)

appsettings.json — no secret here (safe to commit):

json
{
"Connections": {
"ServiceConnection": {
"Settings": {
"AuthType": "ClientSecret",
"AuthorityEndpoint": "https://login.microsoftonline.com/<tenantId>",
"ClientId": "<appId>",
"Scopes": ["https://api.botframework.com/.default"]
}
}
},
"ConnectionsMap": [
{
"ServiceUrl": "*",
"Connection": "ServiceConnection"
}
],
"TokenValidation": {
"Audiences": ["<appId>"],
"TenantId": "<tenantId>"
}
}

appsettings.Development.json — secret lives here (excluded via .gitignore):

json
{
"Connections": {
"ServiceConnection": {
"Settings": {
"ClientSecret": "<secret>"
}
}
}
}
How ConnectionsMap works

Each entry maps a ServiceUrl pattern to a named connection. The first matching entry wins.

  • ServiceUrl: "*" — matches any service URL (use as the default/fallback)
  • Other values are treated as regex patterns
Multiple connections (different identities per channel)
json
{
"Connections": {
"MainConn": {
"Settings": {
"AuthType": "ClientSecret",
"AuthorityEndpoint": "https://login.microsoftonline.com/<tenantId>",
"ClientId": "<app-id-1>",
"ClientSecret": "<secret-1>",
"Scopes": ["https://api.botframework.com/.default"]
}
},
"TeamsConn": {
"Settings": {
"AuthType": "ClientSecret",
"AuthorityEndpoint": "https://login.microsoftonline.com/<tenantId>",
"ClientId": "<app-id-2>",
"ClientSecret": "<secret-2>",
"Scopes": ["https://api.botframework.com/.default"]
}
}
},
"ConnectionsMap": [
{
"ServiceUrl": "https://smba.trafficmanager.net/.*",
"Connection": "TeamsConn"
},
{
"ServiceUrl": "*",
"Connection": "MainConn"
}
]
}
Auth type variants

UserManagedIdentity (no secret, Azure-hosted only):

json
{
"Connections": {
"ServiceConnection": {
"Settings": {
"AuthType": "UserManagedIdentity",
"ClientId": "<msi-clientId>",
"Scopes": ["https://api.botframework.com/.default"]
}
}
}
}

FederatedCredentials (no secret, App Registration + MSI):

json
{
"Connections": {
"ServiceConnection": {
"Settings": {
"AuthType": "FederatedCredentials",
"AuthorityEndpoint": "https://login.microsoftonline.com/<tenantId>",
"ClientId": "<appId>",
"FederatedClientId": "<msi-clientId>",
"Scopes": ["https://api.botframework.com/.default"]
}
}
}
}
Available connection settings fields

AuthType, AuthorityEndpoint, ClientId, ClientSecret, TenantId, FederatedClientId, FederatedTokenFile, Scopes, CertSubjectName, CertThumbprint, CertStoreName

Local development and inbound authentication

With the Quick Start setup, AddAgentAuthorization skips its authentication callback in Development and enables it in other environments. MapDefaultAgentEndpoints automatically applies the matching authorization requirement. Set ASPNETCORE_ENVIRONMENT=Development for anonymous local testing; no token-validation configuration switch is needed.

To test authenticated requests locally, replace the authorization registration with:

csharp
builder.AddAgentAuthorization(
b => b.AddAgentAspNetAuthentication(),
forceEnable: true);

Supply valid TokenValidation:Audiences, TokenValidation:TenantId, and connection settings when authentication is enabled. Keep production outside Development; do not force anonymous access in a deployed agent.

Quick Start

Use the current `samples/dotnet/quickstart` as the startup reference.

Prerequisite: Copy its `AspNetExtensions.cs` into your project. This sample helper provides AddAgentAspNetAuthentication for JWT token validation.

Program.cs:

csharp
using Microsoft.Agents.Hosting.AspNetCore;
using Microsoft.Agents.Storage;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
builder.AddAgentDefaults()
.AddAgent<MyAgent>()
.AddAgentAuthorization(b => b.AddAgentAspNetAuthentication());
builder.Services.AddSingleton<IStorage, MemoryStorage>();
var app = builder.Build();
app.UseAgents();
app.MapDefaultAgentEndpoints();
app.Run();

The explicit MemoryStorage registration matches the quickstart, but is optional: the SDK falls back to MemoryStorage if IStorage is not registered. Use a persistent provider for production (see Storage).

MyAgent.cs — put the AgentApplication subclass in its own file (see AgentApplication Patterns below for routing, state, and auth examples).

Properties/launchSettings.json:

json
{
"profiles": {
"MyAgent": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:3979;http://localhost:3978"
}
}
}

Run: dotnet run

.gitignore — ensure appsettings.Development.json is excluded (it contains secrets):

appsettings.Development.json

Teams app manifest (if targeting Teams): Use the teams-app-manifest skill from agents-sdk-common to generate or validate a manifest against the agent's implemented Teams capabilities. For a starting example, copy `quickstart/appManifest`, including the icons. Update manifest.json:

  • Replace all ${{AAD_APP_CLIENT_ID}} with your bot's Client ID
  • Set name.short and name.full to your bot's display name
  • Replace <<BOT_DOMAIN>> with the agent's host name and update the app metadata and URLs

Program.cs Structure

Minimal setup

Use the Quick Start Program.cs above. The responsibilities are:

CallPurpose
AddAgentDefaults()Register the default HTTP client factory and MVC/authorization services
AddAgent<MyAgent>()Register the agent and its application options
AddAgentAuthorization(b => b.AddAgentAspNetAuthentication())Configure inbound JWT authentication outside Development by default
UseAgents()Add authentication and authorization middleware in the correct order
MapDefaultAgentEndpoints()Map GET / and agent message endpoints, applying the configured authorization requirement
With proactive messaging endpoints
csharp
app.MapAgentProactiveEndpoints<MyAgent>(requireAuth: !app.Environment.IsDevelopment());

Add this before app.Run(). If authentication is forced on in Development, also set requireAuth: true for these separately mapped proactive endpoints.

With custom routes
csharp
var app = builder.Build();
app.UseAgents();
app.MapDefaultAgentEndpoints();
app.MapGet("/health", () => Results.Json(new { ok = true }));
app.Run();
Agent class decorators
csharp
[Agent(name: "MyAgent", description: "A helpful agent", version: "1.0")]
[AgentInterface(protocol: AgentTransportProtocol.ActivityProtocol, path: "/api/messages")]
public class MyAgent : AgentApplication
{
// ...
}
Important: AddAgent vs AddAgentApplicationOptions
  • builder.AddAgent<T>() — registers the agent class. Always required.
  • Do not call AddAgentApplicationOptions() separately unless you have a specific reason — AddAgent handles it.
Important: Default vs manual endpoint mapping
  • Prefer MapDefaultAgentEndpoints() for AgentApplication subclasses with the hosting setup above.
  • MapAgentRootEndpoint() and MapAgentApplicationEndpoints(requireAuth: ...) remain available for manual endpoint/authentication control.
  • MapAgentEndpoints — for ActivityHandler / TeamsActivityHandler compat layer bots

Do not use the compat-layer mapper for an AgentApplication subclass.

Validating Your Configuration

1. Validate bot credentials (ClientId / ClientSecret / TenantId)
bash
curl -s -X POST \
"https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token" \
-d "grant_type=client_credentials\
&client_id=$clientId\
&client_secret=$clientSecret\
&scope=https://api.botframework.com/.default" \
| jq '{token_type, expires_in, error, error_description}'

Common errors:

  • AADSTS700016 — ClientId not found in tenant (wrong ID or wrong tenant)
  • AADSTS7000215 — invalid ClientSecret (expired or incorrect)
  • AADSTS90002 — TenantId not found
2. Validate the agent is running and reachable
bash
curl -s -o /dev/null -w "%{http_code}" \
http://localhost:3978/
  • 200 — the root health endpoint is reachable; this does not prove message processing or authentication works
  • 000 or connection refused — agent is not running or wrong port

An unauthenticated POST /api/messages should return 401 when endpoint authorization is enabled. An empty JSON object is not a valid test activity, so do not expect a successful message response from posting {} with anonymous access. Use Agents Playground to verify the complete message flow.

3. Validate an OAuth connection name

OAuth connection names can only be tested end-to-end via:

Azure Portal → Your Bot Resource → Settings → OAuth Connection Settings → [your connection] → Test Connection

Local Testing with Agents Playground

The Agents Playground lets you test locally without deploying to Azure.

Install:

bash
npm install -g agentsplayground

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 7 Aug 2026.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
1,024
Repository forks
331
7-day trend score
35

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill CERTIFIED badge
[![vskill CERTIFIED](https://verified-skill.com/api/v1/skills/microsoft/agents/agents-sdk-dotnet/badge)](https://verified-skill.com/skills/microsoft/agents/agents-sdk-dotnet)

Something wrong with this skill or its page? Tell us.