Christian
Christian

Reputation: 1194

How to add AzureAD Configuration to AspNetCore App

How can I add a corporate AzureAD Authetication to my aspnetcore app?

I add this to my ConfigureServices in Startup

services.AddAuthentication(AzureADDefaults.AuthenticationScheme).AddAzureAD(options => Configuration.Bind("AzureAd", options));

and want to add this to my appsettings.json file

  "AzureAd": {
"Instance": "",
"CallbackPath": "/signin-oidc",
"ClientId": "your client id",
"Domain": "sma.de",
"TenantId": "your tenant id"

}

But all I have are 3 Hostnames and a port and I have no idea to add this, so how is it done?

Upvotes: 1

Views: 598

Answers (1)

James S.
James S.

Reputation: 150

It does not matter that you have multiple hostnames. If they are hosting the same application you use a single "app registration".

You obtain the Client ID from the Azure portal in Azure Active Directory's App Registrations blade. Each app requires its own registration. If you have three hostnames you add each hostname as redirect URIs. For example if your three hostnames are host1, host2, and host3 all running on port 8081 (and if you're going to leave CallbackPath as is) you use the following redirect URIs in the app registration:

  • https://host1:8081/signin-oidc
  • https://host2:8081/signin-oidc
  • https://host3:8081/signin-oidc

If you are using the public Azure AD cloud the instance is https://login.microsoftonline.com/. The TenantId is up to you. You can use your own tenant's ID or if it's a multi-tenant corporate application you'd use "organizations".

This should be enough information to point you in the right direction.

Upvotes: 2

Related Questions