Instrument Azure App Service - Linux Containers with Sidecar Pattern

이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.
To instrument your Azure App Service containers with serverless-init, see Instrument Azure App Service - Linux Container with serverless-init.

Overview

This instrumentation method uses Azure’s Sidecar pattern to monitor containerized Linux Azure App Service workloads.

Prerequisites

Instrument your application

  1. Integrate the Datadog tracer into your containerized application
  2. Create your Linux Web App
  3. Add Datadog environment variables as application settings
  4. Add the Datadog sidecar

Integrate the Datadog tracer

  1. Add the following lines to the Dockerfile for your main application:

    RUN mkdir -p /datadog/tracer
    RUN mkdir -p /home/LogFiles/dotnet
    
    ADD https://github.com/DataDog/dd-trace-dotnet/releases/download/v2.51.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 installs and configures the Datadog tracer within your application container.

  2. Build the image and push it to your preferred container registry.

Full example Dockerfile

# 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"]

Create your Linux Web App

  1. In the Azure Portal, go to App Services and select Create.
  2. On the Basics tab, provide the required details.
    • For Publish, select Container.
    • For Operating System, select Linux. Then, select Next: Container >.
  3. On the Container tab, provide the required details.
    • For Sidecar support, select Enabled.
    • For Image Source, select your chosen registry.
    • Specify the Registry, Image, Tag, and Port for your container image.
  4. Select Review + create, then select Create.

Add Datadog environment variables

  1. In the Azure portal, select your app.

  2. In the left menu, select Configuration > Application settings.

  3. Add the following environment variables as application settings.

    DD_API_KEY (Required)
    Your Datadog API key.
    Alternatively, you can source your API key (and other sensitive information) from Azure Key Vault. See Use Key Vault references as app settings in Azure App Service.
    DD_SITE

    Corresponds to your Datadog site. Defaults to datadoghq.com.
    DD_SERVICE
    Supply a service name to be displayed in your Datadog Service Catalog. See Unified Service Tagging.
    DD_ENV
    A name for your environment, such as staging or prod. See Unified Service Tagging.
    DD_SERVERLESS_LOG_PATH
    /home/Logfile/*.log
    Corresponds to the path where you write your application logs. If you have changed this location, specify your custom location in this setting.
    DD_DOTNET_TRACER_HOME (Required)
    /datadog/tracer
    DD_TRACE_LOG_DIRECTORY (Required)
    /home/Logfiles/dotnet
    CORECLR_ENABLE_PROFILING (Required)
    1
    CORECLR_PROFILER (Required)
    {846F5F1C-F9AE-4B07-969E-05C26BC060D8}
    CORECLR_PROFILER_PATH (Required)
    /datadog/tracer/Datadog.Trace.ClrProfiler.Native.so

Add the Datadog sidecar

  1. In the Azure portal, select your app.
  2. In the left menu, select Deployment Center.
  3. Select Add. Under Add container, provide the following details:
    • Name: datadog
    • Image source: Docker Hub or another registry
    • Image type: Public
    • Registry server URL: sitecontainerssampleacr.azurecr.io
    • Image and tag: datadog-dotnet:2.0
    • Port: 8126
  4. Select Apply.

Next steps

After you finish instrumenting your application, go to the Serverless > Azure page in Datadog to see your observability data. Your application logs are available in Log Explorer, and your traces are available in Trace Explorer.

PREVIEWING: brett0000FF/node-compatibility