In this blog we continue to dive into the world of observability with Azure App Service. If you've been following our recent updates, you'll know that we announced the Public Preview for the Sidecar Pattern for Linux App Service. Building upon this architectural pattern, we're going to demonstrate how you can leverage it to integrate Dynatrace, an Azure Native ISV Services partner, with your .NET custom container application. In this blog, we'll guide you through the process of harnessing Dynatrace's powerful monitoring capabilities, allowing you to gain invaluable insights into your application's metrics and traces.
Setting up your .NET application
To get started, you'll need to containerize your .NET application. This tutorial walks you through the process step by step.
This is what a sample Dockerfile for a .Net 8 application
# 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 ./
# Set the entry point for the application
ENTRYPOINT ["dotnet", "<your 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 your Linux Web App
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.
Setup your Dynatrace account
If you don’t have a Dynatrace account, you can create an instance of Dynatrace on the Azure portal by following this Marketplace link.
You can choose the Free Trial plan to get a 30 days subscription.
AppSettings for Dynatrace Integration
You need to set the following AppSettings.
You can get more details about the Dynatrace related settings here.
- DT_TENANT – The environment ID
- DT_TENANTTOKEN – Same as DT_API_TOKEN. This is the PaaS token for your environment.
- DT_CONNECTIONPOINT
- DT_HOME - /home/dynatrace
- LD_PRELOAD - /home/dynatrace/oneagent/agent/lib64/liboneagentproc.so
- DT_LOGSTREAM - stdout
- DT_LOGLEVELCON – INFO
We would encourage you to add sensitive information like DT_TENANTTOKEN to Azure Key vault Use Key Vault references - Azure App Service | Microsoft Learn.
Add the Dynatrace Sidecar
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: mcr.microsoft.com
Image and tag: appsvc/docs/sidecars/sample-experiment:dynatrace-dotnet
Port: <any port other than your main container port>
Once you have added the sidecar, you would need to restart your website to see the data start flowing to the Dynatrace backend.
Please note that this is an experimental container image for Dynatrace. We will be updating this blog with a new image soon.
Disclaimer: Dynatrace Image Usage
It's important to note that the Dynatrace image used here is sourced directly from Dynatrace 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 Dynatrace.
Visualizing your Observability data in Dynatrace
You are all set! You can now see your Observability data flow to Dynatrace backend.
The Hosts tab gives you metrics about the VM which is hosting the application.
Dynatrace also has a Services view which lets you look at your application specific information like Response Time, Failed Requests and application traces.
You can learn more about Dynatrace’s Observability capabilities by going through the documentation.
Observe and explore - Dynatrace Docs
Next Steps
As you've seen, the Sidecar Pattern for Linux App Service opens a world of possibilities for integrating powerful tools like Dynatrace into your Linux App Service-hosted applications. With Dynatrace being an Azure Native ISV Services partner, this integration marks just the beginning of a journey towards a closer and more simplified experience for Azure users.
This is just the start. We're committed to providing even more guidance and resources to help you seamlessly integrate Dynatrace with your code-based Linux web applications and other language stacks. Stay tuned for upcoming updates and tutorials as we continue to empower you to make the most of your Azure environment.
In the meantime, don't hesitate to explore further, experiment with different configurations, and leverage the full potential of observability with Dynatrace and Azure App Service.