Official agent skill

M365 Agents Dotnet

by microsoft in microsoft/skills

Microsoft 365 Agents SDK for .NET. An agent skill from microsoft/skills.

OfficialMITAuto-check passedDocuments & Office

Install M365 Agents Dotnet

skills CLI
$ npx skills add microsoft/skills --skill m365-agents-dotnet -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install microsoft/skills m365-agents-dotnet --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/microsoft/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.github/plugins/azure-sdk-dotnet/skills/m365-agents-dotnet .claude/skills/m365-agents-dotnet && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
m365-agents-dotnet
GitHub stars
3.1k
Used in
6 other repos
Token cost
~2.5k tokens
SKILL.md length
175 words
Files
1
Skills in repo
150
Repo updated
First seen
Licence
MIT

At a glance

Microsoft 365 Agents SDK for .NET. An agent skill from microsoft/skills.

  • Works in 6 steps: Use AgentApplication subclasses to… → Use MemoryStorage only for development;… → Enable TokenValidation in production and… → …
  • Tasks that involve Cloud office suites
  • SKILL.md covers Overview, Before implementation, Installation and Configuration (appsettings.json), plus 5 more sections
  • Calls dotnet; reaches login.microsoftonline.com and api.botframework.com

What it does

M365 Agents Dotnet is an agent skill from microsoft/skills, published by the product's own GitHub organization. Microsoft 365 Agents SDK for .NET. Build multichannel agents for Teams/M365/Copilot Studio with ASP.NET Core hosting, AgentApplication routing, and MSAL-based auth. Triggers: "Microsoft 365 Agents SDK", "Microsoft.Agents", "AddAgentApplicationOptions", "AgentApplication", "AddAgentAspNetAuthentication", "Copilot Studio client", "IAgentHttpAdapter".

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Documents & Office, covering Cloud office suites. It works with Microsoft 365, .NET, Microsoft Copilot Studio and ASP.NET Core. The repository describes itself as: Skills, MCP servers, Custom Agents, Agents.md for SDKs to ground Coding Agents. The licence is MIT.

When your agent uses it

  • Tasks that involve Cloud office suites

Example prompts

  • “Microsoft 365 Agents SDK”
  • “Microsoft.Agents”
  • “AddAgentApplicationOptions”
  • “/m365-agents-dotnet”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Use AgentApplication subclasses to centralize routing and error handling.
  2. Use MemoryStorage only for development; use persisted storage in production.
  3. Enable TokenValidation in production and require authorization on /api/messages.
  4. Keep auth secrets in configuration providers (Key Vault, managed identity, env vars).
  5. Reuse HttpClient from IHttpClientFactory and cache MSAL tokens.
  6. Prefer async handlers and pass CancellationToken to SDK calls.

What it can do on your machine

Read from SKILL.md and the folder at commit 354361d. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • dotnet

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • login.microsoftonline.com
    • api.botframework.com

    Also links to:

    • learn.microsoft.com
    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

M365 Agents Dotnet loads about 2.5k tokens when it runs. Until then it costs about 92 tokens; SKILL.md has 175 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~92
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from microsoft/skills at commit 354361d, republished under its MIT licence (© microsoft). 175 words, ~2,512 tokens.

