Microsoft Azure App Services is a group of serverless resources that enable you to build and host web apps, mobile back ends, event-driven functions, and RESTful APIs without managing infrastructure. It can host workloads of all sizes and offers auto-scaling and high availability options.
Datadog provides monitoring capabilities for all Azure App Services resource types:
The Datadog extension for Azure App Services provides additional monitoring capabilities for Azure Web Apps. This support includes:
Trace_ID
injection into application logs.If you haven’t already, set up the Microsoft Azure integration first.
The Datadog .NET APM extension supports the following .NET runtimes in both x64 and x86 architectures when running on Windows instances (AAS does not yet support extensions on Linux). For more details about automatically instrumented libraries, see the Tracer documentation.
DD_API_KEY
and a value of your Datadog API Key.DD_SITE
to
. Defaults to datadoghq.com
.Sending logs from your application in Azure App Services to Datadog requires the use of Serilog. Submitting logs with this method allows for trace ID injection, which makes it possible to connect logs and traces in Datadog. To enable trace ID injection with the extension, add the application setting DD_LOGS_INJECTION:true
.
Note: Since this occurs inside your application, any Azure Platform logs you may be submitting with diagnostic settings does not include the trace ID.
Install the Datadog Serilog sink NuGet package, which sends events and logs to Datadog. By default, the sink forwards logs through HTTPS on port 443. Run the following command in the application’s package manager console:
PM> Install-Package Serilog.Sinks.Datadog.Logs
Next, initialize the logger directly in your application. Replace <DD_API_KEY>
with your Datadog API key.
using Serilog;
using Serilog.Sinks.Datadog.Logs;
Serilog.Log.Logger = new LoggerConfiguration()
.WriteTo.DatadogLogs("<DD_API_KEY>")
.Enrich.FromLogContext()
.CreateLogger();
You can also override the default behavior and forward logs in TCP by manually specifying the following required properties: url, port, useSSL, and useTCP. Optionally, specify the source, service, and custom tags.
For example, to forward logs to the Datadog US region in TCP use the following sink configuration:
using Serilog;
using Serilog.Sinks.Datadog.Logs;
var config = new DatadogConfiguration(
url:"https://http-intake.logs.datadoghq.com",
port:10516,
useSSL:true,
useTCP:false);
Serilog.Log.Logger = new LoggerConfiguration()
.WriteTo.DatadogLogs(
"eb7c615e5fca779871203b7de9209b6c",
source: "<SOURCE_NAME>",
service: "<SERVICE_NAME>",
tags: new string[] { "<TAG_1>:<VALUE_1>", "<TAG_2>:<VALUE_2>" },
configuration: config
)
.Enrich.FromLogContext()
.CreateLogger();
New Logs are now directly sent to Datadog.
Alternatively, since 0.2.0, configure the Datadog sink by using an appsettings.json
file with the Serilog.Settings.Configuration NuGet package.
In the Serilog.WriteTo()
array, add an entry for DatadogLogs, for example:
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.Datadog.Logs" ],
"MinimumLevel": "Debug",
"WriteTo": [
{ "Name": "Console" },
{
"Name": "DatadogLogs",
"Args": {
"apiKey": "<API_KEY>",
"source": "<SOURCE_NAME>",
"host": "<HOST_NAME>",
"tags": ["<TAG_1>:<VALUE_1>", "<TAG_2>:<VALUE_2>"],
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Properties": {
"Application": "Sample"
}
}
Starting with version 0.3.14-prerelease
, the App Services extension includes an instance of DogStatsD (Datadog’s metrics aggregation service). This enables you to submit custom metrics, service checks, and events directly to Datadog from Azure Web Apps with the extension.
Writing custom metrics and checks in your web app is similar to the process for doing so with an application on a host running the Datadog Agent. However, there is no need to configure ports, which is taken care of by the extension automatically. To submit custom metrics to Datadog from Azure App Services using the extension:
Learn more about custom metrics.
If your app begins throwing 5XX errors immediately after installation, first try to reinstall with the application in a full stop. To do this:
A clean install to a stopped app typically solves the problem. However, if you’re still getting 5XX errors, it may be related to something like an enabled debug setting, which can slow down the startup time of your application, and can result in a 500 error. You can also try:
If you’re missing traces or not receiving them at all, make sure you have not manually adjusted any port settings. The Tracer Agent, in the extension, communicates with your application to identify the correct port to use for external traffic. Manual port settings can interfere with this process resulting in missed traces.
Still need help? Contact Datadog support.
Additional helpful documentation, links, and articles:
On this Page