Azure B2C is a business to customer identity management as a service. Basically, using Azure AD B2C service, customer can use their social, and local account identities to get a SSO (Single sign on) access to your applications and APIs. In this blog you will learn how to integrate Azure B2C Service with our ASP.NET Core Web application.
- Azure B2C tenant
- Visual studio 2022 with .NET 6
Before going through this blog, please learn more about Azure AD B2C here.
Azure B2C integration with ASP.NET Core application:
Step 1: Open visual studio and create a new ASP.NET Core web application using MVC template as shown in below figure.
Step 2: Enter a project name, in my case I have named it as ADB2CIM, and click on next.
. Step 4: Install the required components
Step 5: Complete the app registration in Azure B2C using Azure portal, as shown in the below figures
Jump in to you B2C services, and select app registration.
Click on new registration.
Provide app name, supported account types, redirect URI.
In redirect URI select web app, since we are registering for web application. Provide a redirect URI in my case I have given it as ‘https://localhost:7084/’, leave default setting for Permissions and click on Register.
Step 5: In Visual Studio, switch to B2C account and select the appropriate application from the wizard, as shown in below figure.
Step 6: Advance settings
Skip the advance setting and click on finish
Step 7: Make sure service dependencies are configured properly, as shown in below figure.
Run the application, you will get the sign in page, if no users are added to the tenant, please sign up the user.
The flow will redirect to the home page once the user authentication is successful.
We have seen how to quickly start with the AD B2C integration with ASP.NET Core application. I will share more insight about the features available in Azure AD B2C in my next blog.