Install - vFunction Monolithic .NET Framework and OpenTelemetry Agents on Windows x64 running on Azure App Services



Overview

Microsoft .NET Applications have a limitation that only one Agent can be hooked into the Application at a time. To work around this limitation, the Datadog Multiplexer can be used as the Base Agent. This Datadog Multiplexer includes a configuration file that allows you to define two additional .NET Agents to run simultaneously on the Application without conflict.

At a high level, you’ll need to:

  1. Download and install the two .NET Agents you want to run simultaneously
  2. Download the Datadog Multiplexer
  3. Configure the Datadog Multiplexer for the two .NET Agents you want to run simultaneously
  4. Add the vendor-specific environment variables for the two .NET Agents you want to run
  5. Add the generic .NET Agent environment variables to run the Datadog Multiplexer
  6. Restart the Application

.NET Compatibility

vFunction supports C# .NET Core version 3.x and .NET 6.x, 7.x and 8.x applications. vFunction also supports C# .NET Framework version 4.x applications.


Installation Steps


Gather and Prepare the Required Agents
  1. Download the vFunction .NET Linux Agent ZIP, e.g. vfunction-controller-sudo-less-installation.v4.0.1585.tgz
  2. Download the OpenTelemetry .NET AutoInstrumentation Agent ZIP
  3. Download the Multiplexer Agent DLL
  4. Download or create the Multiplexer’s Config File
#Profiler
PROFILER;{918728DD-259F-4A6A-AC2B-B85E1B658318};win-x64;C:\\home\\otel\\win-x64\\OpenTelemetry.AutoInstrumentation.Native.dll

#Tracer
TRACER;{cd7d4b53-96c8-4552-9c11-6e41df8eab8a};win-x64;C:\home\vfunction\agent\vfagent.net.dll

#Custom
  1. Rename the loader-vf-otel-azure-app-services.conf to loader.conf

Install the OpenTelemetry Collector

As a best practice, an OpenTelemetry Collector can be used to collect OpenTelemetry information from the Application and send that information to a number of third-party OpenTelemetry vendors, such as Azure Monitor in lieu of ApplicationInsights. The OpenTelemetry Collector requires a separate installation. A number of options are available for this installation, e.g. via a Docker Container, as a Kubernetes Pod, or on a Linux or Windows Host.

See the OpenTelemetry Collector installation documentation to find the path that best meets your needs.

The OpenTelemetry Collector uses a Configuration file to define where to send the OpenTelemetry information to third-party vendors.


OpenTelemetry Collector Configuration file modified for vFunction Distributed App Analysis

Note that the details below are meant to be added to the default configuration. This is not a full-and-complete example.

  • Find-and-replace $PROTOCOL with http or https depending on how the VF Server was configured
  • Find-and-replace $VFSERVER with the URL for login to your organization’s vFunction Server
  • Find-and-replace $VF_APP_UUID with the one provided by the VF Server UI in the Installation Instructions
exporters:
  otlphttp/vf:
    endpoint: $PROTOCOL://$VFSERVER/api/unauth/otlp
    headers:
      X-VF-APP: $VF_APP_UUID
    # If the VF Server was configured to use HTTP instead of HTTPS, you will need to enable HTTP via the "tls.insecure: true" Key and Value
    # tls:
    #   insecure: true
### Add the Exporter to the pipeline
service:
  pipelines:
    traces:
      receivers: [otlp]
      exporters: [otlphttp/vf]

OpenTelemetry Collector Configuration file modified for Application Insights

A more detailed description of the Azure Monitor Exporter is available in the OpenTelemetry Collector documentation.

Note that the details below are meant to be added to the default configuration. This is not a full-and-complete example.

# Recommended Configuration:
# It is highly recommended to use the connection string which includes the InstrumentationKey and IngestionEndpoint
# This is the preferred method over using 'instrumentation_key' alone.
exporters:
  azuremonitor:
    connection_string: "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://ingestion.azuremonitor.com/"
# Azure Monitor can only handle a limited number of request per minute
# To scale down the number of requests, use probabilistic sampling
# Adjust the percentages until WARNINGS are removed from your Collector's logging
processors:
  probabilistic_sampler:
    sampling_percentage: 50
    mode: "proportional"
  probabilistic_sampler/logs:
    sampling_percentage: 50
    attribute_source: "traceID"
service:
  pipelines:
    traces:
      processors: [ probabilistic_sampler ]
    logs:
      processors: [ probabilistic_sampler/logs ]  

Kudu Console Installation on Azure App Services
  1. Open the App from the Azure Portal
  2. From the left-hand sidebar, open the Development Tools > Advanced Tools > Go to launch the Kudu Console
  3. On the Menu Bar, open the Debug Console > PowerShell editor
  4. Drag-and-drop the vFunction Controller Windows Installation ZIP into C:\home\
  5. Unzip the vFunction Installation ZIP:
