AspNetCore Debugging Startup issue in Azure Web App

Whilst upgrading from AspNetCore 2.0 to 2.1, some of the StartUp configuration had changed slightly and part of the upgrade required me to refactor code into the webhost builder. However as a result I didn’t quite do everything and after deploying to azure web app, I was hit with a 502 response. An exception being thrown in main(). This was a problem because it was happening before it could get to my logging initialization and therefore no logging was happening.

So in order to debug Azure Web App AspNetCore startup issues we need to enable stdout logging which throws all exceptions to a log file. This method of logging is unfiltered and gets heavy very quickly. Therefore it is inadvisable to keep it turned on.

Enable STDOUT on Azure Web App

  1. Go to your azure web app in Azure Portal
  2. Open Kudu Console
  3. Using the navigation bar at the top of the page, open Debug console and select CMD
  4. Navigate to folder site > wwwroot
  5. Edit the web.config
  6. Set stdoutLogEnabled to true and stdoutLogFile to \\?\%home%\LogFiles\stdout
  7. Select Save
  8. Make a request to the application url
  9. In Kudu, navigate to the LogFiles folder
  10. Open the new files marked with stdout
  11. When the log file opens, the error is displayed.
  12. you must disable stdoutLogEnabled by setting to false when you are done

 

Source: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/azure-apps/troubleshoot?view=aspnetcore-2.1#aspnet-core-module-stdout-log

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s