I have a ridiculously simple Node/Express app that I am trying to get running in Azure App services. It's sole purpose is to allow me to learn by getting it working the to incrementally expand the app using Git and Azure Devops.
I'm stuck already.
I have a local folder 'node-starter' and in there is my app.js, package.json, node-modules (including Express) and so on. The app.js is very simple:
const express = require("express")
const app = express()
app.get("/", (req, res) => {
res.send({
"first": "jason",
"last": "bourne"
})
})
app.listen(3000,()=> {
console.log("server running....")
})
My package.json is also very simple:
{
"name": "node-starter",
"version": "1.0.0",
"description": "simple node and express app to test azure deployments",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"express": "^4.17.1"
}
}
When I run this locally using the npm start script the application runs and I can get the json response on the localhost on port 3000. Very simple and works perfectly locally.
What I then do is:
But, when I then browse to the URL provide by the App servive I typically get an application error 503. When I click on the link to get more information, I am taken to a blank Azure help screen. Just three flashing blue circles that never come to anything.
What might be going wrong? Everything looks like its setting up and deploying ok, the app just doesn't seem to be working once its deployed. It has to be something simple, right?
Couple of questions, if that's allowed:
I also tried deploying the app using the VSCode plugin and got exactly the same results. Please put me out my misery and tell me where I might be going wrong. Please.
Only ports 80 and 443 are open for Web Apps. You should change the listen port to process.env.PORT
.
const port = process.env.PORT;
app.listen(port);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With