2016-07-19 16 views
1

私のtypescript node.js/express azureアプリをbitbucket経由で公開していますが、すべてが正しくコンパイルされているようですが、Azureはアプリケーションを起動しません。Azure Webアプリケーションがノードサーバーを起動しない

reproableリポジトリは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); 

そしてAzureのWebアプリケーション上の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を参照することができます。

+0

ポート情報が不足していました。 web.configは必要なかった、ありがとう! – Somkun

関連する問題