I am eager to launch my Node.js Server on Azure App Services

While attempting to deploy my node.js server on Azure using app service, I consistently encounter various errors. The issues range from the build command being unavailable in the configuration to difficulties fetching content. It has become quite frustrating for me, and I am seeking a reliable documentation resource that provides accurate and up-to-date instructions for deploying a server on Azure.

I have already tried utilizing app services, configuring the app as required, and deploying it through CI/CD with the assistance of GitHub. Additionally, I have properly set the appropriate environment variables. Despite following all their instructions diligently, I still encountered difficulties!

Answer №1

I've successfully developed a Node.js application and deployed it to Azure using GitHub actions:

Here are the steps I followed for deployment:

  • Create an App Service in Azure Portal.
  • Make sure to configure the following settings in web app=>Settings=>Configuration=>Application Settings:
WEBSITE_NODE_DEFAULT_VERSION=Node_version>
WEBSITES_PORT=<Port_number_of_your_application>
SCM_DO_BUILD_DURING_DEPLOYMENT=true

  • Navigate to your web app =>Deployment =>Deployment Center=> Select GitHub as the Source and sign in with your GitHub account. Fill in the other fields with the relevant details from your repository.

  • Once you have saved the details, a YAML file (workflow) will be generated in GitHub, initiating the deployment process.
  • You can track the deployment status either through Actions in GitHub or Logs in Deployment Center of the App Service.

Workflow Details:

name: Building and deploying Node.js app to Azure Web App - <web_app_name>

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up Node.js version
        uses: actions/setup-node@v1
        with:
          node-version: '18.x'

      - name: npm install, build, and test
        run: |
          npm install
          npm run build --if-present
          npm run test --if-present
      
      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v2
        with:
          name: node-app
          path: .

  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v2
        with:
          name: node-app

      - name: 'Deploy to Azure Web App'
        uses: azure/webapps-deploy@v2
        id: deploy-to-webapp
        with:
          app-name: '<your_web_app_name>'
          slot-name: 'Production'
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_XXXXXXXXXX }}
          package: .

Successful Deployment:

GitHub:

Azure Portal:

Alternative Methods:

If desired, you can explore alternative methods for deploying Node.js applications such as through VSCode or the CLI.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

In my Node.js project, I am creating a condensed link by extracting an existing URL and saving it to my MongoDB database

Upon generating the short URL, I encounter an error when attempting to open it in my browser for redirection to the original URL. This browser error is displayed. Below is my code snippet:- This snippet is from my urlController.js file // const shortid = ...

Experiencing Error EBUSY: resource occupied or in use

When attempting to run a Node.js app for testing the Raspberry Pi 3 B + Gpio Onoff Module, an error is encountered: fs.js:114 throw err; Error: EBUSY: resource busy or locked, write at Object.writeSync (fs.js:568:3) at Object.writeFileSync (fs.js:1199:26 ...

Issue: A default engine was not specified and an extension was not provided (Utilizing ExpressJs and nunjucks)

I have been working with Nunjucks templating engine in Express js. The page renders correctly, but I am encountering an error in the console. Error: No default engine was specified and no extension was provided. Source: Nunjucks documentation var app = ...

Error encountered: API key is required - Issue found in: /node_modules/cloudinary/lib/utils.js at line 982

I encountered an issue with cloudinary while trying to upload photos on my website after adding a new function for Facebook login. "/home/ubuntu/workspace/YelpCamp/node_modules/cloudinary/lib/utils.js:982 throw "Must supply api_key"; ^ Mus ...

Unable to successfully install a node package using nopt on Ubuntu because of a problem within npm

After updating my Ubuntu to the latest version using update, upgrade, and dist-upgrade commands, I encountered an issue when trying to install yo globally with npm: mathrobin@mathrobin-pc:~$ sudo npm install -g yo The error message I received was: npm E ...

What is preventing me from defining an alias @bundled-es-modules/chai for chai?

When working with NPM, you have the option to install a package under an alias, like this: npm i alias@npm:real-package-name To learn more about this aliasing feature, check out the announcement here: b7b54f2d1 413 #3 530 Add support for package aliase ...

Searching for specific data within an embedded documents array in MongoDB using ID

While working with mongodb and nodejs to search for data within an embedded document, I encountered a strange issue. The query functions as expected in the database but not when implemented in the actual nodejs code. Below is the structure of my data obje ...

Unable to initiate a new project in Node.js

As I was working on adding a new project in Angular, everything was running smoothly until today. However, when trying to create a new project today, I noticed that the node_modules folder is missing and encountered the following errors: https://i.stack.i ...

unable to save the information to mongoDB

I've been attempting for the past 3 hours to save data from an HTML form to MongoDB using Node.js. When I click submit, it redirects to another page displaying the submitted data in JSON format, but it's not getting stored in the database. Here ...

In search of a fresh and modern Facebook node template

I've been on the hunt across the internet for a quality node.js Facebook template, but all I seem to stumble upon is this https://github.com/heroku/facebook-template-nodejs. It's okay, but it's built using express 2.4.6 and node 0.6.x. I wan ...

Prevent the thread from executing by utilizing a callback block

In my setup, I've implemented an ExpressJS middleware to verify the user's IP in the database and block further responses if there have been more than 7 failed login attempts within the last hour. To prevent unnecessary database queries, I added ...

"Encountering a socket connection error (ECONNREFUSED) in a Node application deployed on

Getting ECONNREFUSED error when attempting socket connection in Node app on openshift servers, but works fine on local machine. Hello there! I am currently working on a simple application that requires making an outgoing socket connection from my server.j ...

Managing various private npm repositories from Github on a single server

Currently, I have a node application hosted on GitHub within a private repository. In addition to the main application, there are custom modules that have been developed separately and stored in their own private repositories. Here is an example URL for t ...

Is there a way to reduce the version of npm in a nodejs project?

Despite many attempts made by others, I am still struggling to resolve this issue. I have experimented with the following: npm uninstall -g npm@<version> npm uninstall npm --save npm uninstall -g npm --save However, all my efforts have been unsuc ...

Having trouble accessing variable values within the nth-child selector in JavaScript

I am attempting to utilize the value of a variable within the element selector p:nth-child(0). Instead of hardcoding the number as 0, I want to dynamically assign the value of a variable. In this case, the variable is represented by i in a for loop. Howev ...

What could be causing the `npm: not found` error to appear when attempting to update the version of the Wordpress Docker image?

After encountering a challenging question, I was able to successfully resolve it Here's the situation: I have a Dockerized Wordpress site with Node.JS and NPM. The Dockerfile is structured as follows: FROM composer:2.5.8 as composer FROM wordpress:6. ...

The code "Grunt server" was not recognized as a valid command in the

I recently set up Grunt in my project directory with the following command: npm install grunt However, when I tried to run Grunt server in my project directory, it returned a "command not found" error. Raj$ grunt server -bash: grunt: command not found ...

The act of coming back with just one array

I'm having trouble grasping the concept of returning a single array from a function that calls another function multiple times. The issue I'm facing is that each time the scrapingfunction runs, the console.log in the code provided outputs an arra ...

Employ a variable within the fetch method to retrieve JSON data

Currently, I am in the process of developing a system that extracts specific information from a JSON file based on user input. One challenge that I am facing is how to incorporate a variable into the designated section of my code; fetch( ...

I am encountering an issue where I am unable to successfully fetch a cookie from the Express backend to the React

const express = require("express"); // const storiesRouter = require("./routes/storiesRouter") // const postsRouter = require("./routes/postsRouter"); // const usersRouter = require("./routes/usersRouter"); const cors = require("cors"); const cookieParser ...