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

# Azure App Service - Linux Code

{% alert level="danger" %}
The AAS Linux Wrapper is now deprecated. It will continue to receive layer bumps but no new features. It will be retired on March 1, 2026, at which point no further updates will be provided. You can continue to use the wrapper after March 1, 2026, but its use will not be supported. Datadog strongly recommends switching to the [sidecar instrumentation method](https://docs.datadoghq.com/serverless/azure_app_service/linux_code) as soon as possible.
{% /alert %}

## Overview{% #overview %}

This instrumentation method provides the following additional monitoring capabilities for Linux Azure App Service workloads:

- Fully distributed APM tracing using automatic instrumentation.
- Customized APM service and trace views showing relevant Azure App Service metrics and metadata.
- Support for manual APM instrumentation to customize spans.
- `Trace_ID` injection into application logs.
- Support for submitting custom metrics using [DogStatsD](https://docs.datadoghq.com/extend/dogstatsd).

This solution uses the startup command setting and Application Settings for Linux Azure App Service to instrument the application and manage its configuration. Java, Node, .NET, PHP, and Python are supported.

### Setup{% #setup %}

#### Set application settings{% #set-application-settings %}

To instrument your application, begin by adding the following key-value pairs under **App settings** in your Azure "Environment variables" settings.

{% image
   source="https://datadog-docs.imgix.net/images/serverless/azure_app_service/application-settings.11370e675fea49d1906ce20ad41d8ec8.jpg?auto=format"
   alt="Azure App Service Configuration: the Application Settings, under the Configuration section of Settings in the Azure UI. Three settings are listed: DD_API_KEY, DD_SERVICE, and DD_START_APP." /%}

- `DD_API_KEY` is your Datadog API key.
- `DD_CUSTOM_METRICS_ENABLED` (optional) enables custom metrics.
- `DD_SITE` is the Datadog site [parameter](https://docs.datadoghq.com/getting_started/site/#access-the-datadog-site). Your site is . This value defaults to `datadoghq.com`.
- `DD_SERVICE` is the service name used for this program. Defaults to the name field value in `package.json`.
- `DD_START_APP` is the command used to start your application. For example, `node ./bin/www` (unnecessary for applications running in Tomcat).
- `DD_PROFILING_ENABLED` (optional) Enables the [Continuous Profiler](https://docs.datadoghq.com/profiler/enabling/dotnet/?tab=azureappservice), specific to .NET.

### Identifying your startup command{% #identifying-your-startup-command %}

Linux Azure App Service Web Apps built using the code deployment option on built-in runtimes depend on a startup command that varies by language. The default values are outlined in [Azure's documentation](https://learn.microsoft.com/en-us/troubleshoot/azure/app-service/faqs-app-service-linux#what-are-the-expected-values-for-the-startup-file-section-when-i-configure-the-runtime-stack-). Examples are included below.

Set these values in the `DD_START_APP` environment variable. Examples below are for an application named `datadog-demo`, where relevant.

| Runtime   | `DD_START_APP` Example Value                                                               | Description                                                                                                                                                                                                    |
| --------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Node.js   | `node ./bin/www`                                                                           | Runs the [Node PM2 configuration file](https://learn.microsoft.com/en-us/azure/app-service/configure-language-nodejs?pivots=platform-linux#configure-nodejs-server), or your script file.                      |
| .NET Core | `dotnet datadog-demo.dll`                                                                  | Runs a `.dll` file that uses your Web App name by default.**Note**: The `.dll` file name in the command should match the file name of your `.dll` file. In certain cases, this might not match your Web App.   |
| PHP       | `cp /home/site/wwwroot/default /etc/nginx/sites-available/default && service nginx reload` | Copies script to correct location and starts application.                                                                                                                                                      |
| Python    | `gunicorn --bind=0.0.0.0 --timeout 600 quickstartproject.wsgi`                             | Custom [startup script](https://learn.microsoft.com/en-us/azure/app-service/configure-language-php?pivots=platform-linux#customize-start-up). This example shows a Gunicorn command for starting a Django app. |
| Java      | `java -jar /home/site/wwwroot/datadog-demo.jar`                                            | The command to start your app. This is not required for applications running in Tomcat.                                                                                                                        |

**Note**: The application restarts when new settings are saved.

#### Set General Settings{% #set-general-settings %}

{% tab title="Node, .NET, PHP, Python" %}
Go to **General settings** and add the following to the **Startup Command** field:

```
curl -s https://raw.githubusercontent.com/DataDog/datadog-aas-linux/v1.14.0/datadog_wrapper | bash
```

{% image
   source="https://datadog-docs.imgix.net/images/serverless/azure_app_service/startup-command-1.7655beacbd7a4e4282eaf0aebb660ab6.jpeg?auto=format"
   alt="Azure App Service Configuration: the Stack settings, under the Configuration section of Settings in the Azure UI. Underneath the stack, major version, and minor version fields is a 'Startup Command' field that is populated by the above curl command." /%}

{% /tab %}

{% tab title="Java" %}
Download the [`datadog_wrapper`](https://github.com/DataDog/datadog-aas-linux/releases) file from the releases and upload it to your application with the Azure CLI command:

```
  az webapp deploy --resource-group <group-name> --name <app-name> --src-path <path-to-datadog-wrapper> --type=startup
```

{% /tab %}

### Viewing traces{% #viewing-traces %}

When new Application Settings are saved, Azure restarts the application. However, if a startup command is added and saved, a restart may be required.

After the application restarts, you can view traces by searching for the service name (`DD_SERVICE`) in the [APM Service page](https://docs.datadoghq.com/tracing/services/service_page/) of Datadog.

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

To enable custom metrics for your application with DogStatsD, add `DD_CUSTOM_METRICS_ENABLED` and set it as `true` in your Application Settings.

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

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

## 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 **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/)
