简体   繁体   English

Azure Active Directory 身份验证 - Azure 上出现 500 错误

[英]Azure Active Directory Authentication - 500 Error on Azure

I have an ASP.Net Core 3.1 application that is authenticating against Azure AD.我有一个针对 Azure AD 进行身份验证的 ASP.Net Core 3.1 应用程序。 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.当我从 VS 在本地运行它时,一切都会进行身份验证,但是当我将应用程序部署到 Azure 时,我收到 500 错误:[myappname].azurewebsites.net 当前无法处理此请求。 This is my configuration in my startup.cs file.这是我在 startup.cs 文件中的配置。

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.我在 Azure 中将重定向 URI 设置为 https://[my-appname].azurewebsites.net/signin-oidc 以及 localhost。 I am not sure what I am missing.我不确定我错过了什么。

UPDATE: I setup the logs within Azure and this is what the 500 error is.更新:我在 Azure 中设置了日志,这就是 500 错误。 Any ideas what might be happening?任何想法可能会发生什么? 在此处输入图像描述

HTTP 500 means internal error. HTTP 500 表示内部错误。 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.当我遇到这个问题时,我设置了 Application Insights 并查看日志 stream,以查看实际失败的原因。

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

Turns out that this had nothing to do with Azure Active Directory.事实证明,这与 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.这是访问 SQL 数据库的问题,我通过在 SQL 服务器中添加权限来解决它,以允许我的应用程序访问 SQL 数据库。 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这篇文章帮助我解决了这个问题: https://docs.microsoft.com/en-us/answers/questions/8602/msdn-redirect-publishing-aspnet-web-api-to-azure-a.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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