Microsoft 365 Agents Toolkit CLI
The Microsoft 365 Agents Toolkit CLI, the atk command, is the Agents Toolkit for your terminal: it creates projects from Microsoft's templates, signs in to Microsoft 365 and Azure, registers your app, provisions Azure resources, deploys and packages. For C# developers it has one extra use: unlike the VS Code extension, it creates C# projects, on Windows, macOS or Linux.
What You Need
- Node.js 20 (20.19 or later), or 22.12 or later, with npm. This page uses Node.js 26 LTS with npm 12. Check with
node --versionandnpm --version.
Step 1: Install the CLI
The CLI is an npm package. Install it globally, so atk works in every folder:
npm install -g @microsoft/m365agentstoolkit-cli --allow-scripts=keytar
changed 548 packages in 9s
npm warn install-scripts 2 packages had install scripts blocked because they are not covered by allowScripts:
npm warn install-scripts @microsoft/m365agentstoolkit-cli@1.1.19 (postinstall: node deletePS1.js)
npm warn install-scripts @azure/msal-node-extensions@1.5.32 (install: exit 0)
npm warn install-scripts
npm warn install-scripts Run `npm install -g --allow-scripts=@microsoft/m365agentstoolkit-cli,@azure/msal-node-extensions` to allow these scripts once, or `npm config set allow-scripts=@microsoft/m365agentstoolkit-cli,@azure/msal-node-extensions --location=user` to allow them for all global installs.
Why --allow-scripts=keytar? npm 12 doesn't run packages' install scripts unless you allow them. One of the CLI's dependencies, keytar, uses its install script to get the native code that stores secrets in your operating system's credential store, such as the macOS Keychain. The CLI uses it to protect the sign-in tokens it caches; without it, keytar can't load, and the CLI keeps those tokens unencrypted. --allow-scripts=keytar lets that one script run. Fixed: "npm warn install-scripts … had install scripts blocked because they are not covered by allowScripts" shows what happens without it and how I found out.
The two scripts npm still lists are harmless to skip on macOS and Linux: the CLI's own deletePS1.js removes a leftover PowerShell file from an old version of the toolkit, and @azure/msal-node-extensions' install script is exit 0, which does nothing. If you're on npm 11, which comes with Node.js 26, npm runs install scripts by default and you can leave the option out.
My output says changed because the CLI was already installed; on a first install it says added.
Step 2: Check It
atk --version
1.1.19
That's the newest release at the time of writing. atk --help lists everything the CLI can do:
Commands:
add Add feature to your app.
auth Manage Microsoft 365 and Azure accounts.
collaborator Check, grant and list permissions for who can access and manage app and Microsoft Entra application.
deploy [options] Run the deploy stage in m365agents.yml or m365agents.local.yml.
doctor [options] Prerequisite checker for building apps.
entra-app Manage the Microsoft Entra app in the current application.
env Manage environments.
export Export a Microsoft 365 Agents Toolkit project to an external agent plugin format.
help Show Microsoft 365 Agents Toolkit CLI help.
import Import an external agent plugin into a Microsoft 365 Agents Toolkit project.
install [options] Upload a given application package across Microsoft 365.
launchinfo [options] Get launch information of an acquired M365 App.
list List available app templates and samples.
new [options] Create a new app.
package [options] Build your app into a package for publishing.
preview [options] Preview the current application.
provision [options] Run the provision stage in m365agents.yml or m365agents.local.yml.
publish [options] Run the publish stage in m365agents.yml.
regenerate Regenerate existing resources for your app.
share [options] Run the 'share stage' in m365agents.yml or share the app with other users.
uninstall [options] Clean up resources associated with Manifest ID, Title ID, or an environment in Microsoft 365 Agents Toolkit generated project.
Resources include app registration in Developer Portal, bot registration in Bot Framework Portal, and uploaded custom apps in apps.
update [options] Update the app manifest to Developer Portal.
validate [options] Validate the app using manifest schema, validation rules, or test cases.
The ones you'll meet most:
| Command | What it does |
|---|---|
atk new | Creates a project from a template |
atk auth | Signs the CLI in to Microsoft 365 or Azure |
atk provision | Runs the provision steps of the project's m365agents.yml: registers the app and the bot, and creates Azure resources |
atk deploy | Runs the deploy steps: copies your code to Azure |
atk preview | Starts the app on your machine (it detects dotnet run for C# projects) and opens it in Teams, Outlook or the Microsoft 365 app |
atk package | Builds the app package (the manifest and icons, zipped) for uploading |
The CLI sends usage telemetry to Microsoft by default; add --telemetry false to a command to turn it off.
Step 3: Create a C# Project
atk list templates lists the templates. Its language column shows only each template's default language, but many have C# versions too; you choose one with -l csharp. Create Microsoft's weather agent in C#:
atk new -c weather-agent -l csharp -n WeatherTemplate -i false --llm-service llm-service-azure-openai --azure-openai-endpoint https://foundry-devblogs-exp.openai.azure.com/ --azure-openai-deployment-name gpt-5.6-luna
-c weather-agentpicks the template;-l csharpits C# version;-n WeatherTemplatenames the project and its folder.-i falseturns off the interactive questions, so everything comes from the command line. Leave it out and the CLI asks you instead.- The last three options tell the template which AI service to use. Use your own endpoint and deployment name.
████████████████████ 100% | [1/1] Create (✔) Done.
Project created at: /Users/you/source/WeatherTemplate
The project has the agent itself and everything the toolkit needs to take it to Teams and Azure:
WeatherTemplate/
├── .M365Agent/ the toolkit's project and launch settings for Visual Studio
├── appPackage/ the Teams and Copilot app manifest and icons
├── Bot/ the agent: AgentApplication, Semantic Kernel agent and plugins
├── env/ settings per environment: .env.local, .env.dev
├── infra/ Bicep templates for the Azure resources
├── Properties/
│ └── launchSettings.json
├── appsettings.json the agent's settings, including the Azure OpenAI ones
├── AspNetExtensions.cs checks that requests really come from Azure Bot Service
├── Config.cs
├── m365agents.local.yml what provision and deploy do for local debugging
├── m365agents.yml what provision and deploy do in Azure
├── Program.cs
└── WeatherTemplate.csproj
It builds as it is. Before you run it, two things are worth knowing.
Two Things to Know About the C# Templates
They target .NET 8. The project file says <TargetFramework>net8.0</TargetFramework>, and .NET 8 reached the end of its support on November 10, 2026. On a machine with only .NET 10, dotnet run stops with You must install or update .NET to run this application. Change the line to net10.0 and rebuild: Fixed: "You must install or update .NET to run this application" walks through it.
The weather template uses an API key and Semantic Kernel. Its Program.cs connects to Azure OpenAI with an API key from appsettings.json, and stops at startup if the key is empty:
Unhandled exception. System.ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'apiKey')
It also uses Semantic Kernel, including one preview package. This course builds the same weather agent from an empty project instead, on Microsoft Agent Framework and with Microsoft Entra ID instead of a key: Building a Weather Forecast Agent in C#. The template is still a useful map of everything a toolkit project contains.
Uninstall
npm uninstall -g @microsoft/m365agentstoolkit-cli
Frequently Asked Questions
What happened to teamsapp?
It's the old name of the same CLI. The package still installs a teamsapp command alongside atk, but running it prints Deprecation Warning: The CLI command "teamsapp" is renamed to "atk". The old command name will be retired soon. Use atk.
Do I need the CLI if I use Visual Studio?
No. Visual Studio's Agents Toolkit component does the same jobs from menus. The CLI is for VS Code users, macOS and Linux, and automation such as CI/CD pipelines.
Is it free?
Yes. The CLI is free, like the rest of the Agents Toolkit.
Additional Resources
- Microsoft 365 Agents Toolkit CLI — Microsoft's reference for every command.
- Microsoft 365 Agents Toolkit formats — the CLI, the VS Code extension and Visual Studio compared.
- npm install-scripts — how npm 12 decides which install scripts run.