Setting up .NET tracing on Azure Container Apps
You can enable tracing for .NET Core applications that run on Azure Container Apps by configuring the Instana tracing SDK in your application and connecting it to Instana by using the Instana serverless agent.
For an overview of how Instana monitors .NET applications, see How .NET monitoring works.
Before you begin
Before you enable tracing for a .NET Core application on Azure Container Apps, ensure that the following prerequisites are met:
- You have an active Instana account with access to the Instana UI.
- You have an Azure subscription with Azure Container Apps available.
- Review support information to ensure compatibility with your .NET version and runtime environment.
Enabling .NET tracing
To enable tracing in your .NET Core application hosted on Azure Container App Service, complete the following steps:
Step 1: Add the Instana tracing packages
Modify your application to include the Instana tracing SDK by installing the following packages:
These packages add tracing logic and enable runtime instrumentation.
Step 2: Update the Dockerfile
Set .NET Core tracing environment variables in your Dockerfile:
# set .NET Core tracing environment variables
ENV CORECLR_ENABLE_PROFILING="1"
ENV CORECLR_PROFILER="{cf0d821e-299b-5307-a3d8-b283c03916dd}"
ENV CORECLR_PROFILER_PATH="/app/instana_tracing/CoreProfiler.so"
ENV DOTNET_STARTUP_HOOKS="/app/Instana.Tracing.Core.dll"
Step 3: Create and deploy an Azure Container App
- Go to the Azure portal.
- Search for Container Apps and select Container Apps.
- Create a resource group if one does not exist:
- On the Container Apps page, click Create.
- Select Resource Group and click Create new.
- Enter a name (for example,
myResourceGroup), select a Region, and then click OK.
- Create a Container Apps environment:
- On the Basics tab, select Subscription and the previously created resource group.
- Enter a Container App Name (for example,
myDotnetApp). - Select Region, and then click Next: Environment.
- Under Environment, click Create new and enter an Environment Name (for example,
myContainerAppEnv). - Choose a Region and Log Analytics workspace.
- Click Review + Create, and then Create.
- Deploy a .NET Core Application:
- In the Azure portal, go to Azure Container Registry (ACR) and create a new registry if not already created.
- Push your Docker image to ACR (for example,
mycontainerregistry.azurecr.io/my-dotnet-app:v1). Make sure your .NET Core application is containerized by using Docker. - In Azure Container Apps, click Create Container App.
- Select the created resource group and Container App environment.
- Under Container Settings, select Docker Hub or Azure Container Registry and specify the image name.
- Set the Container Port (for example,
80). - Enable Ingress and select External access.
- Click Review + Create, and then click Create.
Step 4: Configure Instana serverless agent settings
- Log in to your Instana account (for example:
https://sesandbox-instana.instana.io). - Retrieve the Instana endpoint URL and Instana agent key:
- From the navigation menu in the Instana UI, select .
- Select Azure container apps.
- Copy the Instana Endpoint URL and Agent Key.
- Set environment variables in the Azure portal:
- Go to Azure Container Apps in the Azure Portal.
- Select your container app.
- Click .
- Add the following environment variables:
CORECLR_ENABLE_PROFILING = 1 CORECLR_PROFILER = {cf0d821e-299b-5307-a3d8-b283c03916dd} CORECLR_PROFILER_PATH = /app/instana_tracing/CoreProfiler.so DOTNET_STARTUP_HOOKS = /app/Instana.Tracing.Core.dll INSTANA_ENDPOINT_URL = instana_endpoint_url AZURE_SUBSCRIPTION_ID = your_azure_subscription_id AZURE_RESOURCE_GROUP = your_azure_resource_group INSTANA_SERVICE_NAME = your_service_name INSTANA_AGENT_KEY = your_instana_agent_keyNote:INSTANA_SERVICE_NAMEis the name of service that you want to monitor, for exampledotnetcore-webapp. - Save the changes.
Step 5: Verify the setup
From the navigation menu in the Instana UI, go to to view the collected metrics and traces.