unable to run node.js app in app services

DawitA 1 Reputation point
2022-01-27T19:09:23.393+00:00

I am very concerned that i cant deploy and run node.js app using app services on azure. I have spent 4 days now trying to do this and reading and testing all different things that are being suggested online and in docs. This is absurd!

I am writing here to get attention to my stackoverflow question that is not getting a single interest by the azure community/support.

Deploying a node apps is the simplest thing I can think of for testing azure and features.
It should not be this hard to do this. If you are interested about my issue please follow the link to stackoverflow.

Thank you.

https://stackoverflow.com/questions/70869777/app-service-node-js-app-port-setting-not-taking

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
5,614 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Ryan Hill 20,806 Reputation points Microsoft Employee
    2022-02-03T04:11:48.56+00:00

    Apologies for the delayed response @DawitA . I did look over your StackOverflow question post. Firstly, the Linux app service will always start up listening on port 8080 by default. This behavior will not change. However, if you create and set PORT as an app setting, it will be injected into the process.env.PORT environment variable.

    170690-image.png

    From your StackOverflow post, it does appear that you were able to get your node.js app running but if you had any issues, please include snippets of your _default_docker.log and _docker.log files.

    0 comments No comments

  2. DawitA 1 Reputation point
    2022-02-03T06:20:42.027+00:00

    Hi @Ryan Hill

    I attached my latest deployment files and also video showing what I am doing. 5000 is the port i set in the app env settings.
    but the app starts in some random port(8120) now...not even 8080.

    Video : https://www.youtube.com/watch?v=yMYwiEZo_5E

    docker.log :

    2022-02-03T05:36:37.553Z INFO  - 16-lts_20210810.1 Pulling from appsvc/node  
    2022-02-03T05:36:37.565Z INFO  -  Digest: sha256:f2c77f47296172d44d947cc03ef379c2928839cb783ebae0c2e94f7f3035af70  
    2022-02-03T05:36:37.565Z INFO  -  Status: Image is up to date for mcr.microsoft.com/appsvc/node:16-lts_20210810.1  
    2022-02-03T05:36:37.577Z INFO  - Pull Image successful, Time taken: 0 Minutes and 0 Seconds  
    2022-02-03T05:36:37.760Z INFO  - Starting container for site  
    2022-02-03T05:36:37.760Z INFO  - docker run -d -p 8080:8080 --name apptestport_0_a9999c6d -e WEBSITE_SITE_NAME=AppTestPort -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=apptestport.azurewebsites.net -e WEBSITE_INSTANCE_ID=16c367d3cffdba92c731dd16701d005948978ae17cd8bb7b02835e0fe2f9a234 -e HTTP_LOGGING_ENABLED=1 appsvc/node:16-lts_20210810.1    
      
    2022-02-03T05:36:41.873Z INFO  - Initiating warmup request to container apptestport_0_a9999c6d for site apptestport  
    2022-02-03T05:36:57.034Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 15.1610581 sec  
    2022-02-03T05:37:12.149Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 30.2766214 sec  
    2022-02-03T05:37:27.328Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 45.455287 sec  
    2022-02-03T05:37:42.638Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 60.7651455 sec  
    2022-02-03T05:37:57.803Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 75.9301987 sec  
    2022-02-03T05:38:12.937Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 91.0647626 sec  
    2022-02-03T05:38:28.074Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 106.2016487 sec  
    2022-02-03T05:38:43.232Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 121.3592701 sec  
    2022-02-03T05:38:58.374Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 136.5015197 sec  
    2022-02-03T05:39:13.543Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 151.6705203 sec  
    2022-02-03T05:39:28.738Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 166.8657346 sec  
    2022-02-03T05:39:43.879Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 182.0067162 sec  
    2022-02-03T05:39:59.030Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 197.1574242 sec  
    2022-02-03T05:40:15.159Z INFO  - Waiting for response to warmup request for container apptestport_0_a9999c6d. Elapsed time = 213.2867867 sec  
    2022-02-03T05:40:32.781Z ERROR - Container apptestport_0_a9999c6d for site apptestport did not start within expected time limit. Elapsed time = 230.9083944 sec  
    2022-02-03T05:40:32.809Z ERROR - Container apptestport_0_a9999c6d didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.  
    2022-02-03T05:40:32.832Z INFO  - Stopping site apptestport because it failed during startup.  
    2022-02-03T05:40:35.532Z INFO  - 16-lts_20210810.1 Pulling from appsvc/node  
    2022-02-03T05:40:35.536Z INFO  -  Digest: sha256:f2c77f47296172d44d947cc03ef379c2928839cb783ebae0c2e94f7f3035af70  
    2022-02-03T05:40:35.538Z INFO  -  Status: Image is up to date for mcr.microsoft.com/appsvc/node:16-lts_20210810.1  
    2022-02-03T05:40:35.543Z INFO  - Pull Image successful, Time taken: 0 Minutes and 0 Seconds  
    2022-02-03T05:40:35.576Z INFO  - Starting container for site  
    2022-02-03T05:40:35.578Z INFO  - docker run -d -p 5000:5000 --name apptestport_0_24024225 -e PORT=5000 -e WEBSITE_SITE_NAME=AppTestPort -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=apptestport.azurewebsites.net -e WEBSITE_INSTANCE_ID=16c367d3cffdba92c731dd16701d005948978ae17cd8bb7b02835e0fe2f9a234 -e HTTP_LOGGING_ENABLED=1 appsvc/node:16-lts_20210810.1    
    

    default_docker.log : notice how the app is running on port 8120 ; which i never specified anywhere.

    2022-02-03T05:36:41.941136230Z   _____                                 
    2022-02-03T05:36:41.941226030Z   /  _  \ __________ _________   ____    
    2022-02-03T05:36:41.941240330Z  /  /_\  \___   /  |  \_  __ \_/ __ \   
    2022-02-03T05:36:41.941249331Z /    |    \/    /|  |  /|  | \/\  ___/   
    2022-02-03T05:36:41.941257831Z \____|__  /_____ \____/ |__|    \___  >  
    2022-02-03T05:36:41.941266231Z         \/      \/                  \/   
    2022-02-03T05:36:41.941275031Z A P P   S E R V I C E   O N   L I N U X  
    2022-02-03T05:36:41.941283231Z   
    2022-02-03T05:36:41.941307131Z Documentation: http://aka.ms/webapp-linux  
    2022-02-03T05:36:41.941314331Z NodeJS quickstart: https://aka.ms/node-qs  
    2022-02-03T05:36:41.941321631Z NodeJS Version : v16.6.1  
    2022-02-03T05:36:41.941329231Z Note: Any data outside '/home' is not persisted  
    2022-02-03T05:36:41.941337831Z   
    2022-02-03T05:36:42.358581047Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...  
    2022-02-03T05:36:42.361506373Z Build Operation ID: |Gb6duQRu9d0=.9c40f80e_  
    2022-02-03T05:36:43.075314830Z Environment Variables for Application Insight's IPA Codeless Configuration exists..  
    2022-02-03T05:36:43.629955973Z Writing output script to '/opt/startup/startup.sh'  
    2022-02-03T05:36:43.808597164Z Running #!/bin/sh  
    2022-02-03T05:36:43.808686165Z   
    2022-02-03T05:36:43.808697965Z # Enter the source directory to make sure the script runs where the user expects  
    2022-02-03T05:36:43.808706365Z cd "/home/site/wwwroot"  
    2022-02-03T05:36:43.808714365Z   
    2022-02-03T05:36:43.808721365Z export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH  
    2022-02-03T05:36:43.808728165Z if [ -z "$PORT" ]; then  
    2022-02-03T05:36:43.808735366Z  export PORT=8080  
    2022-02-03T05:36:43.808743266Z fi  
    2022-02-03T05:36:43.808749766Z   
    2022-02-03T05:36:43.808756366Z echo Found tar.gz based node_modules.  
    2022-02-03T05:36:43.808763966Z extractionCommand="tar -xzf node_modules.tar.gz -C /node_modules"  
    2022-02-03T05:36:43.808771666Z echo "Removing existing modules directory from root..."  
    2022-02-03T05:36:43.808779366Z rm -fr /node_modules  
    2022-02-03T05:36:43.808786466Z mkdir -p /node_modules  
    2022-02-03T05:36:43.808975168Z echo Extracting modules...  
    2022-02-03T05:36:43.809002568Z $extractionCommand  
    2022-02-03T05:36:43.809010368Z export NODE_PATH="/node_modules":$NODE_PATH  
    2022-02-03T05:36:43.809017868Z export PATH=/node_modules/.bin:$PATH  
    2022-02-03T05:36:43.809040768Z if [ -d node_modules ]; then  
    2022-02-03T05:36:43.809047468Z     mv -f node_modules _del_node_modules || true  
    2022-02-03T05:36:43.809054268Z fi  
    2022-02-03T05:36:43.809074269Z   
    2022-02-03T05:36:43.809082769Z if [ -d /node_modules ]; then  
    2022-02-03T05:36:43.809089769Z     ln -sfn /node_modules ./node_modules   
    2022-02-03T05:36:43.809096169Z fi  
    2022-02-03T05:36:43.809102869Z   
    2022-02-03T05:36:43.809109369Z echo "Done."  
    2022-02-03T05:36:43.809116369Z npm start  
    2022-02-03T05:36:43.818456952Z Found tar.gz based node_modules.  
    2022-02-03T05:36:43.819574062Z Removing existing modules directory from root...  
    2022-02-03T05:36:43.831816171Z Extracting modules...  
    2022-02-03T05:36:44.160325999Z Done.  
    2022-02-03T05:36:45.300050662Z npm info it worked if it ends with ok  
    2022-02-03T05:36:45.301054871Z npm info using npm@6.14.14  
    2022-02-03T05:36:45.302523084Z npm info using node@v16.6.1  
    2022-02-03T05:36:45.669889861Z npm info lifecycle nodeazureapp@1.0.0~prestart: nodeazureapp@1.0.0  
    2022-02-03T05:36:45.691082550Z npm info lifecycle nodeazureapp@1.0.0~start: nodeazureapp@1.0.0  
    2022-02-03T05:36:45.706252985Z   
    2022-02-03T05:36:45.706340586Z > nodeazureapp@1.0.0 start /home/site/wwwroot  
    2022-02-03T05:36:45.706356186Z > node index.js  
    2022-02-03T05:36:45.706364886Z   
    2022-02-03T05:36:46.229985358Z {"level":30,"time":1643866606228,"pid":53,"hostname":"4b165e417fa8","msg":"Server listening at http://127.0.0.1:8120"}  
    2022-02-03T05:36:46.235910311Z **Example app listening at http://localhost:8120**  
    

    170852-chrome-2022-02-03-00-22-13.png

    0 comments No comments