Download SKILL.mdSave it as .claude/skills/m365-agents-dotnet/SKILL.md (or your agent's skills folder).
name
m365-agents-dotnet
description
Microsoft 365 Agents SDK for .NET. Build multichannel agents for Teams/M365/Copilot Studio with ASP.NET Core hosting, AgentApplication routing, and MSAL-based auth. Triggers: "Microsoft 365 Agents SDK", "Microsoft.Agents", "AddAgentApplicationOptions", "AgentApplication", "AddAgentAspNetAuthentication", "Copilot Studio client", "IAgentHttpAdapter".
license
MIT
metadata.author
Microsoft
metadata.version
1.0.0
metadata.package
Microsoft.Agents.Hosting.AspNetCore, Microsoft.Agents.Authentication.Msal, Microsoft.Agents.CopilotStudio.Client

Microsoft 365 Agents SDK (.NET)

Overview

Build enterprise agents for Microsoft 365, Teams, and Copilot Studio using the Microsoft.Agents SDK with ASP.NET Core hosting, agent routing, and MSAL-based authentication.

Before implementation

  • Use the microsoft-docs MCP to verify the latest APIs for AddAgent, AgentApplication, and authentication options.
  • Confirm package versions in NuGet for the Microsoft.Agents.* packages you plan to use.

Installation

bash
dotnet add package Microsoft.Agents.Hosting.AspNetCore
dotnet add package Microsoft.Agents.Authentication.Msal
dotnet add package Microsoft.Agents.Storage
dotnet add package Microsoft.Agents.CopilotStudio.Client
dotnet add package Microsoft.Identity.Client.Extensions.Msal

Configuration (appsettings.json)

json
{
  "TokenValidation": {
    "Enabled": true,
    "Audiences": ["{{ClientId}}"],
    "TenantId": "{{TenantId}}"
  },
  "AgentApplication": {
    "StartTypingTimer": false,
    "RemoveRecipientMention": false,
    "NormalizeMentions": false
  },
  "Connections": {
    "ServiceConnection": {
      "Settings": {
        "AuthType": "ClientSecret",
        "ClientId": "{{ClientId}}",
        "ClientSecret": "{{ClientSecret}}",
        "AuthorityEndpoint": "https://login.microsoftonline.com/{{TenantId}}",
        "Scopes": ["https://api.botframework.com/.default"]
      }
    }
  },
  "ConnectionsMap": [
    {
      "ServiceUrl": "*",
      "Connection": "ServiceConnection"
    }
  ],
  "CopilotStudioClientSettings": {
    "DirectConnectUrl": "",
    "EnvironmentId": "",
    "SchemaName": "",
    "TenantId": "",
    "AppClientId": "",
    "AppClientSecret": ""
  }
}

Core Workflow: ASP.NET Core agent host

csharp
using Microsoft.Agents.Builder;
using Microsoft.Agents.Hosting.AspNetCore;
using Microsoft.Agents.Storage;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddHttpClient();
builder.AddAgentApplicationOptions();
builder.AddAgent<MyAgent>();
builder.Services.AddSingleton<IStorage, MemoryStorage>();

builder.Services.AddControllers();
builder.Services.AddAgentAspNetAuthentication(builder.Configuration);

WebApplication app = builder.Build();

app.UseAuthentication();
app.UseAuthorization();

app.MapGet("/", () => "Microsoft Agents SDK Sample");

var incomingRoute = app.MapPost("/api/messages",
    async (HttpRequest request, HttpResponse response, IAgentHttpAdapter adapter, IAgent agent, CancellationToken ct) =>
    {
        await adapter.ProcessAsync(request, response, agent, ct);
    });

if (!app.Environment.IsDevelopment())
{
    incomingRoute.RequireAuthorization();
}
else
{
    app.Urls.Add("http://localhost:3978");
}

app.Run();

AgentApplication routing

csharp
using Microsoft.Agents.Builder;
using Microsoft.Agents.Builder.App;
using Microsoft.Agents.Builder.State;
using Microsoft.Agents.Core.Models;
using System;
using System.Threading;
using System.Threading.Tasks;

public sealed class MyAgent : AgentApplication
{
    public MyAgent(AgentApplicationOptions options) : base(options)
    {
        OnConversationUpdate(ConversationUpdateEvents.MembersAdded, WelcomeAsync);
        OnActivity(ActivityTypes.Message, OnMessageAsync, rank: RouteRank.Last);
        OnTurnError(OnTurnErrorAsync);
    }

    private static async Task WelcomeAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken ct)
    {
        foreach (ChannelAccount member in turnContext.Activity.MembersAdded)
        {
            if (member.Id != turnContext.Activity.Recipient.Id)
            {
                await turnContext.SendActivityAsync(
                    MessageFactory.Text("Welcome to the agent."),
                    ct);
            }
        }
    }

    private static async Task OnMessageAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken ct)
    {
        await turnContext.SendActivityAsync(
            MessageFactory.Text($"You said: {turnContext.Activity.Text}"),
            ct);
    }

    private static async Task OnTurnErrorAsync(
        ITurnContext turnContext,
        ITurnState turnState,
        Exception exception,
        CancellationToken ct)
    {
        await turnState.Conversation.DeleteStateAsync(turnContext, ct);

        var endOfConversation = Activity.CreateEndOfConversationActivity();
        endOfConversation.Code = EndOfConversationCodes.Error;
        endOfConversation.Text = exception.Message;
        await turnContext.SendActivityAsync(endOfConversation, ct);
    }
}

Copilot Studio direct-to-engine client

DelegatingHandler for token acquisition (interactive flow)
csharp
using System.Net.Http.Headers;
using Microsoft.Agents.CopilotStudio.Client;
using Microsoft.Identity.Client;

internal sealed class AddTokenHandler : DelegatingHandler
{
    private readonly SampleConnectionSettings _settings;

    public AddTokenHandler(SampleConnectionSettings settings) : base(new HttpClientHandler())
    {
        _settings = settings;
    }

