Azure App Service Tracing for Node.js

To use Instana to monitor a Node.js application that runs as an Azure App Service, install the Node.js Azure App Service collector, and enable tracing in the the Azure App Service UI.

Prerequisites

Ensure that an Instana agent is running in the environment where you want to monitor the App Services. For more information about how to configure the Instana agent for Azure monitoring, see Monitoring and instrumenting Microsoft Azure.

Installing the Node.js Azure App Service collector

To monitor a Node.js application that runs as an Azure App Service, you need to install the Node.js Azure App Service in-process collector, which is delivered by using the icr.io/instana/azure-container-services-nodejs Docker image. Use multi-step Docker builds to streamline and speed up the building of Docker images for Node.js applications that run on Azure App Service.

If your application uses CommonJS, follow the steps in the CommonJS section. If your application uses ECMAScript modules, follow the steps in the ECMAScript modules section.

CommonJS

Add the following lines to your Dockerfile after the last FROM clause:

COPY --from=icr.io/instana/azure-container-services-nodejs:latest /instana /instana
ENV NODE_OPTIONS="--require /instana/node_modules/@instana/azure-container-services"

Then, build the container, and push it to the image repository of your choice.

ECMAScript modules

Add the following lines to your Dockerfile after the last FROM clause:

  • For Node.js 18.19.0 and later, add the following commands:

    COPY --from=icr.io/instana/azure-container-services-nodejs:latest /instana /instana
    ENV NODE_OPTIONS="--import=/instana/node_modules/@instana/azure-container-services/esm-register.mjs"
    
  • For Node.js versions earlier to 18.19.0, add the following commands:

    COPY --from=icr.io/instana/azure-container-services-nodejs:latest /instana /instana
    ENV NODE_OPTIONS="--experimental-loader=/instana/node_modules/@instana/azure-container-services/esm-loader.mjs"
    

Then, build the container, and push it to the image repository of your choice.

Enable tracing

Before you proceed with the following steps, ensure that you installed the Node.js Azure App Service collector in your container image successfully.

  1. Open the Azure App Service that needs tracing by Instana. Open the azure app service

  2. On the configuration page, click Application Settings. Then, add the following two environment variables to the application settings:

    Add environment variables

  3. Save the changes, and restart the application.

    Save the configuration

Restrictions

Currently, Azure App Service monitoring is supported only on the Linux platform.