Reputation: 2061
I try to deploy my NestJs Application (uses the express adapter) to Azure App Services. In the docker logs I get this error:
2020-11-20T10:42:02.911Z INFO - docker run -d -p 8947:8080 --name xxx_0_37a36398 -e WEBSITES_PORT=8080 -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=xxx appsvc/node:14-lts_20200918.1 yarn start:prod
2020-11-20T10:42:02.912Z INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2020-11-20T10:42:05.088Z INFO - Initiating warmup request to container xxx_0_37a36398 for site xxx
2020-11-20T10:42:20.586Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 15.4982001 sec
2020-11-20T10:48:35.794Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 390.7060158 sec
2020-11-20T10:56:21.027Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 855.9388558 sec
2020-11-20T11:04:08.996Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 1323.907606 sec
2020-11-20T11:11:55.596Z INFO - Waiting for response to warmup request for container xxx_0_37a36398. Elapsed time = 1790.5073044 sec
2020-11-20T11:12:25.625Z ERROR - Container xxx_i_0_37a36398 for site xxx did not start within expected time limit. Elapsed time = 1820.5363685 sec
2020-11-20T11:12:25.627Z ERROR - Container xxx_0_37a36398 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2020-11-20T11:12:25.637Z INFO - Stopping site xxx because it failed during startup.
The Applications logs says that the application starts successful
2020-11-20T10:42:05.150205868Z _____
2020-11-20T10:42:05.150227670Z / _ \ __________ _________ ____
2020-11-20T10:42:05.150232970Z / /_\ \___ / | \_ __ \_/ __ \
2020-11-20T10:42:05.150237271Z / | \/ /| | /| | \/\ ___/
2020-11-20T10:42:05.150241271Z \____|__ /_____ \____/ |__| \___ >
2020-11-20T10:42:05.150245371Z \/ \/ \/
2020-11-20T10:42:05.150249272Z A P P S E R V I C E O N L I N U X
2020-11-20T10:42:05.150252972Z
2020-11-20T10:42:05.150256472Z Documentation: http://aka.ms/webapp-linux
2020-11-20T10:42:05.150260173Z NodeJS quickstart: https://aka.ms/node-qs
2020-11-20T10:42:05.150263673Z NodeJS Version : v14.7.0
2020-11-20T10:42:05.150267273Z Note: Any data outside '/home' is not persisted
2020-11-20T10:42:05.150270874Z
2020-11-20T10:42:05.388794060Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-11-20T10:42:05.389362508Z Could not find operation ID in manifest. Generating an operation id...
2020-11-20T10:42:05.389393011Z Build Operation ID: 5488a73a-f6e1-48d5-9360-7d4e0db141f4
2020-11-20T10:42:06.033354810Z Environment Variables for Application Insight's Codeless Configuration exists..
2020-11-20T10:42:06.603097828Z Writing output script to '/opt/startup/startup.sh'
2020-11-20T10:42:06.946048753Z Running #!/bin/sh
2020-11-20T10:42:06.946644503Z
2020-11-20T10:42:06.946657204Z # Enter the source directory to make sure the script runs where the user expects
2020-11-20T10:42:06.946662305Z cd "/home/site/wwwroot"
2020-11-20T10:42:06.946666105Z
2020-11-20T10:42:06.947939813Z export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH
2020-11-20T10:42:06.947952014Z if [ -z "$PORT" ]; then
2020-11-20T10:42:06.947956114Z export PORT=8080
2020-11-20T10:42:06.949015304Z fi
2020-11-20T10:42:06.954862399Z
2020-11-20T10:42:06.954927704Z export NODE_OPTIONS='--require /usr/local/lib/node_modules/applicationinsights/out/Bootstrap/Oryx.js ' $NODE_OPTIONS
2020-11-20T10:42:06.954986409Z PATH="$PATH:/home/site/wwwroot" yarn start:prod
2020-11-20T10:42:08.321443397Z yarn run v1.17.3
2020-11-20T10:42:08.484387733Z $ node dist/src/main
[...]
2020-11-20T10:42:23.394152218Z Application started on port 8080
I bind the express server with this line
const port = Number(process.env.PORT) || 8080;
I've googled for a while to find a solution but nothing helps. Here are the steps I tried util now.
WEBSITES_CONTAINER_START_TIME_LIMIT
to 1800WEBSITES_PORT
and PORT
Setting to 80Dose anyone have an idea why this problem still occurs? My app is listing on the right port and returns a 200 Http Status under /
and has also implemented a 400 Error handler (I've read that this cloud also a problem).
Upvotes: 1
Views: 1377
Reputation: 216
Do you use Sentry maybe? We had a similar problem and were able to trace it back to Sentry. Try it without Sentry and a default configuration.
Upvotes: 1
Reputation: 6508
Sourcing from https://learn.microsoft.com/azure/app-service/faq-app-service-linux#custom-containers
My custom container listens to a port other than port 80. How can I configure my app to route requests to that port?
We have automatic port detection. You can also specify an app setting called WEBSITES_PORT and give it the value of the expected port number. Previously, the platform used the PORT app setting. We are planning to deprecate this app setting and to use WEBSITES_PORT exclusively.
You don’t need to use the PORT variable. The automatic port detection detects the port (port 80 is the default), we will attempt to detect which port to bind to your container, but you can also use the WEBSITES_PORT app setting and configure it with a value for the port you want to bind to your container. However, the web server in your custom image may use a port other than 80. You tell Azure about the port that your custom container uses by using the WEBSITES_PORT app setting. For using a different port - Use the EXPOSE instruction in your Dockerfile to expose the appropriate port (E.g 5000) and use the WEBSITES_PORT app setting on Azure with a value of "5000" to expose that port.
Upvotes: 0