简体   繁体   中英

Azure App Service Authentication with Active Directory

I have a dotnet core api in an app service on Azure. When I run this locally, with authentication switched on, I can generate a bearer token and use that to successfully access the end points.

On azure, when authentication is switched off I can access the end points, but when I switch authentication on in azure, I can't access any end points with a token. Postman is just returning the standard response "The page cannot be displayed because an internal server error has occurred".

I can't see anything in application insights so I'm really in the dark.

Hoping someone will know of any common issues that could be behind this.

Thanks in advance

You cannot access your web app authenticated with Azure AD using B2C token .

On local, created web app using Visual Studio only have three authentication choices: 在此处输入图像描述 As we can see, using Individual User Account is connecting to an Azure AD B2C account.

On portal, you could configure your app service with choices below: 在此处输入图像描述 If you are using Log in with Azure Active Directory, you should concern it is not same as B2C. Follow this page to configure Azure AD authentication with web app .

Get the AAD bear token:

  1. Navigate to the app registrations page in your Azure Active Directory, choose the one you created in configuring authentication step. You would see the information like this: 在此处输入图像描述
  2. Go to Certificates & secrets page to create a secret, and copy that value, cause you would not see it after leave this page. 在此处输入图像描述
  3. Open Postman to get the access token, here is the required parameters: 在此处输入图像描述 在此处输入图像描述 在此处输入图像描述
  4. Use the bear token you got from last step to access your web app: 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM