2016-07-24 35 views
0

我剛剛將代碼從github部署到了azure。 它是一個nodejs網絡應用程序。 在蔚藍的天氣中,我正在使用應用程序服務。從github源部署時,空白頁在azurewebsites中顯示。它是一個nodejs webapp

另外,我添加的代碼爲端口位於/ bin /萬維網

var port = process.env.port || 8080; // 8080 for local or whatever number u want 
var listener = app.listen(port, function(){ 
    console.log('Listening on port ' + port); 
}); 

儘管如此,網頁沒有顯示在向上的https:// {APPNAME} .azurewebsites.net

這裏是部署日誌

Command: "D:\home\site\deployments\tools\deploy.cmd" 
Handling node.js deployment. 
KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot' 
Copying file: 'package.json' 
Using start-up script bin/www from package.json. 
Generated web.config. 
The package.json file does not specify node.js engine version constraints. 
The node.js application will run with the default node.js version 4.2.3. 
Selected npm version 3.5.1 
{github-reponame}@0.0.0 D:\home\site\wwwroot 
├── [email protected] 
└── [email protected] 

Finished successfully. 

賈斯汀模式的評論... 在供應鏈管理,文件的結構,似乎是好的。

我沒有檢查部署日誌,部署成功但頁面未顯示。

在scm kudu中,文件的結構看起來沒問題。點擊https:// {appname} .azurewebsites.net時,只會出現一個空白頁面。網頁配置文件存在於根目錄中。嗨,Gary-Liu,MSFT, 。 這是在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 server.js file is a node.js site to be handled by the iisnode module --> 
     <add name="iisnode" path="bin/www" 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/www\/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/www"/> 
     </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 

     See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options 
    --> 
    <!--<iisnode watchedFiles="web.config;*.js"/>--> 
    </system.webServer> 
</configuration> 

更新: 7月24日 - 下午11時05分EST - 看起來像有一些線索,以解決這個問題......但現在知道如何.. 添加從日誌文件的詳細信息: 日誌顯示「源文件中沒有匹配元素......」

2016-07-25T03:03:26 Start 'websitelogs' site extension transform 
2016-07-25T03:03:26 :(6,10), No element in the source document matches '/configuration/system.applicationHost/sites/site[@name='~1{appname}']/application[@path='/websitelogs']' 
2016-07-25T03:03:26 Not executing Remove (transform line 6, 68) 
2016-07-25T03:03:26 StartSection Executing Insert (transform line 7, 65) 
2016-07-25T03:03:26 on /configuration/system.applicationHost/sites/site[@name='~1{appname}']/application 
2016-07-25T03:03:26 Applying to 'site' element (no source line info) 

更新7月25日,1:25 PM EST 對於加里 - 劉MSFT的評論: 我試着在評論GitHub的「端口」行並重新部署它,它仍然湛藍只顯示空白頁時通過https:// {appname} .azurewebsites.net或http:{appname} .azurewebsites.net訪問

從應用程序日誌...

2016-07-25T16:41:15 PID [15128]警告配置默認提供 'MicrosoftAccount' 被忽略 ,因爲它未啓用。替代提供者將被任意選擇。 2016-07-25T16:41:15 PID [15128]信息發送回覆:401.71未授權

該網站仍然顯示空白頁....當通過http:// {appname} .azurewebsites.net或https:// {appname} .azurewebsites.net

代碼通過github回購進行部署。該網站正常工作沒有天藍。 它只是顯示一個空白頁面後,部署到天藍色的網絡應用程序...

更新:七月 25,下午1點39 EST 由於加里 - 劉MSFT 解決!謝謝! 評論港口線有幫助!非常感謝!它正在工作!謝謝! 另外...這是因爲,在這個網絡應用程序中,我已經啓用了對outlook acct的身份驗證/授權。把它關掉,現在沒有更多的空白頁面!該網站現在工作正常!原因是,我啓用它的前景科學是...我希望它會提示前景登錄!謝謝你的幫助!該網站現在正在運行在天藍色!

