---
title: Azure App Service - Linux Code
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Serverless > Serverless Monitoring for Azure App Service > Azure App
  Service - Linux Code
---

# Azure App Service - Linux Code

## Overview{% #overview %}

This page describes how to instrument your Linux Azure App Service application with the Datadog Agent. The procedure on this page makes use of a sidecar container and Application Settings for Linux Azure App Service to instrument the application and manage its configuration.

If you would prefer to not use the sidecar approach (Not Recommended), you can instead follow the instructions to [Instrument Azure App Service - Linux Code Deployment with the Datadog wrapper](https://docs.datadoghq.com/serverless/guide/azure_app_service_linux_code_wrapper_script).

**Supported runtimes**: Java, Node.js, .NET, PHP, Python

## Setup{% #setup %}

### Azure integration{% #azure-integration %}

If you haven't already, install the [Datadog-Azure integration](https://app.datadoghq.com/integrations/azure) to collect metrics and logs.

### Application{% #application %}

Install the tracing library for your language:

{% tab title="Java" %}
Java supports adding instrumentation code through the use of a command line argument, `javaagent`.

1. Download the [latest version of Datadog's Java tracing library](https://dtdg.co/latest-java-tracer).
1. Place the tracing library inside your project. It must be included with your deployment. If you are using the `azure-webapp-maven` plugin, you can add the Java tracing library as a resource entry with type `lib`.
1. Set the environment variable `JAVA_OPTS` with `--javaagent:/home/site/lib/dd-java-agent.jar`. When your application is deployed, the Java tracer is copied to `/home/site/lib/dd-java-agent.jar`.

Instrumentation starts when the application is launched.
{% /tab %}

{% tab title="Node.js" %}

1. Install the `dd-trace` package
   ```
   npm install dd-trace
   ```
1. Initialize the Node.js tracer with the `NODE_OPTIONS` environment variable:
   ```
   NODE_OPTIONS='--require dd-trace/init'
   ```

{% /tab %}

{% tab title=".NET" %}
Add the `Datadog.Trace.Bundle` Nuget package to your project. See [the Nuget package page for more details](https://www.nuget.org/packages/Datadog.Trace.Bundle#readme-body-tab).

For example:

```shell
dotnet add package Datadog.Trace.Bundle --version 3.21.0
```

{% /tab %}

{% tab title="PHP" %}
Run the following script to install Datadog's PHP tracing library: startup.sh:

```bash
#!/usr/bin/env bash

echo "Setting up Datadog tracing for PHP"
DD_PHP_TRACER_VERSION=1.8.3
DD_PHP_TRACER_URL=https://github.com/DataDog/dd-trace-php/releases/download/${DD_PHP_TRACER_VERSION}/datadog-setup.php

echo "Installing PHP tracer from ${DD_PHP_TRACER_URL}"
if curl -LO --fail "${DD_PHP_TRACER_URL}"; then
    eval "php datadog-setup.php --php-bin=all"
else
    echo "Downloading the tracer was unsuccessful"
    return
fi

# This line is can be uncommented if the project contains an nginx configuration in the project root
# cp /home/site/wwwroot/default /etc/nginx/sites-available/default && service nginx reload

service nginx reload
```

This bash script is intended to run as the startup command, which installs the tracing module into PHP and then restarts the NGINX service.
{% /tab %}

{% tab title="Python" %}

1. Add `ddtrace` to your project.

1. Modify your startup command. Your new command should run `ddtrace-run` with your old command as an argument. That is: if your startup command is `foo`, modify it to run `ddtrace-run foo`.

For example:

   ```
   ddtrace-run gunicorn --bind=0.0.0.0 --timeout 600 quickstartproject.wsgi
   ```

{% /tab %}

### Instrumentation{% #instrumentation %}

{% tab title="Datadog CLI" %}
#### Locally{% #locally %}

Install the [Datadog CLI](https://github.com/DataDog/datadog-ci#how-to-install-the-cli)

```shell
npm install -g @datadog/datadog-ci @datadog/datadog-ci-plugin-aas
```

Install the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) and authenticate with `az login`.

Then, run the following command to set up the sidecar container:

```shell
export DD_API_KEY=<DATADOG_API_KEY>
export DD_SITE=<DATADOG_SITE>
datadog-ci aas instrument -s <subscription-id> -g <resource-group-name> -n <app-service-name>
```

Set your Datadog site to . Defaults to `datadoghq.com`.

Additional flags, like `--service` and `--env`, can be used to set the service and environment tags. For a full list of options, run `datadog-ci aas instrument --help`.

#### Azure Cloud Shell{% #azure-cloud-shell %}

To use the Datadog CLI in [Azure Cloud Shell](https://portal.azure.com/#cloudshell/), open a cloud shell, set your API key and site in the `DD_API_KEY` and `DD_SITE` environment variables, and use `npx` to run the CLI directly:

```shell
export DD_API_KEY=<DATADOG_API_KEY>
export DD_SITE=<DATADOG_SITE>
npx @datadog/datadog-ci aas instrument -s <subscription-id> -g <resource-group-name> -n <app-service-name>
```

{% /tab %}

{% tab title="Terraform" %}
The [Datadog Terraform module for Linux Web Apps](https://registry.terraform.io/modules/DataDog/web-app-datadog/azurerm/latest/submodules/linux) wraps the [azurerm_linux_web_app](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_web_app) resource and automatically configures your Web App for Datadog Serverless Monitoring by adding required environment variables and the serverless-init sidecar.

If you don't already have Terraform set up, [install Terraform](https://developer.hashicorp.com/terraform/install), create a new directory, and make a file called `main.tf`.

Then, add the following to your Terraform configuration, updating it as necessary based on your needs:

```tf
variable "datadog_api_key" {
  description = "Your Datadog API key"
  type        = string
  sensitive   = true
}

provider "azurerm" {
  features {}
  subscription_id = "00000000-0000-0000-0000-000000000000" // Replace with your subscription ID
}

resource "azurerm_service_plan" "my_asp" {
  name                = "my-app-service-plan" // Replace with your app service plan name
  resource_group_name = "my-resource-group"   // Replace with your resource group name
  os_type             = "Linux"
  location            = "eastus"
  sku_name            = "P1v2"
}

module "my_web_app" {
  source  = "DataDog/web-app-datadog/azurerm//modules/linux"
  version = "~> 1.0"

  name                = "my-web-app"        // Replace with your web app name
  resource_group_name = "my-resource-group" // Replace with your resource group name
  service_plan_id     = azurerm_service_plan.my_asp.id
  location            = "eastus"

  datadog_api_key = var.datadog_api_key
  datadog_service = "my-service" // Replace with your service name
  datadog_env     = "prod"       // Replace with your environment (e.g. prod, staging)
  datadog_version = "0.0.0"      // Replace with your application version

  site_config = {
    application_stack = {
      python_version = "3.13" // change for your specific runtime
    }
  }
  app_settings = {
    DD_TRACE_ENABLED = "true" // Example setting
  }
}
```

Finally, run `terraform apply`, and follow any prompts.

The [Datadog Linux Web App module](https://registry.terraform.io/modules/DataDog/web-app-datadog/azurerm/latest/submodules/linux) only deploys the Web App resource, so you need to [deploy your code](https://learn.microsoft.com/en-us/azure/app-service/getting-started) separately.
{% /tab %}

{% tab title="Bicep" %}
Update your existing Web App to include the necessary Datadog App Settings and sidecar, as follows:

```bicep
resource webApp 'Microsoft.Web/sites@2025-03-01' = {
  // ...
  properties: {
    // ...
    siteConfig: {
      // ...
      appSettings: concat(datadogAppSettings, [
        //... Your existing app settings
      ])
    }
  }
}

@secure()
param datadogApiKey string

var datadogAppSettings = [
  { name: 'DD_API_KEY', value: datadogApiKey }
  { name: 'DD_SITE', value: 'datadoghq.com' }  // Replace with your Datadog site
  { name: 'DD_SERVICE', value: 'my-service' }  // Replace with your service name
  { name: 'DD_ENV', value: 'prod' }            // Replace with your environment (e.g. prod, staging)
  { name: 'DD_VERSION', value: '0.0.0' }       // Replace with your application version
  { name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE', value: 'true' }
  // Uncomment for .NET applications
  // { name: 'DD_DOTNET_TRACER_HOME', value: '/datadog/tracer' }
  // { name: 'CORECLR_ENABLE_PROFILING', value: '1' }
  // { name: 'CORECLR_PROFILER', value: '{846F5F1C-F9AE-4B07-969E-05C26BC060D8}' }
  // { name: 'CORECLR_PROFILER_PATH', value: '/datadog/tracer/Datadog.Trace.ClrProfiler.Native.so' }
  { name: 'DD_LOGS_INJECTION', value: 'true' }
  { name: 'DD_TRACE_ENABLED', value: 'true' }
  // Add any additional options here
]

resource sidecar 'Microsoft.Web/sites/sitecontainers@2025-03-01' = {
  parent: webApp
  name: 'datadog-sidecar'
  properties: {
    image: 'index.docker.io/datadog/serverless-init:latest'
    isMain: false
    targetPort: '8126'
    environmentVariables: [for v in datadogAppSettings: { name: v.name, value: v.name }]
  }
}
```

Redeploy your updated template:

```shell
az deployment group create --resource-group <RESOURCE GROUP> --template-file <TEMPLATE FILE>
```

See the Manual tab for descriptions of all environment variables.
{% /tab %}

{% tab title="ARM Template" %}
Update your existing Web App to include the necessary Datadog App Settings and sidecar, as follows:

```jsonc
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "webAppName": {
      "type": "string"
    },
    // ...
    "datadogApiKey": {
      "type": "securestring"
    }
  },
  "variables": {
    "datadogAppSettings": [
      { "name": "DD_API_KEY", "value": "[parameters('datadogApiKey')]" },
      { "name": "DD_SITE", "value": "datadoghq.com" }, // Replace with your Datadog site
      { "name": "DD_SERVICE", "value": "my-service" }, // Replace with your service name
      { "name": "DD_ENV", "value": "prod" },           // Replace with your environment (e.g. prod, staging)
      { "name": "DD_VERSION", "value": "0.0.0" },      // Replace with your application version
      { "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE", "value": "true" },
      // Uncomment for .NET applications
      // { "name": "DD_DOTNET_TRACER_HOME", "value": "/datadog/tracer" }
      // { "name": "CORECLR_ENABLE_PROFILING", "value": "1" }
      // { "name": "CORECLR_PROFILER", "value": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}" }
      // { "name": "CORECLR_PROFILER_PATH", "value": "/datadog/tracer/Datadog.Trace.ClrProfiler.Native.so" }
      { "name": "DD_LOGS_INJECTION", "value": "true" },
      { "name": "DD_TRACE_ENABLED", "value": "true" }
      // Add any additional options here
    ],
    "yourAppSettings": [
      // Add your app settings here
    ]
  },
  "resources": {
    "webApp": {
      "type": "Microsoft.Web/sites",
      "apiVersion": "2025-03-01",
      "name": "[parameters('webAppName')]",
      // ...
      "properties": {
        // ...
        "siteConfig": {
          // ...
          "appSettings": "[concat(variables('datadogAppSettings'), variables('yourAppSettings'))]"
        }
      }
    },
    "sidecar": {
      "type": "Microsoft.Web/sites/sitecontainers",
      "apiVersion": "2025-03-01",
      "name": "[concat(parameters('webAppName'), '/datadog-sidecar')]",
      "properties": {
        "image": "index.docker.io/datadog/serverless-init:latest",
        "isMain": false,
        "targetPort": "8126",
        "copy": [{
          "name": "environmentVariables", "count": "[length(variables('datadogAppSettings'))]",
          "input": {
            "name": "[variables('datadogAppSettings')[copyIndex('environmentVariables')].name]",
            "value": "[variables('datadogAppSettings')[copyIndex('environmentVariables')].name]"
          }
        }],
      }
    }
  }
}
```

Redeploy your updated template:

```bash
az deployment group create --resource-group <RESOURCE GROUP> --template-file <TEMPLATE FILE>
```

See the Manual tab for descriptions of all environment variables.
{% /tab %}

{% tab title="Manual" %}

1. **Configure environment variables**. In Azure, add the following key-value pairs in **Settings** > **Environment Variables** > **App Settings**:

{% dl %}

{% dt %}
`DD_API_KEY`
{% /dt %}

{% dd %}
**Value**: Your Datadog API key.See [Organization Settings > API Keys](https://app.datadoghq.com/organization-settings/api-keys) in Datadog.
{% /dd %}

{% dt %}
`DD_SITE`
{% /dt %}

{% dd %}
**Value**: Your [Datadog site](https://docs.datadoghq.com/getting_started/site/). Defaults to `datadoghq.com`.Use the "Datadog Site" drop-down menu on this page's right navigation bar to select your site.
{% /dd %}

{% dt %}
`DD_SERVICE`
{% /dt %}

{% dd %}
**Value**: Your application's service name.Defaults to the name field value in `package.json`.See [Unified Service Tagging](https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging) for more information on the `service` tag.
{% /dd %}

{% dt %}
`DD_ENV`
{% /dt %}

{% dd %}
**Value**: Your application's environment name.There is no default value for this field.See [Unified Service Tagging](https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging) for more information on the `env` tag.
{% /dd %}

{% dt %}
`DD_VERSION`
{% /dt %}

{% dd %}
**Value**: Your application's version.There is no default value for this field.See [Unified Service Tagging](https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging) for more information on the `version` tag.
{% /dd %}

{% dt %}
`WEBSITES_ENABLE_APP_SERVICE_STORAGE`
{% /dt %}

{% dd %}
**Value**: `true`Setting this environment variable to `true` allows the `/home/` mount to persist and be shared with the sidecar.
{% /dd %}

{% dt %}
`DD_SERVERLESS_LOG_PATH`
{% /dt %}

{% dd %}
**Value**: The log path the sidecar uses to collect logs.Where you write your logs. For example, `/home/LogFiles/*.log` or `/home/LogFiles/myapp/*.log`.
{% /dd %}

{% dt %}
`DD_AAS_INSTANCE_LOGGING_ENABLED`
{% /dt %}

{% dd %}
**Value**: falseWhen `true`, log collection is automatically configured for the additional file path: `/home/LogFiles/*$COMPUTERNAME*.log`
{% /dd %}

{% dt %}
`DD_AAS_INSTANCE_LOG_FILE_DESCRIPTOR`
{% /dt %}

{% dd %}
**Value**: An optional file descriptor used for more precise log tailing.Recommended for scenarios with frequent log rotation. For example, setting `_default_docker` configures the log tailer to ignore rotated files and focus only on Azure's active log file.
{% /dd %}

{% /dl %}

{% alert level="info" %}
If your application has multiple instances, make sure your application's log filename includes the `$COMPUTERNAME` variable. This ensures that log tailing does not create duplicate logs from multiple instances that are reading the same file. Enabling this feature variable also prevents `DD_SERVERLESS_LOG_PATH` from being set. This is to prevent ingesting duplicate logs.
{% /alert %}

{% collapsible-section #dotnet-additional-settings %}
#### .NET: Additional required environment variables

For .NET applications, the following environment variables are **required**. See the `Datadog.Tracer.Bundle` [Nuget package README file](https://www.nuget.org/packages/Datadog.Trace.Bundle#readme-body-tab) for more details.

{% dl %}

{% dt %}
`DD_DOTNET_TRACER_HOME`
{% /dt %}

{% dd %}
**Value**: `/home/site/wwwroot/datadog`Path to the directory containing the .NET tracing libraries.
{% /dd %}

{% dt %}
`CORECLR_ENABLE_PROFILING`
{% /dt %}

{% dd %}
**Value**: `1`Enables the instrumentation APIs in the .NET runtime.
{% /dd %}

{% dt %}
`CORECLR_PROFILER`
{% /dt %}

{% dd %}
**Value**: `{846F5F1C-F9AE-4B07-969E-05C26BC060D8}`Identifier for Datadog's .NET the instrumentation library.
{% /dd %}

{% dt %}
`CORECLR_PROFILER_PATH`
{% /dt %}

{% dd %}
**Value**: `/home/site/wwwroot/datadog/``linux-x64/Datadog.Trace.ClrProfiler.Native.so` (single line)Path to the instrumentation library loaded by the .NET runtime.
{% /dd %}

{% /dl %}

{% /collapsible-section %}

**Configure a sidecar container for Datadog**.

1. In Azure, navigate to **Deployment** > **Deployment Center**. Select the **Containers** tab.
1. Click **Add** and select **Custom container**.
1. In the **Edit container** form, provide the following:
   - **Image source**: Other container registries
   - **Image type**: Public
   - **Registry server URL**: `index.docker.io`
   - **Image and tag**: `datadog/serverless-init:latest`
   - **Port**: 8126
   - **Environment Variables**: Include all previously configured Datadog environment variables.
1. Select **Apply**.

**Restart your application**.

If you modified a startup command, restart your application. Azure automatically restarts the application when new Application Settings are saved.

{% /tab %}

**Do not set** the following environment variables in your serverless environment. They should only be set in non-serverless environments.

- `DD_AGENT_HOST`
- `DD_TRACE_AGENT_URL`

### Deployment slots{% #deployment-slots %}

{% alert level="info" %}
Deployment slot instrumentation is in Preview. During the Preview, telemetry from slots appears under the main web app. To distinguish between slot and production telemetry, configure [unified service tagging](https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/) with distinct values for each slot.
{% /alert %}

{% collapsible-section %}
#### Instrument a deployment slot

To instrument a [deployment slot](https://learn.microsoft.com/en-us/azure/app-service/deploy-staging-slots) instead of the main web app, use one of the following methods.

{% tab title="Datadog CLI" %}
Using the [Datadog CLI](https://github.com/DataDog/datadog-ci#how-to-install-the-cli) (v5.9.0+), add the `--slot` flag. Use `--env` to set a distinct environment tag for the slot:

```shell
datadog-ci aas instrument -s <subscription-id> -g <resource-group-name> -n <app-service-name> --slot <slot-name> --env <slot-env>
```

Alternatively, provide the full slot resource ID with the `--resource-id` flag:

```shell
datadog-ci aas instrument --resource-id /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/sites/<app-name>/slots/<slot-name> --env <slot-env>
```

{% /tab %}

{% tab title="Terraform" %}
Use the [Datadog Linux Web App Slot module](https://registry.terraform.io/modules/DataDog/web-app-datadog/azurerm/latest/submodules/linux-slot):

```tf
module "my_web_app_slot" {
  source  = "DataDog/web-app-datadog/azurerm//modules/linux-slot"
  version = "~> 1.0"

  name                = "staging"             // Replace with your slot name
  app_service_id      = module.my_web_app.id  // Reference to your main web app
  resource_group_name = "my-resource-group"   // Replace with your resource group name

  datadog_api_key = var.datadog_api_key
  datadog_service = "my-service" // Replace with your service name
  datadog_env     = "staging"    // Set a distinct value for each slot
  datadog_version = "0.0.0"      // Replace with your application version

  site_config = {
    application_stack = {
      python_version = "3.13" // change for your specific runtime
    }
  }
  app_settings = {
    DD_TRACE_ENABLED = "true" // Example setting
  }
}
```

Run `terraform apply`, and follow any prompts.
{% /tab %}

{% tab title="Bicep" %}
Update your template to target a deployment slot instead of the main web app:

```bicep
param webAppName string
param slotName string

resource webApp 'Microsoft.Web/sites@2025-03-01' existing = {
  name: webAppName
}

resource slot 'Microsoft.Web/sites/slots@2025-03-01' = {
  parent: webApp
  name: slotName
  // ...
  properties: {
    // ...
    siteConfig: {
      // ...
      appSettings: concat(datadogAppSettings, [
        //... Your existing app settings
      ])
    }
  }
}

@secure()
param datadogApiKey string

var datadogAppSettings = [
  { name: 'DD_API_KEY', value: datadogApiKey }
  { name: 'DD_SITE', value: 'datadoghq.com' }  // Replace with your Datadog site
  { name: 'DD_SERVICE', value: 'my-service' }  // Replace with your service name
  { name: 'DD_ENV', value: 'staging' }          // Set a distinct value for each slot
  { name: 'DD_VERSION', value: '0.0.0' }       // Replace with your application version
  { name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE', value: 'true' }
  // Uncomment for .NET applications
  // { name: 'DD_DOTNET_TRACER_HOME', value: '/datadog/tracer' }
  // { name: 'CORECLR_ENABLE_PROFILING', value: '1' }
  // { name: 'CORECLR_PROFILER', value: '{846F5F1C-F9AE-4B07-969E-05C26BC060D8}' }
  // { name: 'CORECLR_PROFILER_PATH', value: '/datadog/tracer/Datadog.Trace.ClrProfiler.Native.so' }
  { name: 'DD_LOGS_INJECTION', value: 'true' }
  { name: 'DD_TRACE_ENABLED', value: 'true' }
  // Add any additional options here
]

resource sidecar 'Microsoft.Web/sites/slots/sitecontainers@2025-03-01' = {
  parent: slot
  name: 'datadog-sidecar'
  properties: {
    image: 'index.docker.io/datadog/serverless-init:latest'
    isMain: false
    targetPort: '8126'
    environmentVariables: [for v in datadogAppSettings: { name: v.name, value: v.name }]
  }
}
```

Redeploy your updated template:

```shell
az deployment group create --resource-group <RESOURCE GROUP> --template-file <TEMPLATE FILE>
```

{% /tab %}

{% tab title="ARM Template" %}
Update your template to target a deployment slot instead of the main web app:

```jsonc
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "webAppName": {
      "type": "string"
    },
    "slotName": {
      "type": "string"
    },
    // ...
    "datadogApiKey": {
      "type": "securestring"
    }
  },
  "variables": {
    "datadogAppSettings": [
      { "name": "DD_API_KEY", "value": "[parameters('datadogApiKey')]" },
      { "name": "DD_SITE", "value": "datadoghq.com" }, // Replace with your Datadog site
      { "name": "DD_SERVICE", "value": "my-service" }, // Replace with your service name
      { "name": "DD_ENV", "value": "staging" },        // Set a distinct value for each slot
      { "name": "DD_VERSION", "value": "0.0.0" },      // Replace with your application version
      { "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE", "value": "true" },
      // Uncomment for .NET applications
      // { "name": "DD_DOTNET_TRACER_HOME", "value": "/datadog/tracer" }
      // { "name": "CORECLR_ENABLE_PROFILING", "value": "1" }
      // { "name": "CORECLR_PROFILER", "value": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}" }
      // { "name": "CORECLR_PROFILER_PATH", "value": "/datadog/tracer/Datadog.Trace.ClrProfiler.Native.so" }
      { "name": "DD_LOGS_INJECTION", "value": "true" },
      { "name": "DD_TRACE_ENABLED", "value": "true" }
      // Add any additional options here
    ],
    "yourAppSettings": [
      // Add your app settings here
    ]
  },
  "resources": {
    "slot": {
      "type": "Microsoft.Web/sites/slots",
      "apiVersion": "2025-03-01",
      "name": "[concat(parameters('webAppName'), '/', parameters('slotName'))]",
      // ...
      "properties": {
        // ...
        "siteConfig": {
          // ...
          "appSettings": "[concat(variables('datadogAppSettings'), variables('yourAppSettings'))]"
        }
      }
    },
    "sidecar": {
      "type": "Microsoft.Web/sites/slots/sitecontainers",
      "apiVersion": "2025-03-01",
      "name": "[concat(parameters('webAppName'), '/', parameters('slotName'), '/datadog-sidecar')]",
      "properties": {
        "image": "index.docker.io/datadog/serverless-init:latest",
        "isMain": false,
        "targetPort": "8126",
        "copy": [{
          "name": "environmentVariables", "count": "[length(variables('datadogAppSettings'))]",
          "input": {
            "name": "[variables('datadogAppSettings')[copyIndex('environmentVariables')].name]",
            "value": "[variables('datadogAppSettings')[copyIndex('environmentVariables')].name]"
          }
        }]
      }
    }
  }
}
```

Redeploy your updated template:

```bash
az deployment group create --resource-group <RESOURCE GROUP> --template-file <TEMPLATE FILE>
```

{% /tab %}

{% /collapsible-section %}

### View traces in Datadog{% #view-traces-in-datadog %}

After your application restarts, go to Datadog's [APM Service page](https://docs.datadoghq.com/tracing/services/service_page/) and search for the service name you set for your application (`DD_SERVICE`).

### Custom metrics{% #custom-metrics %}

To configure your application to submit custom metrics, follow the appropriate steps for your runtime:

- [Java](https://docs.datadoghq.com/extend/dogstatsd/?tab=java#dogstatsd-client)
- [Node.js](https://github.com/brightcove/hot-shots)
- [.NET](https://docs.datadoghq.com/extend/dogstatsd/?tab=dotnet#dogstatsd-client)
- [PHP](https://docs.datadoghq.com/extend/dogstatsd/?tab=php#dogstatsd-client)
- [Python](https://docs.datadoghq.com/extend/dogstatsd/?tab=python#dogstatsd-client)

### Continuous Profiler{% #continuous-profiler %}

{% alert level="info" %}
Datadog's Continuous Profiler is available in preview for Python and Node.js on Linux Azure App Service.
{% /alert %}

To enable the Continuous Profiler, set the environment variable `DD_PROFILING_ENABLED=true`. For more information, see the [Continuous Profiler documentation](https://docs.datadoghq.com/profiler/).

## Deployment{% #deployment %}

To update your Datadog instrumentation with zero downtime, use [deployment slots](https://learn.microsoft.com/en-us/azure/app-service/deploy-best-practices#use-deployment-slots). You can create a workflow that uses [GitHub Action for Azure CLI](https://github.com/marketplace/actions/azure-cli-action).

See the sample [GitHub workflow](https://docs.datadoghq.com/resources/yaml/serverless/aas-workflow-linux.yaml).

## Troubleshooting{% #troubleshooting %}

If you are not receiving traces or custom metric data as expected, enable agent debug logging by setting `DD_LOG_LEVEL` in the sidecar configuration options. For tracer debugging set `DD_TRACE_DEBUG` to true. This generates logs additional debug logs for the sidecar and tracing library.

Be sure to enable **App Service logs** to receive debugging logs.

{% image
   source="https://datadog-docs.imgix.net/images/serverless/azure_app_service/app-service-logs.6c2a488a343168e0a7a3f53010798d24.png?auto=format"
   alt="Azure App Service Configuration: App Service logs, under the Monitoring section of Settings in the Azure UI. The 'Application logging' option is set to 'File System'." /%}

Share the content of the **Log stream** with [Datadog Support](https://docs.datadoghq.com/help).

## Further reading{% #further-reading %}

- [Monitor your Linux web apps on Azure App Service with Datadog](https://www.datadoghq.com/blog/monitor-azure-app-service-linux/)
