简体   繁体   中英

Azure Active Directory Authentication - 500 Error on Azure

I have an ASP.Net Core 3.1 application that is authenticating against Azure AD. Everything authenticates when I run it locally from VS, but when I deploy the app to Azure, I get a 500 error: [myappname].azurewebsites.net is currently unable to handle this request. This is my configuration in my startup.cs file.

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

I have the redirect URIs setup in Azure as https://[my-appname].azurewebsites.net/signin-oidc as well as the localhost. I am not sure what I am missing.

UPDATE: I setup the logs within Azure and this is what the 500 error is. Any ideas what might be happening? 在此处输入图像描述

HTTP 500 means internal error. There was an unhandled exception some where in your code.

When I get this problem I set up Application Insights and watch the log stream, to see what is actually failing.

See: https://microsoft.github.io/AzureTipsAndTricks/blog/tip30.html

Turns out that this had nothing to do with Azure Active Directory. It was an issue with accessing the SQL database and I resolved it by adding permissions within the SQL server to allow my application access to the SQL database. This post helped me to figure this out: https://docs.microsoft.com/en-us/answers/questions/8602/msdn-redirect-publishing-aspnet-web-api-to-azure-a.html

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