1
votes

I have a "Hello, World" Node.js app. My app has the following structure:

/
  /src
    index.html
  package.json
  README.md

The index.html file just contains this:

<html>
  <body>
    <h1>Hello World!</h1>
  </body>
</html>

I am successfully running this locally using npm test via lite-server. My package.json file looks like this:

{
  "name":"my-hello-world",
  "version":"0.0.1",
  "description":"This is a test",
  "main":"index.js"
  "scripts": {
    "start": "lite-server --baseDir=src"
  },
  "author":"",
  "devDependencies": {
    "lite-server":"^2.5.3"
  }
}

I am attempting to deploy this via the "Azure App Service" Visual Studio Code extension. To do this, I:

  1. Right-click on my app service in the explorer.
  2. Choose "Deploy to Web App..."
  3. Select the "src" directory.
  4. Click the "Deploy" button

When I click "Browse Website", I just see a "Hey, Node developers!" splash screen. However, when I run npm start on my local machine, the "Hello World!" page shows as expected. What am I missing?

2

2 Answers

0
votes

I tried to deploy the node web to azure and configure the bs-config.json, the page will show error page. Then I check the Application Logs, then I found it will open localhost port and I check the lite-server github page, found it uses BrowserSync, it's a tool for local development.

enter image description here

If you just want to test node web with azure, you could try with the code provided by the official doc: Create a Node.js web app in Azure. You don't need change anything just extract the zip file and deploy it. It will work.

0
votes

I tried to deploy sample application of node https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-nodejs. I followed the step from the documentation and got the Hello World on screen. For more details Please refer to https://blog.darrenjrobinson.com/how-to-build-and-deploy-an-azure-nodejs-webapp-using-visual-studio-code/