0
votes

We created an application in VS 2017 using a .Net Core Web template. We since realised that we actually need to reference some packages that are full framework packages.

So we changed the target framework to 4.6.2.

However now when the web app is deployed to azure, I am consistently getting the error:

HTTP Error 502.5 - Process Failure Common causes of this issue: The application process failed to start The application process started but then stopped The application process started but failed to listen on the configured port Troubleshooting steps: Check the system event log for error messages Enable logging the application process' stdout messages Attach a debugger to the application process and inspect For more information visit: https://go.microsoft.com/fwlink/?LinkID=808681

It appears to be failing to even start, but I am unsure of what changes I need to make to get this working.

When I publish it a web.config file is created up on the server, which contains this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--ProjectGuid: db77cdb1-05c4-450e-94d8-5dabc48c6d76-->
<system.webServer>
<handlers>
<add resourceType="Unspecified" modules="AspNetCoreModule" verb="*" path="*" name="aspNetCore"/>
</handlers>
<aspNetCore stdoutLogFile=".\logs\stdout" stdoutLogEnabled="true" processPath=".\Genesis.IdentityServer.exe"/>
</system.webServer>
</configuration>

I enabled logging.

The error in the event log up on the azure debug console is as follows:

<Event>
<System>
<Provider Name=".NET Runtime"/>
<EventID>1026</EventID>
<Level>0</Level>
<Task>0</Task>
<Keywords>Keywords</Keywords>
<TimeCreated SystemTime="2017-09-01T06:14:38Z"/>
<EventRecordID>868107718</EventRecordID>
<Channel>Application</Channel>
<Computer>RD0003FFC3731F</Computer>
<Security/>
</System>
<EventData>
<Data>Application: Genesis.IdentityServer.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: Microsoft.Net.Http.Server.WebListenerException at Microsoft.Net.Http.Server.ServerSession..ctor() at Microsoft.Net.Http.Server.WebListener..ctor(Microsoft.Net.Http.Server.WebListenerSettings) at Microsoft.AspNetCore.Server.WebListener.MessagePump..ctor(Microsoft.Extensions.Options.IOptions`1<Microsoft.AspNetCore.Server.WebListener.WebListenerOptions>, Microsoft.Extensions.Logging.ILoggerFactory) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite, Microsoft.Extensions.DependencyInjection.ServiceProvider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].VisitCallSite(Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceCallSite, System.__Canon) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(Microsoft.Extensions.DependencyInjection.ServiceLookup.ScopedCallSite, Microsoft.Extensions.DependencyInjection.ServiceProvider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(Microsoft.Extensions.DependencyInjection.ServiceLookup.SingletonCallSite, Microsoft.Extensions.DependencyInjection.ServiceProvider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].VisitCallSite(Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceCallSite, System.__Canon) at Microsoft.Extensions.DependencyInjection.ServiceProvider+<>c__DisplayClass16_0.<RealizeService>b__0(Microsoft.Extensions.DependencyInjection.ServiceProvider) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(System.Type) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(System.IServiceProvider, System.Type) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.IServiceProvider) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureServer() at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at Genesis.IdentityServer.Program.Main(System.String[]) </Data>
</EventData>
</Event>
<Event>
<System>
<Provider Name="IIS AspNetCore Module"/>
<EventID>1000</EventID>
<Level>0</Level>
<Task>0</Task>
<Keywords>Keywords</Keywords>
<TimeCreated SystemTime="2017-09-01T06:14:38Z"/>
<EventRecordID>868107937</EventRecordID>
<Channel>Application</Channel>
<Computer>RD0003FFC3731F</Computer>
<Security/>
</System>
<EventData>
<Data>Application 'MACHINE/WEBROOT/APPHOST/GENIDENTITYSERVER' with physical root 'D:\home\site\wwwroot\' failed to start process with commandline 'D:\home\site\wwwroot\Genesis.IdentityServer.exe ', ErrorCode = '0x80004005 : e0434352.</Data>
</EventData>
</Event>
</Events>

This is baffling me, can I not simply target framework 462 from my .net core app?

EDIT

I turned on detailed errors and now see:

HTTP Error 502.5 - Bad Gateway The specified CGI application encountered an error and the server terminated the process.

Most likely causes: The CGI application did not return a valid set of HTTP errors. A server acting as a proxy or gateway was unable to process the request due to an error in a parent gateway.

Things you can try: Use DebugDiag to troubleshoot the CGI application. Determine if a proxy or gateway is responsible for this error.

Detailed Error Information: Module AspNetCoreModule Notification ExecuteRequestHandler Handler aspNetCore Error Code 0x00000000 Requested URL http://GenIdentityServer:80/favicon.ico Physical Path D:\home\site\wwwroot\favicon.ico Logon Method Anonymous Logon User Anonymous

I put a try catch around the WebHostBuilder().build call and this is what is logged:

Access is denied   at Microsoft.Net.Http.Server.ServerSession..ctor()
   at Microsoft.Net.Http.Server.WebListener..ctor(WebListenerSettings settings)
   at Microsoft.AspNetCore.Server.WebListener.MessagePump..ctor(IOptions`1 options, ILoggerFactory loggerFactory)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass16_0.<RealizeService>b__0(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureServer()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at Genesis.IdentityServer.Program.Main(String[] args)
1
The stack trace in the event log is almost unreadable and for some reason there is no message associated with the WebListenerException that seems to be the culprit. I suggest that you surround the call to WebHostBuilder.Build() in your Main method with a try-catch and then log any exception thrown in a way so that you can read it (write exception.ToString() to the log). One reason you might get a WebListenerException is because the process is trying to bind to port that is inaccessible or already in use.Martin Liversage
I updated the issue with the error that I see from the detailed error logs in azureC. Moore

1 Answers

0
votes

Ok I didn't realise that this had been added to the code:

//.UseWebListener(options => //{ // options.ListenerSettings.Authentication.Schemes = AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM; // options.ListenerSettings.Authentication.AllowAnonymous = true; //})

which of course won't work on azure!