    protected override async Task<HttpResponseMessage> SendAsync(
        HttpRequestMessage request,
        CancellationToken cancellationToken)
    {
        if (request.Headers.Authorization is null)
        {
            string[] scopes = [CopilotClient.ScopeFromSettings(_settings)];

            IPublicClientApplication app = PublicClientApplicationBuilder
                .Create(_settings.AppClientId)
                .WithAuthority(AadAuthorityAudience.AzureAdMyOrg)
                .WithTenantId(_settings.TenantId)
                .WithRedirectUri("http://localhost")
                .Build();

            AuthenticationResult authResponse;
            try
            {
                var account = (await app.GetAccountsAsync()).FirstOrDefault();
                authResponse = await app.AcquireTokenSilent(scopes, account).ExecuteAsync(cancellationToken);
            }
            catch (MsalUiRequiredException)
            {
                authResponse = await app.AcquireTokenInteractive(scopes).ExecuteAsync(cancellationToken);
            }

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authResponse.AccessToken);
        }

        return await base.SendAsync(request, cancellationToken);
    }
}
Console host with CopilotClient
csharp
using Microsoft.Agents.CopilotStudio.Client;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);

var settings = new SampleConnectionSettings(
    builder.Configuration.GetSection("CopilotStudioClientSettings"));

builder.Services.AddHttpClient("mcs").ConfigurePrimaryHttpMessageHandler(() =>
{
    return new AddTokenHandler(settings);
});

builder.Services
    .AddSingleton(settings)
    .AddTransient<CopilotClient>(sp =>
    {
        var logger = sp.GetRequiredService<ILoggerFactory>().CreateLogger<CopilotClient>();
        return new CopilotClient(settings, sp.GetRequiredService<IHttpClientFactory>(), logger, "mcs");
    });

IHost host = builder.Build();
var client = host.Services.GetRequiredService<CopilotClient>();

await foreach (var activity in client.StartConversationAsync(emitStartConversationEvent: true))
{
    Console.WriteLine(activity.Type);
}

await foreach (var activity in client.AskQuestionAsync("Hello!", null))
{
    Console.WriteLine(activity.Type);
}

Best Practices

  1. Use AgentApplication subclasses to centralize routing and error handling.
  2. Use MemoryStorage only for development; use persisted storage in production.
  3. Enable TokenValidation in production and require authorization on /api/messages.
  4. Keep auth secrets in configuration providers (Key Vault, managed identity, env vars).
  5. Reuse HttpClient from IHttpClientFactory and cache MSAL tokens.
  6. Prefer async handlers and pass CancellationToken to SDK calls.

© microsoft, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .github/plugins/azure-sdk-dotnet/skills/m365-agents-dotnet of microsoft/skills.

Open the folder on GitHubat commit 354361d

Used in 6 other repositories

We found 18 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 6 other GitHub owners. This page covers the copy in microsoft/skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

M365 Agents Dotnet next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

M365 Agents Dotnet compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
M365 Agents Dotnet this skillmicrosoft/skills3.1k6 repos~2.5kAutomated safety check: PassMIT
AI Agent PostureSCStelz/security-investigator249—~21kAutomated safety check: PassMIT
Msgraph SDKgithub/awesome-copilot40k—~2.1kAutomated safety check: PassMIT
Purview Dspm AIvinayaklatthe/microsoft-security-skills175—~1.5kAutomated safety check: PassMIT
Code Reviewpnp/powershell905—~385Automated safety check: PassMIT
CLI Microsoft365pnp/cli-microsoft365-mcp-server131—~3.5kAutomated safety check: PassMIT

Similar skills

  • AI Agent Posture

    SCStelz/security-investigator

    Audit or report on AI agent security posture across Copilot Studio, Microsoft 365 Copilot, Microsoft Foundry, and third-party agents.

    249 GitHub stars~21k tokensUpdated 2 days ago
    Documents & OfficeAuto-check passed
  • Msgraph SDK

    github/awesome-copilot

    Official

    Integrate Microsoft Graph SDK into any project — .NET, TypeScript/JavaScript, or Python.

    40k GitHub stars~2.1k tokensUpdated today
    Documents & OfficeAuto-check passed
  • Purview Dspm AI

    vinayaklatthe/microsoft-security-skills

    Guidance for Microsoft Purview Data Security Posture Management for AI (DSPM for AI) - discovering, monitoring, and protecting sensitive data interactions with generative AI apps like Microsoft 365…

    175 GitHub stars~1.5k tokensUpdated 3 mo ago
    Documents & OfficeAuto-check passed
  • Code Review

    pnp/powershell

    Reviews changes to PnP PowerShell, a .NET 8 module of 800+ cmdlets for Microsoft 365.

    905 GitHub stars~385 tokensUpdated yesterday
    DevelopmentAuto-check passed
  • CLI Microsoft365

    pnp/cli-microsoft365-mcp-server

    Use CLI for Microsoft 365 to manage Microsoft 365 tenants from the terminal.

    131 GitHub stars~3.5k tokensUpdated 3 days ago
    Documents & OfficeAuto-check passed
  • Spfx Release

    pnp/docker-spfx

    Automate SPFx version releases - branch, update files, commit, open PR, then tag after merge

    134 GitHub stars~572 tokensUpdated 3 mo ago
    Documents & OfficeAuto-check: notes

