Node.js agent on Microsoft Azure

This document describes special considerations for using Microsoft Azure as a hosting service with New Relic's Node.js agent.

Deploying Azure on a Mac

If you are using a Mac, view Microsoft's tutorial about deploying a Node.js app on Windows Azure. The tutorial assumes you have a working installation of Node.js and the Windows Azure SDK for Node.js for your platform:

  • Install the Windows Azure SDK for Node.js: Windows installer > Mac installer > Linux download.
  • If you are using Mac or Linux, install Node.js from (The Windows installer already includes Node.js.)
  • Make sure you have Git installed.

Installing the Node.js agent

Continue with these steps to add the New Relic Node.js agent to your Azure application.

  1. If there is no package.json file in your root, create one:
    app_dir > touch package.json
  2. Add the following to your package.json file:
            "name": "node",
            "version": "0.0.1",
            "dependencies" : {
              "newrelic" : "*"
            "engine": {
              "node": "10.18"
  3. Add require('newrelic'); to the top of the server.js file. For example:
          var http = require('http')
          var port = process.env.PORT || 1337;
          http.createServer(function(req, res) {
            res.writeHead(200, { 'Content-Type': 'text/plain' });
            res.end('Hello New Relic Node.js agent!\n');

Adding app settings in Azure

Continue with these steps to configure your app in Windows Azure.

  1. Sign in to
  2. Select Web Sites > (selected Node.js app) > Configure.
  3. Add the following to the app settings:

    • new_relic_app_name: your Windows Azure website name
    • new_relic_license_key: your New Relic license key
  4. Save your settings.
  5. Restart your Node.js app.

Within a few minutes you will see data in New Relic's user interface: From the New Relic APM menu bar, select Applications > (selected app).

Optional: Adding app settings with the CLI

Optional: Here is an example of how to add the app settings by using the CLI (Node SDK):

azure account download "Subscription Name"
azure account import "PathToPublishSettingsFile"
azure site config add "new_relic_app_name=REPLACE_WITH_YOUR_APP_NAME"
azure site config add "new_relic_license_key=REPLACE_WITH_YOUR_LICENSE_KEY"
azure site restart WindowsAzureWebSiteName

Using environment variables

If your agent runs in PaaS environments such as Heroku or Microsoft Azure, all of the configuration variables in newrelic.js have counterparts that can be set as environment variables. You can freely mix and match variables in the configuration file. Environment variables override your configuration file settings.

For example, as a convenience to Azure users, the agent will use APP_POOL_ID as the application name (NEW_RELIC_APP_NAME) if it's set, so you can use the name you chose for your Azure Web Server without setting it twice. For more information, see Configuring Node.js with environment variables.

For more help

Additional documentation resources include:

Join the discussion about Node.js monitoring in the New Relic Online Technical Community! The Technical Community is a public platform to discuss and troubleshoot your New Relic toolset.

If you need additional help, get support at