我正在通过bitbucket发布我的打字稿node.js / express azure app,看起来一切都正常编译,但是azure并没有启动应用程序。
可重复使用的存储库是here。我尝试将应用程序克隆到一个新的本地目录,然后运行deploy.cmd并在输出文件夹中调用node start,这很好。
答案 0 :(得分:1)
由于Azure Web Apps上的node.js应用程序未侦听经典号码端口,因此请回应iisnode侦听的默认端口上的Web请求。
您可以尝试修改main.ts
脚本:
let server: Server = new Server(process.env.PORT || 3000);
对Azure Web Apps上的node.js应用程序的请求是通过iisnode处理的,您需要在根目录中创建一个web.config
配置文件来配置入口文件,即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>
有关iisnode的更多信息,请参阅https://github.com/tjanczuk/iisnode。