In this blog post, we dive into the realms of observability and monitoring, taking advantage of the latest advancements in Azure's Linux App Service. If you've been following App Service updates, you might have caught wind of the Public Preview for the Sidecar Pattern for Linux App Service announced recently. Leveraging this development, we're here to guide you through integrating Datadog, an Azure Native ISV service partner that provides a powerful observability platform, with your .NET custom container application hosted on Linux App Service. Whether you're eager to streamline log management, track application traces, or enhance request monitoring, we've got you covered.
To get started, you'll need to containerize your .NET application. This tutorial walks you through the process step by step.
Once your application is containerized, you can integrate the Datadog tracer. To do that, you will need to add the following lines to the Dockerfile for your main application.
# Datadog specific
RUN mkdir -p /datadog/tracer
RUN mkdir -p /home/LogFiles/dotnet
ADD https://github.com/DataDog/dd-trace-dotnet/releases/download/v2.49.0/datadog-dotnet-apm-2.49.0.tar.gz /datadog/tracer
RUN cd /datadog/tracer && tar -zxf datadog-dotnet-apm-2.49.0.tar.gz
This ensures that the Datadog tracer is properly installed and configured within your application container.
Below is a sample Dockerfile incorporating Datadog integration:
# Stage 1: Build the application
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
# Copy the project file and restore dependencies
COPY *.csproj ./
RUN dotnet restore
# Copy the remaining source code
COPY . .
# Build the application
RUN dotnet publish -c Release -o out
# Stage 2: Create a runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
# Copy the build output from stage 1
COPY --from=build /app/out ./
# Datadog specific
RUN mkdir -p /datadog/tracer
RUN mkdir -p /home/LogFiles/dotnet
ADD https://github.com/DataDog/dd-trace-dotnet/releases/download/v2.49.0/datadog-dotnet-apm-2.49.0.tar.gz /datadog/tracer
RUN cd /datadog/tracer && tar -zxf datadog-dotnet-apm-2.49.0.tar.gz
# Set the entry point for the application
ENTRYPOINT ["dotnet", "<your dotnet app>.dll"]
You're now ready to build the image and push it to your preferred container registry, be it Azure Container Registry, Docker Hub, or a private registry.
Create a new Linux Web App from the portal and choose the options for Container and Linux.
On the Container tab, make sure that Sidecar support is Enabled.
Specify the details of your application image.
Note: Typically, .NET uses port 8080 but you can change it in your project.
If you don’t have a Datadog account, you can create an instance of Datadog on the Azure portal by following this QuickStart.
Create Datadog - Azure Native ISV Services | Microsoft Learn
Alternatively, you can also create a service account on Datadog by following the steps in this tutorial.
Service Accounts (datadoghq.com)
Datadog offers a 14 days Free Trial if you would like to try out the service.
You need to set the following AppSettings.
Alternatively, you can create your API Key by following the steps here API and Application Keys (datadoghq.com).
We would encourage you to add sensitive information like API keys to Azure Key vault Use Key Vault references - Azure App Service | Microsoft Learn.
To know more about these Datadog settings, you can refer to the documentation.
Go to the Deployment Center for your application and add a sidecar container
Image Source: Docker Hub and other registries
Image type: Public
Registry server URL: svlsddagent.azurecr.io
Image and tag: serverless-sidecar:latest
Port: 8126
Disclaimer: Datadog Image Usage
It's important to note that the Datadog image used here is sourced directly from Datadog and is provided 'as-is.' Microsoft does not own or maintain this image. Therefore, its usage is subject to the terms of use outlined by Datadog, which can be found here.
You are all set! You can now see your Observability data flow to Datadog backend. Take a look at the Azure serverless page for a complete view of your App Services.
The Service Catalog gives you an overview of each service, such as the number of requests, latency, and more.
You can see your application logs by going to Logs -> Explorer
Your application traces will be under APM->Traces->Explorer
To learn more about Datadog dashboards, you can refer to the documentation.
In this guide, we've explored the seamless integration of Datadog with your .NET custom container application hosted on Linux App Service. By leveraging the Sidecar Pattern and Datadog's powerful observability platform, you can now unlock actionable insights and enhance the monitoring capabilities of your applications.
It's important to note that Datadog, as an Azure Native ISV Services partner, offers robust support for Azure services and environments. Our collaboration with Datadog is aimed at providing you with even closer and simplified integration experiences in the future.
Stay tuned for upcoming guides where we'll delve into integrating Datadog with code-based web applications and other language stacks like NodeJS and Python.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.