Azure Web App不启动节点服务器

我正在通过bitbucket发布我的typecript node.js / express azure应用程序,而且似乎所有东西都正确编译,但是azure不会启动应用程序。

一个可责备的仓库在这里 。 我尝试克隆应用程序到一个新的本地目录,然后在输出文件夹中运行deploy.cmd和调用节点启动,并且工作正常。

由于Azure Web Apps上的node.js应用程序不在监听经典号码端口,因此请响应iisnode侦听的默认端口上的Web请求。

你可以尝试修改你的main.ts脚本:

 let server: Server = new Server(process.env.PORT || 3000); 

对Azure Web应用程序上的node.js应用程序的请求通过iisnode进行处理,您需要在根目录下创build一个web.configconfiguration文件,以在您的scheme中configuration入口文件bin\main.js

web.config内容示例:

 <?xml version="1.0" encoding="utf-8"?> <!-- 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> <!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support --> <webSocket enabled="false" /> <handlers> <!-- Indicates that the bin/main.js file is a node.js site to be handled by the iisnode module --> <add name="iisnode" path="bin/main.js" verb="*" modules="iisnode"/> </handlers> <rewrite> <rules> <!-- Do not interfere with requests for node-inspector debugging --> <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true"> <match url="^bin/main.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="public{REQUEST_URI}"/> </rule> <!-- All other URLs are mapped to the node.js site entry point --> <rule name="DynamicContent"> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/> </conditions> <action type="Rewrite" url="bin/main.js"/> </rule> </rules> </rewrite> <!-- bin directory has no special meaning in node.js and apps can be placed in it --> <security> <requestFiltering> <hiddenSegments> <remove segment="bin"/> </hiddenSegments> </requestFiltering> </security> <!-- Make sure error responses are left untouched --> <httpErrors existingResponse="PassThrough" /> <!-- You can control how Node is hosted within IIS using the following options: * watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server * node_env: will be propagated to node as NODE_ENV environment variable * debuggingEnabled - controls whether the built-in debugger is enabled To debug your node.js application: * set the debuggingEnabled option to "true" * enable web sockets from the portal at https://manage.windowsazure.com/#Workspaces/WebsiteExtension/Website/garynodedeploy/configure * browse to https://garynodedeploy.azurewebsites.net/bin/main.js/debug/ See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options --> <iisnode watchedFiles="web.config;*.js" debuggingEnabled="false" /> </system.webServer> </configuration> 

你可以参考https://github.com/tjanczuk/iisnode关于iisnode的更多信息&#x3002;