More from microsoft/skills

All 150 skills in this repo
  • Official

    Reference for building on Microsoft Foundry with the azure-ai-projects Python SDK: project clients, versioned agents, evaluations, connections, datasets and indexes.

    3.1k GitHub starsUsed in 6 repos~2.8k tokens
    Auto-check passed
  • Official

    Python guidance for the Azure AI Search SDK covering vector, hybrid and semantic search, index management and indexers, with Entra ID authentication preferred over keys.

    3.1k GitHub starsUsed in 6 repos~4.4k tokens
    Auto-check passed
  • Official

    Covers producer, consumer, and checkpoint-store setup for Azure Event Hubs streaming in Python, with Entra ID auth and partition targeting.

    3.1k GitHub starsUsed in 1 repo~2.3k tokens
    Auto-check passed
  • Pydantic Models Py

    microsoft/skills

    Official

    Create Pydantic models following the multi-model pattern with Base, Create, Update, Response, and InDB variants.

    3.1k GitHub starsUsed in 6 repos~496 tokens
    Auto-check passed
  • DebugView CLI

    microsoft/skills

    Official

    Captures and filters Windows user-mode and kernel debug output from the command line with the Sysinternals DebugView CLI, including bounded runs suited to agents.

    3.1k GitHub starsUsed in 1 repo~2.7k tokens
    Auto-check passed
  • Frontend UI Dark TS

    microsoft/skills

    Official

    Build dark-themed React applications using Tailwind CSS with custom theming, glassmorphism effects, and Framer Motion animations.

    3.1k GitHub starsUsed in 5 repos~3.6k tokens
    Auto-check passed

Questions about M365 Agents Dotnet

What does M365 Agents Dotnet do?

Microsoft 365 Agents SDK for .NET. An agent skill from microsoft/skills. M365 Agents Dotnet is an agent skill from microsoft/skills, published by the product's own GitHub organization.NET.

When should I use M365 Agents Dotnet?

M365 Agents Dotnet fits situations like: tasks that involve Cloud office suites.

How do I install M365 Agents Dotnet in Claude Code?

Run `npx skills add microsoft/skills --skill m365-agents-dotnet -a claude-code`. Or copy the skill folder (.github/plugins/azure-sdk-dotnet/skills/m365-agents-dotnet in microsoft/skills) into .claude/skills/m365-agents-dotnet in your project. Claude Code loads it when a task matches its description.

How do I install M365 Agents Dotnet in Codex?

Run `npx skills add microsoft/skills --skill m365-agents-dotnet -a codex`. Or copy the skill folder (.github/plugins/azure-sdk-dotnet/skills/m365-agents-dotnet in microsoft/skills) into .agents/skills/m365-agents-dotnet in your project. Codex loads it when a task matches its description.

Can I use M365 Agents Dotnet in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add microsoft/skills --skill m365-agents-dotnet -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/m365-agents-dotnet, .gemini/skills/m365-agents-dotnet, .github/skills/m365-agents-dotnet and .opencode/skills/m365-agents-dotnet in your project.

What does M365 Agents Dotnet need to run?

Going by SKILL.md and its folder, M365 Agents Dotnet needs the command-line tools its instructions call (dotnet).

Does M365 Agents Dotnet access the network?

SKILL.md names 4 domains. In commands or code: login.microsoftonline.com and api.botframework.com; the agent is likely to contact these when it follows the instructions. As links in the text: learn.microsoft.com and github.com. This is read from the text; nothing was executed.

Is M365 Agents Dotnet safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does M365 Agents Dotnet use?

M365 Agents Dotnet is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does M365 Agents Dotnet use?

About 2.5k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to M365 Agents Dotnet?

Skills that share tags, products or a category with M365 Agents Dotnet: AI Agent Posture (SCStelz/security-investigator, 249 stars), Msgraph SDK (github/awesome-copilot, 40k stars), Purview Dspm AI (vinayaklatthe/microsoft-security-skills, 175 stars) and Code Review (pnp/powershell, 905 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains M365 Agents Dotnet?

microsoft (a GitHub organization, an official publisher) maintains it in microsoft/skills, which has 3,091 GitHub stars. The repository holds 150 skills in this directory. The repository was last updated on October 6, 2026.

Source: microsoft/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.