从github源部署时,空白页面显示在azurewebsites中。这是一个nodejs webapp

时间:2016-07-24 03:49:45

标签: node.js azure github azure-web-sites

我刚刚将代码从github部署到azure。 它是一个nodejs网络应用程序。 在azure中,我使用的是app服务。

另外,我在/ 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); 
});

仍然,网页没有显示在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
├── lodash@4.4.0 
└── underscore@1.7.0 

Finished successfully.

Justin Pattern的评论...... 在scm中,文件结构似乎没问题。

我确实检查了部署日志,部署成功但页面没有显示。

在scm kudu中,文件的结构似乎没问题。仍然只有在点击https:// {appname}时才显示空白页面.azurewebsites.net

嗨Gary-Liu MSFT, web.config存在于根目录中。 这就是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美国东部时间 - 看起来有一些线索来解决这个问题...但现在确定如何... 从日志文件中添加更多信息: 日志显示&#34;源文档中的任何元素都不匹配...&#34;

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 对于Gary-Liu MSFT的评论: 我试着评论&#34;端口&#34; github中的行并重新部署它,当通过https:// {appname} .azurewebsites.net或http:{appname} .azurewebsites.net

访问时,它仍然只显示空白页面

从应用程序日志...

2016-07-25T16:41:15 PID [15128]警告配置的默认提供商&#39; MicrosoftAccount&#39;被忽略了 因为它没有启用。替代提供者将被任意选择。 2016-07-25T16:41:15 PID [15128]信息发送回复:401.71未经授权

网站仍显示空白页面....通过http:// {appname} .azurewebsites.net或https:// {appname} .azurewebsites.net

访问

代码是通过github repo部署的。没有天蓝色的网站工作正常。 它只是在部署到azure Web应用程序后显示一个空白页...

更新 美国东部时间7月25日下午1点39分 感谢Gary-Liu MSFT 解决!谢谢! 评论港口线有帮助!非常感谢!它现在正在运作!谢谢!  另外......这是因为,对于这个Web应用程序,我已经启用了对outlook acct的身份验证/授权。切换它,现在没有更多的空白页!该网站现在运作正常!原因,我启用它来展望acct是...我希望它会提示登录Outlook!谢谢你的帮助!该网站现已在天蓝色中运行!

1 个答案:

答案 0 :(得分: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); });
    bin/www
  • 的第18行开始
  • 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); });
    app.js
  • 的第2行开始