0

I create a project from the project template: "Basic Azure Node.js Express 4 Application" in Visual Studio 2017 Enterprise edition.

enter image description here

When I run it locally it works fine. Now I publish this to Azure using the below Publish menu:

enter image description here

I get the following error:

iisnode encountered an error when processing the request.

HRESULT: 0x2
HTTP status: 500
HTTP subStatus: 1001
HTTP reason: Internal Server Error

enter image description here

I'm making no changes to the code from the template.

Any Ideas?

Aram
  • 5,537
  • 2
  • 30
  • 41

2 Answers2

1

I followed your steps in Visual Studio 2017 Community edition. When I published the Express app to Azure Web App, I get the following error on my browser.

The page cannot be displayed because an internal server error has occurred.

After some investigation, I fixed it by changing the Web.config file to something like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
    </staticContent>
    <modules runAllManagedModulesForAllRequests="false" />

    <iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug" />

    <handlers>
      <add name="iisnode" path="bin/www" verb="*" modules="iisnode" />
    </handlers>

    <rewrite>
      <rules>
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^bin/www\/debug[\/]?" />
        </rule>
        <rule name="StaticContent">
          <action type="Rewrite" url="public{REQUEST_URI}" />
        </rule>
        <rule name="DynamicContent">
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
          </conditions>
          <action type="Rewrite" url="bin/www" />
        </rule>
      </rules>
    </rewrite>

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

  </system.webServer>

</configuration>    

Also, the web.config file can be found at https://github.com/projectkudu/kudu/wiki/Using-a-custom-web.config-for-Node-apps.

Hope this will help you.

Aaron Chen
  • 9,835
  • 1
  • 16
  • 28
0

I also had the problem of 500 server errors, and couldn't figure out why node wasn't starting when I started the site. There were a couple different kinds of logs you can turn on, but Diagnose and solve problems > Failed Request Tracing Logs is what helped me.

In the logs, I saw:

Warning:
ModuleName="RewriteModule", Notification="SEND_RESPONSE", HttpStatus="500", HttpReason="URL Rewrite Module Error.", HttpSubStatus="52", ErrorCode="2152071471", ConfigExceptionInfo=""
ErrorDescription="The expression "^server\app.js\/debug[\/]?" contains an escape sequence that is not valid."

And the problem came down to using Windows path separator -NodeStartFile server\app.js instead of URL path separator -NodeStartFile server/app.js in the Azure App Service Deploy task web.config parameter.

Carl Walsh
  • 6,100
  • 2
  • 46
  • 50