Skip to main content

Posts

Showing posts from April, 2025

Adding Entra ID Authentication to a Blazor App

I wanted to take the time to write up this article since I found it useful when working on Blazor Apps. Althought this is not Sitecore related, I think it will be useful if we need to build an admin .NET portal. Additionally most organizations already have Entra ID if they use Microsoft apps and building Entra ID Authentication wont add costs like other Authentication methods would. To get started make sure the following packages are available (using NuGet) in your solution. Microsoft.Identity.Web Microsoft.Identity.Web.UI Azure.Security In your Program.cs file, add the following using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.Identity.Web; using Microsoft.Identity.Web.UI; // Add Microsoft Entra ID authentication builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) .AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd")); builder.Services.AddAuthorization(options => { options.FallbackPo...