Running a NodeJS and Express 4 App in Azure

I encountered 500 errors when I tried to move my Node/Express app to Azure. It ran fine on Heroku, but threw 500's when I ran it on Azure WebApps. I was using git deployment.

In order to get a NodeJS and Express 4 app running in Azure, follow these steps:


Create a file called Procfile in your root folder
Configure the file as follows (eg if app.js is in your root folder):

web: node app.js

If app.js exists in a subfolder such as /Server/app.js, then you would configure the file as:

web: node server/app.js


Create a web.config file and place it in the root. Adjust the server/app.js or app.js as needed (like mentioned in the step above). This will also redirect from HTTP to HTTPS (which you might/might not want)

<?xml version="1.0" encoding="utf-8"?>
    <webSocket enabled="false" />
      <add name="iisnode" path="server/app.js" verb="*" modules="iisnode"/>
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^server/app.js\/debug[\/]?" />
        <rule name="StaticContent">
          <action type="Rewrite" url="public{REQUEST_URI}"/>
        <rule name="DynamicContent">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
          <action type="Rewrite" url="server/app.js"/>
        <rule name="Redirect to HTTPS" stopProcessing="true">
          <match url="(.*)" />
            <add input="{HTTPS}" pattern="^OFF$" />
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
          <remove segment="bin"/>
    <httpErrors existingResponse="PassThrough" />