### Replace VERSION with the actual vFunction release version
Expand-Archive -Path C:\home\vfunction-controller-windows-installation.vVERSION.zip -DestinationPath C:\home -Force
  1. Drag-and-drop the OpenTelemetry AutoInstrumentation Agent ZIP into C:\home\
  2. Unzip the OpenTelemetry AutoInstrumentation Agent ZIP:
### Replace VERSION with the actual vFunction release version
Expand-Archive -Path C:\home\opentelemetry-dotnet-instrumentation-windows.zip -DestinationPath 'C:\home\otel' -Force
  1. Drag-and-drop the Datadog Multiplexer Agent DLL into C:\home\vfunction\
  2. Drag-and-drop the Datadog Multiplexer’s loader.conf into C:\home\vfunction\
  3. In the Kudu Menu Bar, go to Process Explorer and select the Properties button for the w3wp.exe process. Look for the quote-enclosed string after the flag -ap. Copy-and-paste this value into a text editor for use in a later step. If it exists, avoid the Process that starts as “~1” since this is a Management Process
  4. The full path to the w3wp.exe process dictates whether this is a 32-bit or 64-bit, e.g. C:\Windows\System32 or C:\Windows\SysWOW64. Note whether this is a 32-bit or 64-bit w3wp.exe process for use in a later step
  • x86 = C:\Windows\System32
  • x64 = C:\Windows\SysWOW64
  1. Add the Environment Variables for the vFunction Dynamic Agent and install the Agent
### Replace the $CHANGE_ME values with the Required Configuration Settings. For detailed Settings explanations, see:
### https://kb.vfunction.com/installations/configurable-settings/mono-dynamic-agent/dotnet/windows
powershell -NoProfile -ExecutionPolicy unrestricted -Command "
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_NAME -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_HOST -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_APP_ID -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_ORG_ID -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_CLIENT_ID -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_CLIENT_SECRET -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_INSTANCE_ID -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_TAG -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_AGENT_VERSION -Value 'framework';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_AGENT_APPLICATION_NAME -Value '$CHANGE_ME_FROM_STEP_7';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_AGENT_ARCHITECTURE -Value '$CHANGE_ME_FROM_STEP_8';
C:\home\vfunction\controller-installation\install.ps1 -instance default-dotnet -scriptMode true -runAsServices false"

#### Sample Values
powershell -NoProfile -ExecutionPolicy unrestricted -Command "
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_NAME -Value 'OMS-AppServices';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_HOST -Value 'https://vfunction.mycompany.com';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_APP_ID -Value '111111-1111-1111-111111';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_ORG_ID -Value '111111-1111-1111-111111';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_CLIENT_ID -Value '111111-1111-1111-111111';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_CLIENT_SECRET -Value '111111-1111-1111-111111';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_INSTANCE_ID -Value 'AppService';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_CONTROLLER_TAG -Value 'AppService';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_AGENT_VERSION -Value 'framework';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_AGENT_APPLICATION_NAME -Value 'oms';
New-Item -Path Env:\VF_CONTROLLER_DEFAULT_DOTNET_AGENT_ARCHITECTURE -Value 'x64';
C:\home\vfunction\controller-installation\install.ps1 -instance default-dotnet -scriptMode true -runAsServices false"
  1. Re-open the App from the Azure Portal
  2. From the left-hand sidebar, select Settings > Environment Variables
  3. Add new Environment Variables based on the .NET version
Key Value
COR_ENABLE_PROFILING 1
COR_PROFILER_PATH_64 Datadog.Trace.ClrProfiler.Native.dll
COR_PROFILER {846F5F1C-F9AE-4B07-969E-05C26BC060D8}
VF_AGENT_CONF_LOCATION C:\\home\\vfunction\\config\\agent\\instances\\default-dotnet\\conf.json
COMPlus_TailCallOpt 0
OTEL_EXPORTER_OTLP_ENDPOINT http://URL_FOR_OTEL_COLLECTOR:4318
OTEL_DOTNET_AUTO_INSTALL_DIR C:\\home\\otel
DOTNET_ADDITIONAL_DEPS C:\\home\\otel\\AdditionalDeps
DOTNET_SHARED_STORE C:\\home\\otel\\store
DOTNET_STARTUP_HOOKS C:\\home\\otel\\net\\OpenTelemetry.AutoInstrumentation.StartupHook.dll
OTEL_DOTNET_AUTO_HOME C:\\home\\otel
  1. Save and apply the Environment Variable changes. This will automatically restart the Azure App Service’s instance
  2. In the vFunction Server UI, confirm that the Agent is Status: Up and Start Learning
  3. If any issues arise:
  1. Confirm OpenTelemetry Exporters are working as expected as well

Using OpenTelemetry and Azure Monitor instead of Application Insights

If the starting point for your organization is an application that uses Application Insights for performance monitoring, note that Microsoft recommends to move to the OpenTelemetry Agent and Azure Monitor instead of the Application Insights .NET SDK.

Instead of using the Application Insights .NET SDK, vFunction recommends to follow the Microsoft Guidance. The documentation above includes explicit steps for Azure Monitor.