Build and Deploy Node.js web apps in Azure App Service

Author by Zavier Sanders

This quick tutorial shows you how to build a simple Node.js application and deploy it to the Azure App Service, from the command-line. The steps in this tutorial can be followed on any operating system that can run Node.js.  

 

Prerequisites

 

Create Node.js web app

  1. Open the command-line terminal and install the Yeoman Express generator.

 

npm install -g generator-express

 
  1. Within a working directory, generate an express app.

    

yo express

 
  1. Choose the following options:

    

Would you like to create a new directory for your project? Yes
Enter directory name: <appname>
Select a version to install: MVC
Select a view engine to use: Jade
Select a css preprocessor to use (Sass Requires Ruby): None
Select a database to use: None
Select a build tool to use: Grunt

    

  1. CD into the root of your new app. We’ll want to make sure it runs in your development environment.

 

npm start      

    

Within your browser, go to http://localhost:3000. You should see the Express home page. We now have a simple running Node.js web app using Express.

 

Deploy to Azure App Service

Now that you’ve verified the app runs correctly, type  Crtl+c  in the command terminal to stop it.

 
  1. Enter the following commands to change into ASM Mode and log in to Azure.

 

azure config mode asm
azure login

 

Use the prompt to login through the browser with your Microsoft account.

 
  1. Within the root directory of your application, create the App Service app resource in Azure using the following command.

 

azure site create --git <appname>

 

Follow the prompt to create Git/FTP deployment credentials, if you never set them up before.

 
  1. Use git to deploy your app to Azure.

 

git add.
git commit -m “<your commit message>”
git push azure master

 
  1. Lastly, launch your live Azure app in the browser with the following command.

 

azure site browse

 

You now have a very simple Node.js web app running live in Azure App Service.

 

 

The Azure App Service is a fully managed platform for web, mobile, and integration scenarios. Although this tutorial is a pretty basic example, it shows how easy it is to build and deploy a Node.js web app to Azure App Service.

 

 
Tags in this Article