This sample project demonstrates how to configure Azure Active Directory (Azure AD) authentication for a .NET Core application. It also includes Swagger UI for easy interaction with single sign-on (SSO).
Before you begin, make sure you have the following:
- Azure AD account and application registered.
- .NET Core SDK installed.
- Visual Studio Code or your preferred code editor.
- Postman or a similar tool for testing.
-
Clone this repository:
git clone https://github.com/yourusername/azure-ad-dotnet-core-swagger.git cd azure-ad-dotnet-core-swagger -
Open the project in your code editor.
-
Update the
appsettings.jsonfile with your Azure AD application details:
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "yourtenant.onmicrosoft.com",
"TenantId": "your-tenant-id",
"ClientId": "your-client-id",
"CallbackPath": "/signin-oidc"
}- Build and run the application:
dotnet build
dotnet runFollow these steps to configure Azure AD for the application:
- Sign in to the Azure portal.
- Create a new Azure AD application.
- Configure the application with the appropriate redirect URIs.
- Note the Client Id and Tenant Id and update the appsettings.json file in your project.
- refer LaunchSettings.json for multiple launch options.
- with IIS Express swagger ui is accessible at https://localhost:44303/swagger/index.html
