1

I have an Azure App service instance and I want to deploy an express application to this instance.

To test it in the simplest way possible I generated a fresh express API application using:

generator-express-no-stress : https://www.npmjs.com/package/generator-express-no-stress

Tested it locally and could access the landing page and swagger documentation.

On the Azure portal, I set up a local git deployment and then pushed the local express application to the Azure instance.

When pushing to the remote App Service instance everything seemed to go fine and no error messages popped up and got the standard:

remote: Finished successfully.
remote: Running post deployment command(s)...
remote: Deployment successful.
To https://****.scm.azurewebsites.net:443/****.git
* [new branch]      master -> master

I assumed that the express API is now running on the Azure app instance but it isn't.

I go to the main page to view the landing page:

https://****.azurewebsites.net

Or the swagger api-explorer:

https://****.azurewebsites.net/api-explorer

I just get 404 page not found.

I haven't modified anything just done exactly as stated above.

Do I need to do anything else to get the express API to work?

Softey
  • 1,451
  • 3
  • 21
  • 42
  • Are you listening on `process.env.PORT`? You can't hardcode a port number for App Service: https://stackoverflow.com/a/43452334/4148708 – evilSnobu Mar 11 '18 at 14:03
  • Yes it has that as the initial value for the port selection – Softey Mar 11 '18 at 14:31
  • When you deploy, do you get a `remote: Detected Node application` or something similar? – evilSnobu Mar 11 '18 at 15:26
  • Not that wording exactly but it's clear it knows it is node from the version print out and running of NPM start. – Softey Mar 11 '18 at 15:29

1 Answers1

1

If you look closer at the remote: deployment output these three lines stand out:

remote: Invalid start-up command "cd build && node main" in package.json.
        Please use the format "node <script relative path>".
remote: Looking for app.js/server.js under site root.
remote: Missing server.js/app.js files, web.config is not generated

The missing web.config is what prevents your app from booting.

I'm sure there's a fix but the easier fix is to just switch to an App Service Linux worker and push a Docker image. You could try the built-in Node image first.

evilSnobu
  • 24,582
  • 8
  • 41
  • 71