【发布时间】:2019-06-08 11:53:31
【问题描述】:
我正在尝试为 ASP.NET MVC 应用程序设置暂存环境,并希望将其作为 Azure Web 应用程序来实现,但此时我真的被困在 HTTP 500 上。
我得到的错误是:
500.79: The request failed because of an unhandled exception in the Easy Auth module.
使用诊断日志我能够获得堆栈跟踪:
2019-01-14T13:07:22 PID[14448] Critical System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.UriFormatException: Invalid URI: The format of the URI could not be determined.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString, UriKind uriKind)
at Microsoft.Azure.AppService.Middleware.ModuleConfig.set_OpenIdIssuer(String value)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at Microsoft.Azure.AppService.Middleware.MiddlewareConfig.TryLoadConfig(Type type, HttpContextBase context)
at Microsoft.Azure.AppService.Middleware.ModuleConfig.EnsureConfigLoaded(HttpContextBase context)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Azure.AppService.Middleware.ModuleManager.LoadModuleConfig(HttpContextBase context)
at Microsoft.Azure.AppService.Middleware.ModuleManager.LoadAllModulesAndGetEnabledModules(HttpContextBase context)
at Microsoft.Azure.AppService.Middleware.HttpModuleDispatcher.EnsureInitialized(HttpContextBase context)
at Microsoft.Azure.AppService.Middleware.HttpModuleDispatcher.<DispatchAsync>d__11.MoveNext()
我使用了在 Azure 上可以找到的任何其他诊断工具,但除了一个微弱的提示外,我无法弄清楚更多:使用失败的请求跟踪功能,我注意到这些跟踪表明向非常奇怪且明显错误的 URL 发出请求:
根据请求跟踪的 URL:https://Skillmanagementtest:80
实际请求的网址:https://skillmanagementtest.azurewebsites.net
我完全不知道这个 URL 或端口来自哪里;我从来没有在任何地方指定端口 80(无论如何它的 HTTPS 都是错误的)。 “Skillmanagementtest”是我给 Azure Web App 起的名字,我认为我没有在其他任何地方使用过它。用于身份验证的主页 URL 和回复 URL(使用 AAD 作为身份验证提供程序)设置正确。我的假设是,正是这个乱码的 URL 导致了 UriFormatException,但我不知道 URL 的来源......
也就是说,应用程序似乎可以正常启动(还有诸如日志框架将其文件放在启动时的工作),并且启动它也不会将任何错误放入诊断日志中,但是每当发出请求时,出现上述错误。
在本地和生产中(使用“经典”VM,而不是 Azure Web 应用程序)Web 应用程序运行没有问题,但我无法发现它们与 Azure Web 应用程序之间的配置有任何差异(当然除了不同的文件路径和数据库连接)。还给定名为 Azure 中间件的 Stack Trace 表明问题源于作为 Azure Web 应用运行的应用程序,并且作为唯一的手段,我几乎有它应该是一些配置错误......
作为设置暂存环境的一部分,我的目标是尽可能实现自动化。因此,我还设置了一个 CI/CD resp。使用 Azure DevOps 构建和发布管道。这似乎一切正常。配置方面,我在 web.config 上分别使用 XML 转换。 web.Staging.config 文件。转换均已正确应用。
--
对于任何可能出现问题的想法,我将非常感激,因为我自己几乎没有东西可以尝试(第三天我正试图让这个工作......)
~芬罗德
【问题讨论】:
标签: asp.net-mvc azure azure-web-app-service azure-configuration