Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug an ASPNET Core MVC Application Deployed in Azure

I've created a simple ASPNET Core 1.0 MVC app, which I am trying to deploy to Azure using Visual Studio. I am able to run this app locally on my machine using IIS Express, and navigate to my default route and display the page. However, in Azure I always get a 500 error every time, and at this point I am at a loss for how to get additional information.

I've enabled detailed request logging in my Azure app, but it doesn't really seem to tell me much.

ModuleName="AspNetCoreModule", Notification="EXECUTE_REQUEST_HANDLER", HttpStatus="500", HttpReason="Internal Server Error", HttpSubStatus="0", ErrorCode="The operation completed successfully.
 (0x0)", ConfigExceptionInfo="" 

I've stripped down my Startup configuration to the bare essentials

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();
}

public void Configure(IApplicationBuilder app, ILoggerFactory loggingFactory)
{

    loggingFactory.AddConsole();
    loggingFactory.AddDebug();

    app.UseMvc(routes => {
        routes.MapRoute(
            name: "default",
            template: "{controller=Home}/{action=Index}/{id?}"
        );
    });

}

Something must be blowing up in the MVC pipeline but I have no idea how to add more visibility. What can I do to get more information?

And in case it matters, this is my Program.cs

var host = new WebHostBuilder()
    .UseKestrel()
    .UseContentRoot(Directory.GetCurrentDirectory())
    .UseIISIntegration()
    .UseStartup<Startup>()
    .Build();

host.Run();
like image 935
mclark1129 Avatar asked Aug 03 '16 16:08

mclark1129


People also ask

How do you debug an app deployed on Azure?

In Solution Explorer, right-click the project, and click Publish. In the Profile drop-down list, select the same profile that you used in Create an ASP.NET app in Azure App Service. Then, click Settings. In the Publish dialog, click the Settings tab, and then change Configuration to Debug, and then click Save.

How do I debug Aspnet?

Select the ASP.NET Core project in Visual Studio Solution Explorer and click the Properties icon, or press Alt+Enter, or right-click and choose Properties. Select the Debug tab and click the link to open the Open debug launch profiles UI.

How do I debug a deployed application?

To use Visual Studio to debug a deployed application, you must attach to the ASP.NET worker process and make sure that the debugger has access to symbols for the application. You must also locate and open the source files for the application. For more information, see Specify Symbol (.


1 Answers

Try setting ASPNETCORE_ENVIRONMENT to Development to display full exception message on the error page.

Application Settings

Remember to turn it off when finished, otherwise you will leak error information.

like image 57
Dennis Avatar answered Sep 20 '22 13:09

Dennis