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 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

  1. Go to the Azure portal.
  2. Search for Container Apps and select Container Apps.
  3. Create a resource group if one does not exist:
    1. On the Container Apps page, click Create.
    2. Select Resource Group and click Create new.
    3. Enter a name (for example, myResourceGroup), select a Region, and then click OK.
  4. Create a Container Apps environment:
    1. On the Basics tab, select Subscription and the previously created resource group.
    2. Enter a Container App Name (for example, myDotnetApp).
    3. Select Region, and then click Next: Environment.
    4. Under Environment, click Create new and enter an Environment Name (for example, myContainerAppEnv).
    5. Choose a Region and Log Analytics workspace.
    6. Click Review + Create, and then Create.
  5. Deploy a .NET Core Application:
    1. In the Azure portal, go to Azure Container Registry (ACR) and create a new registry if not already created.
    2. 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.
    3. In Azure Container Apps, click Create Container App.
    4. Select the created resource group and Container App environment.
    5. Under Container Settings, select Docker Hub or Azure Container Registry and specify the image name.
    6. Set the Container Port (for example, 80).
    7. Enable Ingress and select External access.
    8. Click Review + Create, and then click Create.

Step 4: Configure Instana serverless agent settings

  1. Log in to your Instana account (for example: https://sesandbox-instana.instana.io).
  2. Retrieve the Instana endpoint URL and Instana agent key:
    1. From the navigation menu in the Instana UI, select More > Agents > Install agents.
    2. Select Azure container apps.
    3. Copy the Instana Endpoint URL and Agent Key.
  3. Set environment variables in the Azure portal:
    1. Go to Azure Container Apps in the Azure Portal.
    2. Select your container app.
    3. Click Settings > Environment variables.
    4. 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_key
      Note: INSTANA_SERVICE_NAME is the name of service that you want to monitor, for example dotnetcore-webapp.
    5. Save the changes.

Step 5: Verify the setup

From the navigation menu in the Instana UI, go to Applications > Services to view the collected metrics and traces.