We have an ASP.NET Core 6 application where development was started already with ASP.NET Core 1 beta so some things might not have been migrated perfectly along the way.
We now tried to deploy it to an App Service on Linux instance running on a P1v3 plan.
In the docker default log I find
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
But the docker logs (without default in the name) I see
INFO - docker run -d -p 9463:8080 -p 7965:50050 -p 8626:50051 --name xxx -e WEBSITE_SITE_NAME=xxx -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=xxx.azurewebsites.net -e WEBSITE_INSTANCE_ID=7225caab0c70bd61c011893553915089afdc0fffc99a53623c1d7673cee3bdce -e HTTP_LOGGING_ENABLED=1 -e WEBSITE_USE_DIAGNOSTIC_SERVER=True appsvc/dotnetcore:6.0_20221116.6.tuxprod
INFO - Initiating warmup request to container xxx for site xxx
INFO - Waiting for response to warmup request for container xxx. Elapsed time = 15.088367 sec
INFO - Waiting for response to warmup request for container xxx. Elapsed time = 228.7440965 sec ERROR - Container xxx for site xxx did not start within expected time limit. Elapsed time = 230.7635573 sec 2022-12-18T19:54:23.146Z ERROR - xxx didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
It seemed like the application was listening on port 5000, which is Kestrels default port, but all traffic was sent to 8080 which seems to be mapped to port 9463 in the above logs. That port is different for every restart but the application is always starting on port 5000.
I also tried adding the setting WEBSITES_PORT with the value 5000, but that didn't have much effect.
I assume that the site is started by executing dotnet xxx.dll but I cannot in the logs see that any other parameters are passed to the application. So the question is, how is the port (9463 in the above case) passed to the asp.net application and what code line would I need in program.cs or startup.cs to capture that setting? Or can I force the App service to bind to port 5000?
The alternative is to create a new ASP.NET Core 6 site for the VS template and start migrating the code, but preferably I would first like to just use the existing code.
The startup command should've been right after appsvc/dotnetcore:6.0_20221116.6.tuxprod
. Since it's not there, go to your Configuration blade under your app service, General Settings and set the Startup Command. Normally, oryx image will detected this command automatically, but it appears it didn't in your case.