Step-by-Step Deployment Process

Step 1: Create a Node.js Application

1. Creating app.js

Start by creating a Node.js application. For simplicity, we’ll create a basic app.js file that responds with “Hello, Azure!”.Remember to initialise a new Node.js project using: npm init -y

Javascript




const express = require('express');
const app = express();
const port = process.env.PORT || 3000;
  
app.get('/', (req, res) => {
  res.send('Hello, Azure! This is a Node.js application.');
});
  
app.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});


2. Check application locally

Ensure your Node.js application runs correctly on your local machine by testing it locally. Run your application on port 3000 using the command “node app.js”

Open a web browser and go to http://localhost:3000 to see if the application is running.

3. Set up a Github repository

Create a GitHub repository (e.g., my-nodejs-app) and push the Node.js application code to the repo.

Step 2: Set Up Azure Resources

1. Sign in to Azure portal

Open your web browser and navigate to the Azure portal. Sign in with your Azure account or create a new account.

2. Configure app service plan

If you don’t have an active app service plan, go to the App Service plan section from the Azure resources marketplace to generate a new plan. Fill in the following details:

  1. Subscription: Choose your Azure subscription.
  2. Resource Group: Create a new or use an existing resource group.
  3. Name: Enter a unique name for your App Service. (my-nodejs-app-azure name was used here)
  4. Operating System: Choose your system’s operating system (Linux or Windows)
  5. Region: Choose the appropriate region

Click on ‘Review+Create’

3. Create a web app

Click on the “+ Create” button on the top left from the App Service section you created above and select “Web App”. Fill in the following details:

  1. Subscription: Choose your Azure subscription.
  2. Resource Group: Create a new or use an existing resource group.
  3. Name: Enter a unique name for your App Service. (my-nodejs-app-azure name was used here)
  4. Publish: Choose “Code”.
  5. Runtime Stack: Choose “Node.js 16LTS”.

Step 3: Deploy

1. Connect Github to Azure

Connect your GitHub repository to your Azure Web App for seamless deployments.In the Azure portal, navigate to your Web App and select “Deployment Center.” Choose GitHub as the source and connect to the GitHub repository (my-nodejs-app). Configure the deployment settings and select the branch to deploy.

2. View deployed website

Check your deployed Node.js application on Azure by browsing the Web App.Navigate to your Web App’s overview section in the Azure portal and click on “Browse” to view your deployed website. This should be same as the site we saw on localhost:3000.

Deploy a Node.js Application with Azure

Deploying a Node.js application on Azure, a prominent cloud computing platform, has become a seamless process, thanks to its user-friendly interface and integration capabilities. This guide aims to walk you through deploying a Node.js application on Azure using the Azure portal. We will cover essential terminologies, provide a step-by-step guide, and incorporate diagrams, screenshots, and examples to ensure a comprehensive understanding.

Similar Reads

Key Terminologies

Before we embark on the deployment journey, let’s familiarize ourselves with key terminologies related to Azure and deploying Node.js applications:...

Step-by-Step Deployment Process

Step 1: Create a Node.js Application...

FAQs On Node.js Application With Azure

...

Contact Us