{"id":232876,"date":"2021-06-07T08:43:31","date_gmt":"2021-06-07T15:43:31","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=232876"},"modified":"2021-06-07T08:43:31","modified_gmt":"2021-06-07T15:43:31","slug":"build-apps-for-microsoft-teams-with-net","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/build-apps-for-microsoft-teams-with-net\/","title":{"rendered":"Build apps for Microsoft Teams with .NET"},"content":{"rendered":"<p>We recently announced updates to the Teams Toolkit &#8211; a streamlined way to create, debug, and deploy apps to Microsoft Teams. In this post, we\u2019re taking a closer look at how to get started developing a new Microsoft Teams app with .NET and Blazor using the Teams Toolkit extension for Visual Studio 2019 that\u2019s in early Preview.<\/p>\n<h2>What are Teams apps?<\/h2>\n<p>Microsoft Teams apps extend the functionality of Teams to fit your team&#8217;s needs in an integrated and connected way.\u00a0Your app could\u00a0be simple and send notifications or get more complex and provide integration with your CRM to add, lookup, and\u00a0review customer data.<\/p>\n<h2>Download and install the Teams Toolkit extension<\/h2>\n<p>To get started\u00a0building Teams apps,\u00a0<a href=\"https:\/\/aka.ms\/teams-toolkit-vs\" target=\"_blank\" rel=\"noopener\">visit the Teams Toolkit in the Visual Studio Marketplace<\/a>\u00a0and click the Download button.\u00a0Once downloaded, click the\u00a0Microsoft.VisualStudio.TeamsToolkit.vsix\u00a0file to begin the installation process.\u00a0Click Install to add the extension to Visual Studio 2019.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-2021-06-07-103012.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-232924\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-2021-06-07-103012.png\" alt=\"VSIX installer dialog\" width=\"436\" height=\"332\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-2021-06-07-103012.png 436w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-2021-06-07-103012-300x228.png 300w\" sizes=\"(max-width: 436px) 100vw, 436px\" \/><\/a><\/p>\n<h2>Getting started using project templates<\/h2>\n<p>You\u2019re now ready to create your first Microsoft Teams app. One of the features included is a new project template. Currently, the template creates a Blazor Server application that is setup to work with Teams and includes all the dependencies you\u2019ll want to get started.\nTo begin, launch Visual Studio 2019\u00a0and click\u00a0<strong>Create a new project<\/strong>.\u00a0In the dialog, search for Teams to find the new Microsoft Teams App project template. Once selected, click\u00a0<strong>Next<\/strong>.<\/p>\n<p>Configure your project details on the screens that follow. The dialog gives you an opportunity to provide a name for your Teams app, but it can be changed or configured later too. Finally, clicking <strong>Create<\/strong> will complete the process and open your new solution in Visual Studio 2019.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-2021-06-07-103743.png\"><img decoding=\"async\" class=\"aligncenter wp-image-232925 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-2021-06-07-103743.png\" alt=\"Visual Studio new project dialog\" width=\"931\" height=\"630\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-2021-06-07-103743.png 931w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-2021-06-07-103743-300x203.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-2021-06-07-103743-768x520.png 768w\" sizes=\"(max-width: 931px) 100vw, 931px\" \/><\/a><\/p>\n<h2>Configure\u00a0identity\u00a0with one\u00a0click<\/h2>\n<p>One of our focuses with the Teams Toolkit is to help developers create apps that integrate with Teams with as close to zero-configuration as possible. We\u2019ve also listened to feedback on some of the challenges of creating Teams apps today and focused on making identity and single sign-on (SSO) simpler to setup.<\/p>\n<p>Before you start debugging,\u00a0navigate to the\u00a0<strong>Project &gt;\u00a0TeamsFx<\/strong>\u00a0menu and click the\u00a0<strong>Configure for SSO\u2026<\/strong> menu option. Select an account with a Microsoft 365 tenant and all the required dependencies will be setup for your app. If you don\u2019t have M365, sign up for the <a href=\"https:\/\/developer.microsoft.com\/en-us\/microsoft-365\/dev-program\" target=\"_blank\" rel=\"noopener\">Microsoft Developer Program<\/a>\u00a0first, which allows you to have a testing tenant with preconfigured permissions.<\/p>\n<h2>Start debugging your app in\u00a0Teams<\/h2>\n<p>That\u2019s all the setup that is needed to get started, so the next step is\u00a0run\u00a0your app.\u00a0It\u2019s as easy as\u00a0clicking the\u00a0Start Debugging\u00a0button in the toolbar or\u00a0using\u00a0the\u00a0<strong>Debug &gt; Start Debugging<\/strong>\u00a0menu option.\u00a0Visual Studio will launch Teams in a browser and offer to add your app. Click the\u00a0Add\u00a0button\u00a0to see your application running in Teams.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Picture1.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-232926\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Picture1.png\" alt=\"Add button in Teams\" width=\"306\" height=\"260\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Picture1.png 306w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Picture1-300x255.png 300w\" sizes=\"(max-width: 306px) 100vw, 306px\" \/><\/a><\/p>\n<p>The project template includes sample code to demonstrate the basics of\u00a0getting information about the authenticated user. Clicking\u00a0the Authorize button\u00a0will\u00a0prompt the user to accept the additional permissions required to use Microsoft Graph.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Picture2.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-232927\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Picture2.png\" alt=\"New app running inside Teams\" width=\"624\" height=\"570\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Picture2.png 624w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2021\/06\/Picture2-300x274.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<h2>Exploring the project template<\/h2>\n<p>The project template includes a few dependencies and project setup criteria to make developing Teams app simpler.<\/p>\n<h3>Microsoft.TeamsFx.SimpleAuth<\/h3>\n<p>Included\u00a0as a package reference\u00a0and\u00a0<a href=\"https:\/\/github.com\/OfficeDev\/TeamsFx\/tree\/main\/packages\/simpleauth\" target=\"_blank\" rel=\"noopener\">available on GitHub<\/a>\u00a0is the\u00a0Microsoft.TeamsFx.SimpleAuth\u00a0library which\u00a0helps with token acquisition for single sign-on. This is configured in the project\u00a0as middleware\u00a0with a\u00a0single line of code in the\u00a0ConfigureServices\u00a0method of the Startup class.<\/p>\n<pre>services.AddTeamsFxSimpleAuth(Configuration);<\/pre>\n<h3>Microsoft.Fast.Components.FluentUI<\/h3>\n<p>To help\u00a0build applications that\u00a0look and feel at home inside Teams, we\u2019ve included a new package that provides\u00a0a set of lightweight\u00a0Blazor\u00a0component wrappers around Fluent UI web components.\u00a0These are\u00a0optional for your application, but are provided by default to make it easy to build the UI of your app.\u00a0This project is <a href=\"https:\/\/github.com\/microsoft\/fast-blazor\" target=\"_blank\" rel=\"noopener\">available on GitHub<\/a> and we&#8217;d love your feedback!<\/p>\n<h2>Teams\u00a0app manifest<\/h2>\n<p>All the details and configuration for a Teams app are controlled with a Teams app manifest. Inside the Properties folder of the project you\u2019ll find the manifest.json file. Use the manifest to configure the name of your Teams app, endpoints of the hosted web app, and which capabilities are provided. Visit <a href=\"https:\/\/docs.microsoft.com\/en-us\/microsoftteams\/platform\/resources\/schema\/manifest-schema\" target=\"_blank\" rel=\"noopener\">the documentation to learn more about the manifest file<\/a>.<\/p>\n<pre>\"developer\": {\r\n\"name\":\u00a0\"My Company\",\r\n\"websiteUrl\":\u00a0\"https:\/\/localhost:44357\",\r\n\"privacyUrl\":\u00a0\"https:\/\/localhost:44357\/privacy\",\r\n\"termsOfUseUrl\":\u00a0\"https:\/\/localhost:44357\/termsofuse\"\r\n},\r\n<\/pre>\n<p>After making changes to the manifest file, you can use the\u00a0<strong>Project &gt;\u00a0TeamsFx\u00a0&gt; Update Teams\u00a0Manifest<\/strong>\u00a0menu to update your application in the Teams Developer Portal.<\/p>\n<h2>Share your feedback\u00a0and explore Teams\u00a0apps<\/h2>\n<p>The Teams Toolkit extension for Visual Studio 2019 is currently in Preview and during this time we\u2019re encouraging developers to try it out and share their feedback with us. We appreciated all the feedback we receive and it helps us deliver experiences that truly matter to you. To share your feedback, use the <strong>Help &gt; Submit Feedback<\/strong>\u00a0menu in Visual Studio.\u00a0Also, be sure to\u00a0visit the documentation and learn more\u00a0about developing applications for Microsoft Teams!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create, debug, and deploy web apps directly in Teams with Visual Studio and Blazor using an early preview of the Teams Toolkit extension available for Visual Studio 2019 today. Learn more about the Teams Toolkit and follow along to get started in under 5 minutes. <\/p>\n","protected":false},"author":557,"featured_media":232931,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[155,1029],"tags":[237,1377,6210,294,880,6811,6812],"class_list":["post-232876","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio","category-web","tag-net","tag-asp-net-core","tag-blazor","tag-extensions","tag-get-started","tag-teams","tag-web-apps"],"acf":[],"blog_post_summary":"<p>Create, debug, and deploy web apps directly in Teams with Visual Studio and Blazor using an early preview of the Teams Toolkit extension available for Visual Studio 2019 today. Learn more about the Teams Toolkit and follow along to get started in under 5 minutes. <\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/232876","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/557"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=232876"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/232876\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/232931"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=232876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=232876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=232876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}