title: How to define a web.config file for Azure deployment for a MEAN application?
body: <p>While my app runs fine locally, I'm having a difficult time deploying it to an Azure Web App.</p>
  
  <p>The structure of the application is as follows:</p>
  
  <ul>
  <li>./index.html</li>
  <li>./app.js - main node.js code, including Express middleware</li>
  <li>./*.js - supporting myapp's node.js code</li>
  <li>./assets/angular - Angular.js v1.2.x</li>
  <li>./assets/bootstrap</li>
  <li>./assets/css</li>
  <li>./assets/img</li>
  <li>./views - views for the application</li>
  <li>state.js routes to /myapp/* (e.g., /myapp/home, /myapp/login).</li>
  <li>all Express API calls are to /api/* (e.g., /api/version)</li>
  </ul>
  
  <p>After piecing together tidbits from other sources, my best guess for a web.config is as follows:</p>
  
  <pre><code>&lt;handlers&gt;
    &lt;!-- Indicates that the app.js file is a node.js site to be handled by the iisnode module --&gt;
    &lt;add name="iisnode" path="app.js" verb="*" modules="iisnode"/&gt;
  &lt;/handlers&gt;
  &lt;rewrite&gt;
    &lt;rules&gt;
      &lt;!-- Do not interfere with requests for node-inspector debugging --&gt;
      &lt;rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true"&gt;
        &lt;match url="^app.js\/debug[\/]?" /&gt;
      &lt;/rule&gt;
  
      &lt;rule name="Static files" stopProcessing="true"&gt;
        &lt;match url=".*" /&gt;
        &lt;conditions logicalGrouping="MatchAll"&gt;
          &lt;!-- Core application files --&gt;
          &lt;add input="{REQUEST_URI}" pattern="assets/" ignoreCase="true" /&gt;
          &lt;add input="{REQUEST_URI}" pattern="views/" ignoreCase="true" /&gt;
        &lt;/conditions&gt;
        &lt;action type="Rewrite" url="{REQUEST_URI}" /&gt;
      &lt;/rule&gt;
  
      &lt;rule name="Express.js API"&gt;
        &lt;match url="api/*" /&gt;
        &lt;action type="Rewrite" url="app.js"/&gt;
      &lt;/rule&gt;
  
      &lt;rule name="Angular"&gt;
        &lt;match url=".*" /&gt;
        &lt;conditions logicalGrouping="MatchAll"&gt;
          &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt;
          &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt;
        &lt;/conditions&gt;
        &lt;action type="Rewrite" url="index.html" /&gt;
      &lt;/rule&gt;        
    &lt;/rules&gt;
  &lt;/rewrite&gt;
  </code></pre>
  
  <p>Unfortunately, after publishing to Azure, while most of the assets/ and index.html file are loaded (as viewed in browser debug window), I get a "Failed to load resource: the server responded with a status of 500 (Internal Server Error)" on the /assets/angular/app.js.</p>
  
  <p>What could be causing this issue? Furthermore, is there a standard for deploying MEAN apps on Azure? Is there a standard web.config for this type of MEAN app?</p>