Hello, I wanted to learn and get familiar with Azure App Service and decided to do that by creating and testing a simple Express App called 'test-app-name'.
My repository is very simple and it just has following files. It runs successfully when I run on my localhost but it won't load when I hosted it on Azure App Service and even connected it to my GitHub repository in Deployment Center (I get 500 error that says This page isn’t working)
- index.js (proivded below)
- package.json (provided below)
- node_modules, .gitignore, package-lock.json.
import dotenv from 'dotenv'
dotenv.config()
import express from 'express';
import cors from 'cors';
import bodyParser from 'body-parser';
const port = process.env.PORT || 3000;
const app = express();
app.use(cors());
app.get('/', (req, res) => {
console.log('Hello World~');
res.send('Hello World!');
});
app.listen(3000);
{
"name": "test-app-name",
"version": "1.0.0",
"main": "index.js",
"type": "module",
"dependencies": {
"cors": "^2.8.5",
"debug": "^3.2.7",
"dotenv": "^16.0.3",
"express": "^4.18.2"
},
"scripts": {
"test": "echo \"Just some Testing here...\"",
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}
I really am not able to understand why this App is not working and I did verify in Azure portal that the App was deployed successfully (and again when it re-deployed after I connected it to my GitHub repository). I also created another app and tested using this documentation (https://learn.microsoft.com/en-us/azure/app-service/quickstart-nodejs?tabs=windows&pivots=development-environment-vscode) and this worked fine.
For my 'test-app-name', I also did the Step 12 ~ 14 as noted in the documentation above but it still gave the same error.
Any advice would be great. My goal is to learn why it's not working instead of getting it to even work, and I am just not able to find the answer.