Create a Node.js app in Azure App Service on Linux


This article deploys an app to App Service on Linux. To deploy to App Service on Windows, see Create a Node.js app in Azure.

App Service on Linux provides a highly scalable, self-patching web hosting service using the Linux operating system. This quickstart shows how to deploy a Node.js app to App Service on Linux using the Cloud Shell.

You'll complete this quickstart in Cloud Shell, but you can also run these commands locally with Azure CLI.

Sample app running in Azure

If you don't have an Azure subscription, create a free account before you begin.

Use Azure Cloud Shell

Azure hosts Azure Cloud Shell, an interactive shell environment that you can use through your browser. Cloud Shell lets you use either bash or PowerShell to work with Azure services. You can use the Cloud Shell pre-installed commands to run the code in this article without having to install anything on your local environment.

To launch Azure Cloud Shell:

Option Example/Link
Select Try It in the upper-right corner of a code block. Selecting Try It doesn't automatically copy the code to Cloud Shell. Example of Try It for Azure Cloud Shell
Go to or select the Launch Cloud Shell button to open Cloud Shell in your browser.
Select the Cloud Shell button on the top-right menu bar in the Azure portal. Cloud Shell button in the Azure portal

To run the code in this article in Azure Cloud Shell:

  1. Launch Cloud Shell.
  2. Select the Copy button on a code block to copy the code.
  3. Paste the code into the Cloud Shell session with Ctrl+Shift+V on Windows and Linux, or Cmd+Shift+V on macOS.
  4. Press Enter to run the code.

Download the sample

In the Cloud Shell, create a quickstart directory and then change to it.

mkdir quickstart

cd quickstart

Next, run the following command to clone the sample app repository to your quickstart directory.

git clone

While running, it displays information similar to the following example:

Cloning into 'nodejs-docs-hello-world'...
remote: Counting objects: 40, done.
remote: Total 40 (delta 0), reused 0 (delta 0), pack-reused 40
Unpacking objects: 100% (40/40), done.
Checking connectivity... done.


The sample index.js sets the listening port to process.env.PORT. This environment variable is assigned by App Service.

Create a web app

Change to the directory that contains the sample code and run the az webapp up command.

In the following example, replace <app_name> with a unique app name.

cd nodejs-docs-hello-world

az webapp up -n <app_name>

This command may take a few minutes to run. While running, it displays information similar to the following example:

Creating Resource group 'appsvc_rg_Linux_CentralUS' ...
Resource group creation complete
Creating App service plan 'appsvc_asp_Linux_CentralUS' ...
App service plan creation complete
Creating app '<app_name>' ....
Webapp creation complete
Updating app settings to enable build after deployment
Creating zip with contents of dir /home/username/quickstart/nodejs-docs-hello-world ...
Preparing to deploy and build contents to app.
Fetching changes.

Generating deployment script.
Generating deployment script.
Generating deployment script.
Running deployment command...
Running deployment command...
Running deployment command...
Deployment successful.
All done.
  "app_url": "https://<app_name>",
  "location": "Central US",
  "name": "<app_name>",
  "os": "Linux",
  "resourcegroup": "appsvc_rg_Linux_CentralUS ",
  "serverfarm": "appsvc_asp_Linux_CentralUS",
  "sku": "STANDARD",
  "src_path": "/home/username/quickstart/nodejs-docs-hello-world ",
  "version_detected": "6.9",
  "version_to_create": "node|6.9"

The az webapp up command does the following actions:

  • Create a default resource group.

  • Create a default app service plan.

  • Create an app with the specified name.

  • Zip deploy files from the current working directory to the app.

Browse to the app

Browse to the deployed application using your web browser. Replace <app_name> with your app name.


The Node.js sample code is running in App Service on Linux with a built-in image.

Sample app running in Azure

Congratulations! You've deployed your first Node.js app to App Service on Linux.

Update and redeploy the code

In the Cloud Shell, type nano index.js to open the nano text editor.

Nano index.js

Make a small change to the text in the call to response.end:

response.end("Hello Azure!");

Save your changes and exit nano. Use the command ^O to save and ^X to exit.

You'll now redeploy the app. Substitute <app_name> with your app.

az webapp up -n <app_name>

Once deployment has completed, switch back to the browser window that opened in the Browse to the app step, and refresh the page.

Updated sample app running in Azure

Manage your new Azure app

Go to the Azure portal to manage the app you created.

From the left menu, click App Services, and then click the name of your Azure app.

Portal navigation to Azure app

You see your app's Overview page. Here, you can complete basic management tasks like browse, stop, start, restart, and delete.

App Service page in Azure portal

The left menu provides different pages for configuring your app.

Clean up resources

In the preceding steps, you created Azure resources in a resource group. If you don't expect to need these resources in the future, delete the resource group from the Cloud Shell. If you modified the region, update the resource group name appsvc_rg_Linux_CentralUS to the resource group specific to your app.

az group delete --name appsvc_rg_Linux_CentralUS

This command may take a minute to run.

Next steps