Debug your Microsoft Teams app using Microsoft Visual Studio
Microsoft Teams Toolkit automates app startup services, initiates debugging, and uploads Teams app. After debugging, you can preview the Teams app in Teams web client. You can also customize debug settings to use your bot endpoints, or environment variables to load your configured app. Visual Studio allows you to debug tabs, bots, and message extensions.
Prerequisites
Install | For using... | |
---|---|---|
Visual Studio 2022 | You can install the enterprise edition of Visual Studio, and install the ASP.NET workload and Microsoft Teams Development Tools. Use the latest version | |
Teams Toolkit | A Visual Studio extension that creates a project scaffolding for your app. Use latest version. | |
Microsoft Teams | Microsoft Teams to collaborate with everyone you work with through apps for chat, meetings, and call-all in one place. | |
Prepare your Microsoft 365 tenant | Access to Teams account with the appropriate permissions to install an app. | |
Microsoft 365 developer account | Access to Teams account with the appropriate permissions to install an app. | |
Azure Tools and Microsoft Azure CLI | Azure tools to access stored data or deploy a cloud-based backend for your Teams app in Azure. |
Key features of Teams Toolkit
Teams Toolkit automates the local debugging process for the following key features:
Prepare Teams app dependencies: Teams Toolkit prepares local debug dependencies and registers your Teams app in your tenant account. For Bot and Message Extension apps, Teams Toolkit registers and configures bot.
Start debugging: You can perform debugging with a single operation, press F5 to start debugging. Teams Toolkit builds code, starts services, and launches the app in your browser.
Toggle breakpoints: You can toggle breakpoints in the source code of tabs, bots, message extensions, and Azure Functions. The breakpoints execute when you interact with the Teams app in your web browser.
The following image shows the toggle breakpoints:
Hot Reload: Select Hot Reload to apply your changes in your Teams app when you want to update and save the source code during debugging.
To enable auto Hot Reload, select Hot Reload on File Save from the dropdown.
Tip
To learn more about the Hot Reload function, see .NET Hot Reload experience.
Stop debugging: Select Stop Debugging (Shift+F5) when the local debug is complete.
Add environment variables
You can add the environmentVariables
to the launchSettings.json
file.
Launch Teams app as a web app
You can launch Teams app as a web app instead of running the app in Teams client. To launch your Teams app as a web app, follow these steps:
In Solution Explorer, under Project, select Properties > launchSettings.json.
Remove the
launchUrl
property.Right-click on Solution (in this scenario the project name is MyTeamsApp1) and select Properties.
A solution property pages dialog box appears.
Select Configuration Properties > Configuration in the dialog box.
Clear the Deploy checkbox.
Select OK.
Next
See also
Platform Docs