1
votes

I am trying to deploy an aspnet core app to Azure. This seems to have gone through OK but when I try to start up the app I am presented with the following error...

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

There seems to be much written about IIS in this but not with Azure so I'm at a loss as to where to look next. The Azure logs are not indicating anything.

The Microsoft docs give me this info...

Platform conflicts with RID

Browser: HTTP Error 502.5 - Process Failure

Application Log: - Application Error: Faulting module: KERNELBASE.dll Exception code: 0xe0434352 Faulting module path: C:\WINDOWS\system32\KERNELBASE.dll - IIS AspNetCore Module: Failed to start process with commandline '"dotnet" .\my_application.dll' (portable app) or '"PATH\my_application.exe"' (self-contained app), ErrorCode = '0x80004005'.

ASP.NET Core Module Log: Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'teststandalone.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Troubleshooting:

If you published a self-contained application, confirm that you didn't set a platform in buildOptions of project.json that conflicts with the publishing RID. For example, do not specify a platform of x86 and publish with an RID of win81-x64 (dotnet publish -c Release -r win81-x64). The project will publish without warning or error but fail with the above logged exceptions on the server.

...but don't actually help by telling me what these settings should be for Azure (or if it's relevant there) so I'm not sure if this is a red herring. I'm not specifying a -r switch on my dotnet publish configuration.

I managed to find an event log which threw out some XML repeatedly logging...

Failed to start process with commandline '"%LAUNCHER_PATH%" %LAUNCHER_ARGS%', ErrorCode = '0x80070002'.

After more investigation I discovered that I needed to change the %LAUNCHER_PATH% and %LAUNCHER_ARGS% values myself. I've tried various changes to the web.config but no luck. My web.config now looks like this...

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <!--
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
  -->

  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="dotnet" arguments="site\wwwroot\Esoterix.Modle.Portalweb.dll" stdoutLogEnabled="true" stdoutLogFile="LogFiles\stdout" forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>

The paths are from the root of the Azure deployment which seems to work for the stdout log file path (I was getting errors reported with that) but not for the app itself. I'm still seeing the following error..

<Event>
    <System>
        <Provider Name="IIS AspNetCore Module"/>
        <EventID>1000</EventID>
        <Level>0</Level>
        <Task>0</Task>
        <Keywords>Keywords</Keywords>
        <TimeCreated SystemTime="2016-11-28T19:31:32Z"/>
        <EventRecordID>1514022203</EventRecordID>
        <Channel>Application</Channel>
        <Computer>RD0004FFD7108D</Computer>
        <Security/>
    </System>
    <EventData>
        <Data>Failed to start process with commandline '"dotnet" site\wwwroot\Esoterix.Modle.Portalweb.dll', ErrorCode = '0x80004005'.</Data>
    </EventData>
</Event>

Which is repeated 4 times

If I look in my stdout output I have the following...

Failed to load the dll from [\?\D:\home\site\wwwroot\hostpolicy.dll], HRESULT: 0x800700C1

An error occurred while loading required library hostpolicy.dll from [\?\D:\home\site\wwwroot]

If I try running the exe directly with the web config here...

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <!--
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
  -->

  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="\\?\%home%\site\wwwroot\Esoterix.Modle.Portalweb.exe" arguments="" stdoutLogEnabled="true" stdoutLogFile="\\?\%home%\LogFiles\stdout" forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>

Then my stdout gives me the following error...

Failed to load the dll from [\?\D:\home\site\wwwroot\hostfxr.dll], HRESULT: 0x80070057

The library hostfxr.dll was found, but loading it from \?\D:\home\site\wwwroot\hostfxr.dll failed

1

1 Answers

1
votes

I resolved this by adding a reference to dotnet-publish-iis.

Full details on how to do this are logged in a github issue at https://github.com/aspnet/Hosting/issues/892