Skip to content

GettingStarted

Mika Berglund edited this page Dec 29, 2025 · 6 revisions

Getting Started With Blazorade ID

This page walks you through the necessary steps to get Blazorade ID configured in your application. Blazorade ID supports the following types of Blazor applications.

Each of these applications have slightly different setup steps, and are separately described below.

Overview

The following list provides a brief overview of the steps required. You can use this as a checklist if you are not configuring Blazorade ID for the first time.

  1. Add Nuget package Blazorade.Id
  2. Add @using statements to your _Imports.razor file
  3. Add router assemblies (Router.AdditionalAssemblies)
  4. Register Blazorade ID services that match your Blazor application type
  5. Configure your authority settings

When you have completed, the setup, head over to the Blazorade ID Samples section for more information on how to use Blazorade ID in your application.

Setup Steps

Follow the steps below to configure Blazorade ID in your application.

1. Blazorade ID Nuget Package

Add the Blazorade.Id Nuget package to your Blazor application.

2. @using Statements

Locate your _Imports.razor file. It it typically in the root of your project, but can be stored in other locations as well. Add the following @using statements to it.

@using Blazorade.Id.Services
@using Blazorade.Id.Configuration
@using Blazorade.Id.Model
@using Blazorade.Id.Components
@using Blazorade.Id.Components.Pages

3. Register Blazorade ID Services

Blazorade ID relies heavily on a set of services that are registered in a standard .NET Dependency Injection service collection.

You do this typically in your Program.cs file where all the other services are also registered.

Regardless of what your application type is, you should find a WebApplicationBuilder variable in that file. This builder should expose a Services collection property.

Add the necessary Blazorade ID services to that collection as shown below.

For Blazor Server applications, you register the required services like this:

builder.Services
    .AddBlazoradeIdServerApplication();

In Blazor WebAssembly (WASM) applications, the services are registered like this:

builder.Services
    .AddBlazoradeIdWasmApplication();

The AddBlazoradeIdServerApplication() / AddBlazoradeIdWasmApplication() methods both return an instance of the BlazoradeIdBuilder class. You use this builder instance to further configure your application. You can also use it as a short cut to register your custom service implementations, if you need to customize Blazorade ID.

4. Configure Authority Settings

You need to register your Identity Provider (IdP) as an authority with Blazorade ID. You do this by adding options to the same service collection you added the services to above.

The sample below describes how you configure your authority for Blazor WASM applications, but you do the same in Blazor Server applications as well.

builder.Services
    .AddBlazoradeIdWasmApplication()
    .AddAuthority((sp, options) => 
    {
        var config = sp.GetRequiredService<IConfiguration>();
        config.GetRequiredSection("blazorade:id").Bind(options);
    });

You can of course get the necessary option values from any service that is available through the IServiceProvider instance passed to the delegate. The code above assumes that you have the following section in your application configuration file.

{
  "blazorade": {
    "id": {
      "discoverydocumenturi": "https://yourtenant.ciamlogin.com/yourtenant.onmicrosoft.com/v2.0/.well-known/openid-configuration",
      "clientid": "{Your application Client ID}",
      "scope": "{Default scopes to use in your application}",
      "enablesilentauthorizationcodeflow": {true or false}
    }
  }
}

The example above assumes that you are using a Microsoft Entra External ID tenant called yourtenant. See Configuring Your Application in Microsoft Entra ID for details on how to register your application in Microsoft Entra ID.

For details on how to configure Blazorade ID in your application, please refer to the docs for the AuthorityOptions class.

Note! Blazorade ID does not require any secrets to be stored in the application settings. DO NOT store secrets such as client secrets or passwords in the application settings.

Clone this wiki locally