Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Design Principles

Mika Berglund edited this page Jan 6, 2021 · 1 revision

Design Principles of Blazorade Teams

Blazorade Teams is designed to make Microsoft Teams application development with Blazor super easy. So easy that it might just be THE easiest way. This is primarily achieved by following the following guiding principles.

  • Handle application initialization
  • Handle user authentication
  • Handle communications with the Teams SDK
  • Support both Blazor Server and Blazor WebAssembly
  • Allow any UI framework

Handle Application Initialization

For some developers, especially those with lots of experience with various JavaScript libaries, it might be easy to get started with the Teams JavaScript SDK. However, that's not the case for everybody.

And, since the Teams SDK is all JavaScript, you would need to do a lot of wizardry, since the Teams SDK has a lot of callback methods that will get pretty tricky in Blazor applications. Even if you would get a hang of it, there is a lot of boilerplate code that you would need to write in all your Teams applications just to get your application properly initialized.

So, that's why all of this is taken care of by Blazorade Teams. You can write your application relying on the fact that all of the information has been resolved for you before your application gets to do its magic.

For more information on how to write your Blazor applications with Blazorade Teams, see Build Your First Application.

Handle User Authentication

Teams does not automatically take care of authenticating your user. It will only provide you with a "login hint" that is not to be mistaken for the authenticated user. So you would properly need to authenticate the user.

Yes, the Teams SDK provides you with a method to open an authentication dialog to authenticate the user, but that requires additional user action. But the user is already authenticated with Teams, so why would you need to bother the user with another authentication dialog?

That's why Blazorade Teams includes functionality that takes care of authenticating the user without user interaction. This is done using MSAL.js that also caches the tokens it receives from Azure AD, and refreshes them also when they expire.

Usually, your users will only see the login dialog the first time they use your application, when they need to consent to the delegated permissions your application requests. And if you consent to the permissions as an admin on behalf of your organization, your users will never see the login and consent dialog.

Handle Communications with the Teams SDK

The Teams SDK is all JavaScript. All method invocations have to be made from JavaScript or through JavaScript interop provided by Blazor.

The thing where this gets a bit tricky is that many of the API calls in the Teams SDK require that you pass in a callback function that the SDK will call with the information you requested.

Blazorade Teams leverages the TaskCompletionSource<TResult> class to build a promise that you can use in your .NET code like any other async function.

So for instance, to get the Context object from the Teams SDK, you simply call the GetContextAsync method on the BlazoradeTeamsInteropModule class instead of using interop to call the getContext method, and somehow try to get the callback calling back to your Blazor code. The GetContextAsync method will use JavaScript interop to call the method on the Teams SDK, and route the response back to your code.

Support Blazor Server and Blazor WebAssembly

Since the Teams SDK is all JavaScript, you could just as well write your Teams applications as pure JavaScript applications. Having your application running more or less only on the client will radically reduce the hosting costs for your application.

Since Blazorade Teams supports both Blazor Server and Blazor WebAssembly, you could run your application as a standard ASP.NET server application, or use static website hosting in Azure Storage accounts or use the Static Web Apps feature. You could even run your Teams apps for free on GitHub pages.

Allow Any UI Framework

Blazorade Teams is not about UI frameworks or UI components. It will probably never ship with anything that renders a UI. Instead, it focuses on making it super easy for you to write Teams applications with Blazor and taking care of the heavy lifting involved.

This will allow you to use whatever UI framework you like to build your Teams application. You might want to have a look at Blazorade Bootstrap, if you want to build your application using Bootstrap.