Add Microsoft Entra ID authentication (Members)

Learn how to use Microsoft Entra ID (Azure Active Directory) credentials to login to Umbraco as a member.

This tutorial takes you through configuring Microsoft Entra ID (Azure Active Directory/Azure AD) for the member login on your Umbraco CMS website.

Prerequisites

  • A project with a setup for Members.

  • Visual Studio, or another Integrated Development Environment (IDE).

Step 1: Configure Entra ID

Before your applications can interact with Entra ID, they must be registered with a tenant that you manage. This can be either an Entra ID (Azure AD) tenant or an Entra ID B2C (Azure AD B2C) tenant. For more information on creating an Azure AD B2C tenant, see Microsoft's Tutorial: Quickstart: Use your Azure subscription to create an external tenant.

Follow these steps to register your web application with your Entra tenant and configure it for member sign-in:

  1. On the App Registrations screen, copy the Application (Client) ID value. You will need this in your code later.

  2. Click Add a certificate or secret.

Entra Example: App Registration Screen
  1. Add a new client secret and copy the generated Value. You will use this in your code as well.

  2. Return to the Overview screen and click Add a Redirect URI.

  3. Add full URLs for all of your applicable environments (local, dev, live, etc.) with the path /umbraco-b2c-members-signin appended. For example, https://mysite.com/umbraco-b2c-members-signin.

Step 2: Install the NuGet package

You need to install the Microsoft.AspNetCore.Authentication.MicrosoftAccount NuGet package. There are two approaches to installing the packages:

  1. Use your favorite Integrated Development Environment (IDE) and open up the NuGet Package Manager to search and install the packages.

  2. Use the command line to install the package.

Step 3: Implement the Entra ID Authentication

  1. Create a new class for custom configuration options: EntraIDB2CMembersExternalLoginProviderOptions.cs.

With autolinking, if a visitor uses Sign in with Microsoft and their email matches a member, that member is signed in. If no matching member exists, a new one is created. By default, it isn’t assigned to any groups.

  1. Create a new static extension class called MemberAuthenticationExtensions.cs.

Ensure to replace YOURCLIENTID and YOURCLIENTSECRET in the code with the values from the Entra ID tenant. If Entra ID is configured to use accounts in the organizational directory only (single tenant registration), you must specify the Token and Authorization endpoint. For more information on the differences between single and multi tenant registration, refer to Microsoft's identity platform documentation.

  1. Add the Members authentication configuration in the Program.cs file:

Are you building a package for Umbraco?

Then you will not have access to the Program.cs file. Instead you need to create a composer in order to register your extension method.

Learn more about this in the Dependency Injection article.

  1. Build the project.

  2. Run the website.

Entra ID Login Screen

Last updated