seanpmaxwell / express-generator-typescript

Create a new express app similar to express-generator but with TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Azure Web App not Starting, web.config?

lelong37 opened this issue · comments

Hey everyone,

Have everything deployed just ask it is on my local, I've tested production build and runtime locally:

  • npm run build
  • npm run start

And everything works great locally. As soon as I deploy to Azure Web App (App Service), looks like my app doesn't even start. From what I understand Azure by default will run your start command if it's in your package.json, which this project has, so not sure why app isn't starting.

Could you be so kind to confirm my web.config is correct? I don't think it is because I'm not able to run the app using typical:

node ./dist/server.js

I believe that's how my Azure Web App is attempting to start the app by the looks of my web.config.

Any help 🙏, would greatly be appreciated..! 🤞

<?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 in


formation, 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="server.js" verb="*" modules="iisnode"/>
    </handlers>
    <rewrite>
      <rules>
        <!-- Do not interfere with requests for node-inspector debugging -->
        <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^server.js\/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{PATH_INFO}"/>
        </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="server.js"/>
        </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>

Changed my Azure Web App to be Linux based vs. Windows, redployed app started immediately. Would be nice to get some prescriptive guidance for deploying to Azure Web App Windows based. Closing this issue for now.

just FYI, you should run with node /dist/index.js not node dist/server.js, if you look at the two files, server.js just sets it up, index.js actually starts the server.