2016-07-19 106 views
1

我通過bitbucket發佈了我的typescript node.js/express azure應用程序,並且似乎所有內容都正確編譯,但是azure不會啓動該應用程序。Azure Web應用程序不啓動節點服務器

責備庫是here。我嘗試將應用程序克隆到新的本地目錄,然後運行deploy.cmd並在輸出文件夾中啓動調用節點,並且工作正常。

+0

您的回購協議鏈接不起作用 – DAXaholic

+0

修復,格式錯誤 – Somkun

+0

@Somkun修復了問題,解決了您的問題?如果是這樣的話,你應該刪除這個問題。 –

回答

1

由於Azure Web Apps上的node.js應用程序未偵聽經典號碼端口,因此請響應iisnode偵聽的默認端口上的Web請求。

你可以嘗試修改main.ts腳本:

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

和反對到node.js的Azure上的Web應用程序的應用程序的請求通過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> 

您可以參考https://github.com/tjanczuk/iisnode關於iisnode更多信息。

+0

我錯過了端口信息。 web.config沒有必要,謝謝! – Somkun

相關問題