简体   繁体   English

Azure 移动端 node.js 后端部署端口问题

[英]Azure mobile node.js backend deploy port issue

I'm new on node.js and azure.我是 node.js 和 azure 的新手。 I want to develop a mobile app which insert and select data in a table.我想开发一个在表格中插入和 select 数据的移动应用程序。 For the android part - client side I use the code from here .对于 android 部分客户端,我使用此处的代码。 For the node.js part - server side I use the code from the same repository this code对于 node.js 部分 - 服务器端我使用来自同一存储库的代码此代码

When I deploy the node.js project on azure I give an error:当我在 azure 上部署 node.js 项目时,出现错误: 看图片

I have this message if a use any code for mobile node.js.如果使用移动 node.js 的任何代码,我会收到此消息。

In Container diag, the problem is at PORT:在 Container diag 中,问题出在 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.您还可以查看应用程序日志以确定是否设置了错误的 PORT。

In application logs the port is 8080:在应用程序日志中,端口是 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.错误 - 站点 antaresmobilejs 的容器 antaresmobilejs_0_7b069d42 已退出,站点启动失败 错误 - 容器 antaresmobilejs_0_7b069d42 未响应 HTTP 端口上的 ping:8080,站点启动失败。 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.在我的 node.js 代码中,我将端口设置为 8080,但在应用程序设置中找不到端口设置。

Actually, the Node.js backend port for Azure Mobile Apps should be set as below if using Express.js.实际上,如果使用 Express.js,Azure 移动应用程序的 Node.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.在官方文档How to use the Mobile Apps Node.js SDK中有介绍,如下图。

在此处输入图像描述

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它也被编码在 offcal 示例代码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.代码process.env.PORT将从环境中读取 Azure 指定的默认端口, web.config文件将帮助节点后端应用程序通过 Z5DA5ACF461B4EFB7E76EC861065B212Z 启动。

在此处输入图像描述

The real port of API endpoint for client is 80 , because the node app hosted in IIS.客户端的 API 端点的真实端口是80 ,因为节点应用程序托管在 IIS 中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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