HTTP 500.79 Error / System.UriFormatException when deploying ASP.NET App to Azure Web App

心已入冬 提交于 2019-12-11 06:38:57

问题


I am attempting to set up a Staging Environment for an ASP.NET MVC Application, and want to do that as an Azure Web App, but I am really stuck on an HTTP 500 at this point.

The error I get is:

500.79: The request failed because of an unhandled exception in the Easy Auth module.

Using diagnostics logs I was able to get a Stack Trace:

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()

I've used any other diagnostics tool that I was able to find on Azure, but was not able to figure out a lot more, except one faint hint: Using the Failed Request Tracing feature I noticed that those traces state that the requests were made to very odd and obviously wrong URL's:

URL according to Request Trace: https://Skillmanagementtest:80

Actually requested URL: https://skillmanagementtest.azurewebsites.net

Screenshot: Failed Request Trace

I have absolute no clue where either this URL or the port comes from; I have never specified port 80 anywhere (which is wrong anyway as its HTTPS). "Skillmanagementtest" is the name I have given the Azure Web App, and I don't think that I have used it anywhere else. The Home Page URL and the Reply URL for Authentication (using AAD as Authentication Provider) is set correctly. My assumption is, that it is this gibberish URL that causes the UriFormatException, but I've got no clue where the URL is coming from...

That said, the application seems to start up properly (also things like logging frameworks placing their files on startup works), and starting it up also does not place any errors into the diagnostic logs, but whenever a request is made, the above error occurs.

Locally and in production (using a "classical" VM, not an Azure Web App) the Web App runs without problem, but I was not able to spot any difference in configuration between those and the Azure Web App (except of course the different file paths and DB connections). Also given the Stack Trace naming an Azure Middleware suggests that the problem originates from the app being run as Azure Web App, and as the only leverage I pretty much have there it oughta be some configuration error...

As a part of setting up the Staging Environment I aim towards having as much as possible automated. Thus I have also set up a CI/CD resp. a Build and a Release Pipeline using Azure DevOps. This seems to work all fine. Configuration-wise I use XML Transformations on the web.config resp. web.Staging.config file. The transformations are all applied correctly.

--

For any ideas on what may be wrong I would be immensly grateful, as I myself have pretty much run out of things to try (third full day I am trying to get this to work...)

~ Finrod


回答1:


"Solution": I have fixed this error, respectively replaced it with a different one. The URL which was erronous was the "Issuer ID" in the "Authenticatio / Authorization" section of the App Service; I filled in the tenant (i.e. "xxxxx.onmicrosoft.com") instead of the issuer URL as explained here: https://docs.microsoft.com/en-us/azure/app-service/configure-authentication-provider-aad. However, I get a 403 now, when trying to make requests to the app. Will make a new question for this as I once more have no clue what to do, but maybe someone encounters this problem here as well.



来源:https://stackoverflow.com/questions/54182432/http-500-79-error-system-uriformatexception-when-deploying-asp-net-app-to-azur

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!