+0

你有沒有使用SCM /捻接口來檢查部署的文件的結構?門戶中還應該有一個App Service的部署日誌。可以通過訪問https:// {site name} .scm.azurewebsites.net找到Kudu。此外,此視頻還介紹了設置您正在嘗試執行的操作:https://azure.microsoft.com/en-us/ documentation/videos/create-a-nodejs-site-deploy-from-github/ –

+0

上面編輯的文章包含了這個scm/kudu /部署日誌信息。 – maggie

回答

0

你能否檢查你的應用程序根目錄下是否有web.config文件?

web.config的內容應與以下類似:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <appSettings> 
    </appSettings> 
    <system.webServer> 
    <!-- mimeMap enables IIS to serve particular file types as specified by fileExtension. --> 
    <staticContent> 
     <mimeMap fileExtension=".svg" mimeType="image/svg+xml" /> 
    </staticContent> 

    <modules runAllManagedModulesForAllRequests="false" /> 

    <!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. --> 
    <iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.jade"/> 

    <!-- Remote debugging (Azure Website with git deploy): Comment out iisnode above, and uncomment iisnode below. --> 
    <!--<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.jade" 
     loggingEnabled="true" 
     devErrorsEnabled="true" 
     nodeProcessCommandLine="node.exe &#45;&#45;debug"/>--> 

    <!-- indicates that the server.js file is a Node.js application 
    to be handled by the iisnode module --> 
    <handlers> 
     <add name="iisnode" path="/bin/www" verb="*" modules="iisnode" /> 

     <!-- Remote debugging (Azure Website with git deploy): Uncomment NtvsDebugProxy handler below. 
     Additionally copy Microsoft.NodejsTools.WebRole to 'bin' from the Remote Debug Proxy folder.--> 
     <!--<add name="NtvsDebugProxy" path="ntvs-debug-proxy/ad81dc69-210e-42c6-80da-221ed1245211" verb="*" resourceType="Unspecified" 
     type="Microsoft.NodejsTools.Debugger.WebSocketProxy, Microsoft.NodejsTools.WebRole"/>--> 
    </handlers> 

    <security> 
     <requestFiltering> 
     <hiddenSegments> 
      <remove segment="bin" /> 
     </hiddenSegments> 
     </requestFiltering> 
    </security> 

    <rewrite> 
     <rules> 
     <clear /> 
     <!-- Remote debugging (Azure Website with git deploy): Uncomment the NtvsDebugProxy rule below. --> 
     <!--<rule name="NtvsDebugProxy" enabled="true" stopProcessing="true"> 
      <match url="^ntvs-debug-proxy/.*"/> 
     </rule>--> 

     <rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true"> 
      <match url="iisnode.+" negate="true" /> 
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> 
      <action type="Rewrite" url="bin\www" /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 

任何更新或進一步關注,請隨時讓我知道。

更新

看來你的存儲庫代碼有一些錯誤。它定義了端口並使http服務器在您的代碼中多次收聽端口。我做了一些修改,並部署到Azure進行測試,現在它在我身邊正常工作。

請嘗試刪除或評論以下代碼段,然後再次部署到Azure。

  • var listener = app.listen(port, function(){ console.log('Listening on port ' + port); });
    開始於第18行的bin/www
  • var port = process.env.port || 8080; // 8080 for local or whatever number u want var listener = app.listen(port, function(){ console.log('Listening on port ' + port); });
    在2號線開始的app.js
+0

是的,它存在於根目錄中,並將內容添加到上面的主文章中。 – maggie

+0

是否方便您爲我們提供您的存儲庫,我們可以對其進行進一步的診斷 –

+0

我試圖放在天藍色的web應用程序中的存儲庫是github.com/maggienj/megan (該web應用程序運行良好沒有天藍色...它只是它從天藍色的網站不工作...) – maggie