Search code examples
asp.netasp.net-mvcasp.net-core-mvcnuget-packageswisscomdev

ASP.NET Core MVC Health Check failing


I try to run a ASP.NET Core MVC Web application on the Swisscom Appcloud. But when I start the Application I get following Error-Message in the Console:

2017-01-24 14:29:53 [CELL/0] ERR Timed out after 1m0s: health check never passed. 

Its looks like the Appcloud cannot check the Health of my Application. Do I need to install a Nuget-Package or something else to get this up and running?

Thanks for your effort


Solution

  • As gsmachado has already mentioned, you must listen to a specific port.

    The .NET Core buildpack configures the app web server automatically so you don’t have to handle this yourself. But you have to prepare your app in a way that allows the buildpack to deliver this information via the command line to your app.

    The buildpack will start your app with the following command:

    $ dotnet run --server.urls http://0.0.0.0:${PORT}

    Therefore you have to add the command line as a configuration provider and then add the UseConfiguration extension to pass the configuration to the WebHostBuilder

    e.g.:

    var config = new ConfigurationBuilder()
    .AddCommandLine(args)
    .Build();
    
    var host = new WebHostBuilder()
        .UseKestrel()
        .UseConfiguration(config)
        .UseStartup<Startup>()
        .Build();