Azure App Services Tracing for .NET

You can set up tracing for Azure App Services that are written in .NET language that runs on both Windows and Linux platforms by configuring the workloads for each platform.

Supported platforms

Instana supports monitoring of .NET Azure App Services in the following platforms:

- Windows 
- Linux

Enabling tracing

You can enable tracing by instrumenting the .Net applications. To enable instrumentation, set up workloads in Windows or Linux platforms.

Setting up Windows workloads for tracing .NET Framework, .NET Core, and .NET

To enable instrumentation for .Net Framework, .Net Core, and .Net on Windows variants of App Services, you must have an Instana agent running in the environment where you intend to monitor the App Services.

For more information about how to configure the Instana agent for Azure monitoring, see Monitoring and Instrumenting Microsoft Azure.

To set up Windows workloads, complete the following steps:

  1. In the Microsoft Azure portal, search for the .Net App Service that you want to instrument.

  2. Open the .Net App Service in the Azure Portal.

  3. From the navigation menu, click Extensions. In the Extensions page, you can add a new extension, check the extensions that are installed, and update or remove an extension.

    Extensions menu

  4. Install the Instana Tracing App Service extension. After installation, you must configure the extension before you use it.

  5. Go to the Extensions page.

  6. Click the URL icon for the Instana Tracing App Service extension in the table of installed extensions. The Instana Tracing for AppServices window is displayed where you can configure the Instana extension.

    Instrumentation configuration

  7. Complete the following configurations:

    1. To enable the Instana Tracing feature, set Enable Tracing to On.

    2. To select 32 bit for your App Services application set Enable 64 bit to Off. To select 64 bit for your App Services application set Enable 64 bit to On. For more information, see Bitness of the application.

    3. In the Agent Key field, enter the license key of your Instana host agent.

    4. In the Endpoint URL field, enter the endpoint URL for serverless monitoring.

      For self-hosted, enter the endpoint in the https://<IP address of the Instana backend>/serverless format and set the INSTANA_DISABLE_CA_CHECK parameter to true or 1.

    5. In the Log-Level field, enter the log level that you want to use. The values that you can enter are NONE, DEBUG, INFO, WARN, and ERROR.

      The log information is generated in the root folder of the App Service application.

  8. After you enter all the information, click Update Config. The information is saved within the context of the App Service.

  9. From the Dashboard of the App Service, restart the App Service. When you run your application, an Instana rewriter is attached to the application, and Instana starts collecting traces.

To view the traces in the Instana UI, complete the following steps:

  1. In the Instana UI, open the dashboard of your App Service entity.

  2. Click Upstream / Downstream. Traces that are collected for this entity are displayed.

    Traces

Setting up Linux workloads for .NET Core and .NET

To enable instrumentation for .Net Core and .Net applications that run on Linux-based App Services, you must have an Instana agent running in the environment where you intend to monitor the App Service. For more information about how to configure the Instana agent to monitor Azure, see Monitoring and Instrumenting Microsoft Azure.

Automatic instrumentation is not available on Linux.

To capture traces, complete the following steps:

  1. Add the tracing NuGet package into your project: Instana.Tracing.Core.Rewriter.Linux

  2. After you add the tracing NuGet package, redeploy your application to the Azure App Service.

  3. After the application is redeployed, Instana tracing becomes a part of your application. To activate tracing, configure the CLR engine as follows:

    1. Go to the Configuration section on your Azure App Service dashboard.

    2. Add the following environment variables:

      CORECLR_ENABLE_PROFILING = 1
      CORECLR_PROFILER = {cf0d821e-299b-5307-a3d8-b283c03916dd}
      CORECLR_PROFILER_PATH = /home/site/wwwroot/instana_tracing/CoreProfiler.so
      DOTNET_STARTUP_HOOKS = /home/site/wwwroot/Instana.Tracing.Core.dll
      INSTANA_AGENT_KEY = the license key of your Instana host agent
      INSTANA_ENDPOINT_URL = one of the following [endpoint URL for serverless monitoring](../../../setup_and_manage/endpoints_and_keys.html#endpoints-for-serverless-monitoring)
      
  4. Restart your application. To make sure that your changes are active, follow these steps:

    1. Stop the application.
    2. Wait for 1-2 minutes to clear any cached states.
    3. Start the application again.

    You can now view traces in the Instana UI.

Troubleshooting

The following section outlines the troubleshooting steps to resolve common problems.

Bitness of the application

When you configure the Instana instrumentation by using the installed extension in Azure, you can see an Enable 64 bit checkbox. Depending on the bit version of your application, you must attach the appropriate rewriter.

By default, when you deploy the application through Visual Studio to Azure App Service, the application is installed in 32-bit mode. The bit version settings can be changed in the configuration of the App Service by going to Configuration > General Settings:

App Service Platform configuration

If you are using a 64-bit mode, select 64 Bit in the Instana Tracing App Service Extension configuration. Otherwise, you cannot attach and collect traces.

Tracing does not work

If tracing does not work, complete the following steps:

  1. Check that the bit version is correctly configured both in the App Service configuration and in the Instana Tracing App Service extension configuration.

  2. Make sure that the agent Key and endpoint URL are set correctly in the Instana Tracing for App Services page. For more information, see Endpoint URL for serverless monitoring.

  3. Check for errors in the Event log by clicking Diagnose and solve problems > Application Event Logs.

    Event logs

  4. Open the Kudu Process Explorer by clicking Advanced Tools from the navigation menu. Check whether the w3wp process is attached with the Instana.Profiler_x64.dll module.

    Open Kudu

    Process Explorer

  5. Get the Instana debugging logs from the Kudu tool. In the Kudu Tool, go to Debug Console, and then go to the C:\home\site\wwwroot> folder. You can find two types of log files in the folder:

  • CLR debug logs: 1.log_YYYY-MM-DD-HH_MM_SS
  • Instrumentation logs: YYYY-MM-DD_HH_MM_SSPID