通过FTP将nodejs应用程序部署到Azure不起作用

我正在尝试使用Node的Azure,并使用Wercker CI构build,然后通过FTP部署到Azure。

但似乎我有一些麻烦得到这个工作。 我正在复制一个server.js文件以及一个package.json和一些其他资产。 但看起来没有任何运行npm install命令。 另外,我得到一个You do not have permission to view this directory or page. 到达现场时。

有一个web.config文件,configuration如下:

 <!-- This configuration file is required if iisnode is used to run node processes behind IIS or IIS Express. For more information, visit: https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config --> <configuration> <system.webServer> <handlers> <!-- indicates that the app.js file is a node.js application to be handled by the iisnode module --> <add name="iisnode" path="./server.js" verb="*" modules="iisnode"/> </handlers> <rewrite> <rules> <!-- Don't interfere with requests for logs --> <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true"> <match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$"/> </rule> <!-- Don't interfere with requests for node-inspector debugging --> <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true"> <match url="^\.\/server.js\/debug[\/]?" /> </rule> <!-- First we consider whether the incoming URL matches a physical file in the /public folder --> <!--<rule name="StaticContent"> <action type="Rewrite" url="./app/assets/{REQUEST_URI}"/> </rule>--> <!-- All other URLs are mapped to the Node.js application entry point --> <rule name="DynamicContent"> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/> </conditions> <action type="Rewrite" url="./server.js"/> </rule> </rules> </rewrite> <iisnode watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade;middleware\*.js"/> </system.webServer> </configuration> 

server.js一样简单:

 var http_1 = require('http'); var express = require('express'); var log4js_1 = require('log4js'); var morgan = require('morgan'); var split = require('split2'); // NOTE: Some of the features used are only available in ES6 // do not forget to start the server using `node --harmony` option so that everything will work properly, // in case you use anything that is behind the staging flag. // Check https://nodejs.org/en/docs/es6/#which-features-are-behind-the-es_staging-flag // to see which features require the flag. var app = express(); var APP_PORT = process.env.PORT || 5000; var APP_PATH = __dirname + "/public"; // We will need to split the output from morgan into lines to avoid trailing line feeds, // https://github.com/expressjs/morgan/issues/70. var log = log4js_1.getLogger(); var log4jsStream = split().on('data', function (line) { log.debug(line); }); app.use(morgan('tiny', { stream: log4jsStream })); // `__dirname` in this case will be `./dist/` since we start the server from there. app.use(express.static(APP_PATH)); app.all('/*', function (req, res) { res.sendFile(APP_PATH + "/index.html"); }); var server = http_1.createServer(app); server.listen(APP_PORT, function () { // console.log(`Express server listening on port ${APP_PORT}`); }); //# sourceMappingURL=server.js.map 

最后, package.json包含必要的代码。

所以我只是想知道,有没有办法将应用程序部署到Azure并触发npm install并启动Web服务器?

我可以看到,如果你通过Git进行部署,Kudu将为我做所有这些。 但是在使用Wercker进行部署时,我不认为这是我的select。 另外,我正在编译CI构build期间的一些TypeScript文件,我不希望那些版本控制,所以有一个Git仓库,我需要存储所有编译的文件也不是一个选项。

我真的很感激有关如何处理这个问题的一些意见。

根据你的描述有点困惑:

所以我只是想知道,有没有办法将应用程序部署到Azure并触发npm安装并启动Web服务器?

我可以看到,如果你通过Git进行部署,Kudu将为我做所有这些。 但我不认为这是我的select

通常,通过Git将您的节点应用程序部署到Azure,它将自动运行npm install。 如果你不喜欢使用Git,你更喜欢什么特定的要求。

目前我无法重现您关于Wercker的问题。 通过GIT进行部署时会发生错误吗?

根据你对@ theadriangreen的意见,看来你在npm install失败,因为超时。 如果是这样,您可以尝试启用Web应用程序的Always On设置,以防止您的站点在一段时间内没有收到任何请求的情况下卸载。

另外,如果在部署之后仍然需要一些自定义任务,则可以参考Post Deployment Action Hooks来configuration您的自定义部署脚本。

通过FTP进行部署时, npm install将不会自动运行。 在这种情况下,您可以使用控制台来运行npm install

通过FTP进行部署时, npm install将不会自动运行。 在这种情况下,您将不得不在所部署的文件夹中包含所有依赖关系。 所以你可以做到这一点,通过FTP部署,或者你可以使用git。

如果你使用git,你可以添加你不想部署的文件到你的.gitignore,然后单独部署(即把它们放在一个blob中)。