Create .NET agents in Visual Studio using the Microsoft 365 Agents Toolkit

In this article, you learn how to create a new Agents SDK .NET project in Visual Studio, using the Microsoft 365 Agents Toolkit.

Note

Before you begin, you need to install the Agents Toolkit extension for Visual Studio.

Create a new project

The Agents Toolkit provides a project template to help you get started with building an agent. You can start from a template in the toolkit or from samples in the Agents SDK. This document focuses on the templates available in the Agents Toolkit.

Note

The procedure that follows currently works for .NET only.

  1. To build a new agent project, open Visual Studio and select Create a new project. Search for "agent" to find new templates using the Microsoft 365 Agent Toolkit and Agents SDK Select Microsoft 365 Agents > Next.

    Create a new project

    A dialog appears so that you can name the agent. You can also change the location and solution name if you want to.

  2. When you are finished, select Next

    Configure your new project

  3. The next dialog prompts you for the agent type to choose. You can select a few different options the toolkit provides for creating agents. To use the Microsoft 365 Agents SDK, you should select the Weather Agent sample. This prebuilt sample implements Semantic Kernel for orchestration with Azure AI Foundry or Azure OpenAI models. You can also use the Empty agent sample if you want to get started without a model or orchestrator set up.

    Select the type of app to create

    Select llm type to use for model

  4. For this walkthrough, select Azure AI Foundry and complete the required inputs. Including the key, endpoint and deployment name. This information can be found in Azure AI Foundry under Models and endpoints.

    Configure settings to connect to the chosen LLM service

  5. Select Create. The toolkit creates the project from a template for you, ready to get started.

  6. In a short amount of time, you should have a new project created which utilizes the Agents SDK.

    App code in editor

Test your agent in Microsoft 365 Agents Playground

To get started, you can test locally using the Microsoft 365 Agents Playground in the Toolkit.

To start testing, select the debug target in your project to be Microsoft 365 Agents Playground."

The playground opens for you to test in a new browser window with your local host and shows the playground with it ready to test. Start sending messages to your agent to test it's behaviour.

Debug and test your agent in Microsoft Teams or Microsoft 365 Copilot

You can also set the debug target to be directly in Microsoft Teams or Microsoft 365 Copilot.

  1. Select one of the debugging options as the debug target from the list of targets.

    Select Microsoft Teams (browser)

    It takes a few moments to Microsoft Teams. You're prompted to add your agent in the Teams Client that opens.

    Teams prompt to add agent

  2. Select Add. A notification pane appears, indicating that the agent is added successfully.

    Agent added successfully to Teams, prompt to open

  3. Select Open on your new agent to open in Teams. You can ask questions of your agent, directly in Teams. You can set breakpoints to work through debugging your experience when required.

    Agent running in M365 Copilot

Summary

You have now successfully:

  • Started a new Microsoft 365 Agents project and agent using the Agents Toolkit
  • Tested the agent locally using the Microsoft 365 Agents Playground
  • Deployed the agent for debugging directly in the Teams or Microsoft 365 channel