Net6 Minimal Api | Azure AD Authentication
How to Azure AD authentication Net6 Minimal Api?
In this video I have demonstrated Implementing azure AD authentication in .net 6 minimal APIs. We have used Visual studio capabilities to configure Azure Active Directory Authentication in .Net6 minimal API.
We have created a .Net6 project as Minimal API support is added from dotnet 6 and going to add Azure AD authentication for the same. While creating the project we need to uncheck the controllers checkbox and it will create minimal API project.
---------------------------------------------------------------
First step is to create an app registration for the api app. after that we need to configure Azure AD using visual studio. To configure Azure AD Authentication,Double click on connected services which is under the project file, it opens a tab. In that under service dependencies, click on + symbol. It will open a window. In that select Microsoft Identity platform and follow the wizard. In the next step, it will show you the window where you can select the previously created app registration with which the Azure AD will be configured to asp.net core web api/minimal api project. click on next and finish. It will add all required packages for configuring .net6 minimal api azure ad authentication and also adds azure ad configuration in appsettings.json file. It adds azure ad instance configuration in appsettings.json with clientid, instance, tenantid etc details.
--------------------------------------------------------------------------
After the previous step, we need to add code in Program.cs and call required methods for .net6 asp.net core web api minimal api azure ad authentication.
In this demo, we have created a .net6 minimal api endpoint which can only be accessed by the user who has authorization with "Manager" role.
------------------------------------------------------------------------
After that, we need to goto app registration, create the roles and expose it as an api by adding the scopes. We have used postman to test the application. for that we need to create another app registration and in the minimal api's app registration, we need to add the new app registration as client app registration in expose as an api section. To test the changes with postman, we have to use implicit authentication and choose oAuth2.0 authorization flow. we can get azure ad oauth2.0 code url from the overview page of app registration by clicking on endpoints. we need to provide scopes in postman tool and logon with any user who has manager role for Azure AD authentication and authorization to test minimal api azure ad authentication.
--------------------------------------------------------------------------
Chapters
00:00 Intro
00:31 Creating .Net6 Minimal API Azure Ad authentication Project
01:20 Configuring Azure AD to .Net6 Minimal API project
08:35 Creating Azure AD roles for the user
12:12 Testing Azure AD Authentication with Postman
Buy Me A Coffee - https://www.buymeacoffee.com/azuretea...