Instrument Azure App Service - Linux Containers with Sidecar Pattern
このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、
お気軽にご連絡ください。
Overview
This instrumentation method uses Azure’s Sidecar pattern to monitor containerized Linux Azure App Service workloads.
Prerequisites
Instrument your application
- Integrate the Datadog tracer into your containerized application
- Create your Linux Web App
- Add Datadog environment variables as application settings
- Add the Datadog sidecar
Integrate the Datadog tracer
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.
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
- In the Azure Portal, go to App Services and select Create.
- On the Basics tab, provide the required details.
- For Publish, select Container.
- For Operating System, select Linux.
Then, select Next: Container >.
- 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.
- Select Review + create, then select Create.
Add Datadog environment variables
In the Azure portal, select your app.
In the left menu, select Configuration > Application settings.
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
- In the Azure portal, select your app.
- In the left menu, select Deployment Center.
- 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
- 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.