Agent does not load with ApplicationInsights running in Azure App Services
Overview of the Issue
If ApplicationInsights is enabled on a .NET Application running in an Azure App Services environment, the vFunction Environment Variables will be overwritten. This issue can be seen when:
- The vFunction Agent is installed on an Azure App Services App
- The vFunction Environment Variables have been added to the Application Settings
- No vFunction logging is written to C:\home\vfunction\logs\instances\default-dotnet\vfagent.net.log
- No logging is written to C:\Temp\vfagent.net.log
- The correct agent.application_name is added to the C:\home\vfunction\config\installation\instances\default-dotnet\installation.yaml
- The correct agent.architecture is added to the C:\home\vfunction\config\installation\instances\default-dotnet\installation.yaml
- The Kudu Debug Console’s Process Explorer for the w3wp.exe process’s Environment Variables shows that the COR_PROFILER_PATH_32, COR_PROFILER_PATH_64, CORECLR_PROFILER_PATH_32, or CORECLR_PROFILER_PATH_64 unexpectedly does not refer to the vfagent.dll or vfagent.x86.dll. Instead one of these Environment Variables refers to an InstrumentationEngine or ApplicationInsights DLL
Steps to Resolve the Issue
This issue can be resolved by taking the following steps:
- Open the Azure App Services Application’s Settings > Environment Variables
- On the Menu Bar, click the Advanced Edit button
- Remove the entire JSON entries for the Environment Variables (a) ApplicationInsights_InstrumentationKey and (b) InstrumentationEngine_EXTENSION_VERSION
- Save and Apply the changes so that the Environment Variables are removed and the Application restarts
- Confirm that the C:\home\vfunction\logs\instances\default-dotnet\vfagent.net.log is written as expected and that the Agent is visible in the vFunction Server UI’s Learning > Select Controllers page