Build a simple Express app but unable to host it on Azure App Service.

IamTypingNow 20 Reputation points
2023-05-31T16:16:07.66+00:00

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)

  1. index.js (proivded below)
  2. package.json (provided below)
  3. 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.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,939 questions
{count} votes

Accepted answer
  1. VenkateshDodda-MSFT 24,951 Reputation points Microsoft Employee Moderator
    2023-06-01T06:47:12.77+00:00

    @IamTypingNow Thanks for reaching out to Microsoft Q&A, apologize for any inconvenience caused on this.

    Could you please run the WebApp down detector under Diagnose and solve problems of your web app to identify/ to understand more why you are getting 500 error while requesting the root url of the web app whether this might be causing from application code end or by any platform issue.

    Also, you can enable the diagnostic logging in app service and review the application logs/log stream logs.

    For more information, you can make use of the below blogs to troubleshoot node apps on app service.

    1. Debug node js apps on app service 1 2
    2. Common iis node issues

    Feel free to reach back to me if you have any further questions on this.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.