简体   繁体   中英

Azure mobile node.js backend deploy port issue

I'm new on node.js and azure. I want to develop a mobile app which insert and select data in a table. For the android part - client side I use the code from here . For the node.js part - server side I use the code from the same repository this code

When I deploy the node.js project on azure I give an error: 看图片

I have this message if a use any code for mobile node.js.

In Container diag, the problem is at PORT:

Check your Application Settings to make sure that the PORT setting of your container is correct. You can also view Application Logs to determine if there was a wrong PORT set.

In application logs the port is 8080:

ERROR - Container antaresmobilejs_0_7b069d42 for site antaresmobilejs has exited, failing site start ERROR - Container antaresmobilejs_0_7b069d42 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.

In my node.js code, I set the port to 8080, but I don't find the port settings in application settings.

Actually, the Node.js backend port for Azure Mobile Apps should be set as below if using Express.js.

app.listen(process.env.PORT || 3000);

It was introduced in the offical document How to use the Mobile Apps Node.js SDK , as the figure below.

在此处输入图像描述

It also be coded in the offcal sample code https://github.com/Azure/azure-mobile-apps-quickstarts/blob/master/backend/node/TodoSample/app.js#L35

The code process.env.PORT will read the default port specified by Azure from the environment, and the web.config file will help node backend app to start up by IIS.

在此处输入图像描述

The real port of API endpoint for client is 80 , because the node app hosted in IIS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM