How to use Environment Variables to hook into multiple .NET Applications Simultaneously
Overview
In Server version 3.7 and later, a new Environment Variable was introduced to hook into multiple .NET processes simultaneously. The VF_MULTI_AGENT_CONF_LOCATION allows Environment Variables to be used to hook the vFunction Agent into multiple processes while maintaining the ratio of one Agent per .NET process.
Steps to implement VF_MULTI_AGENT_CONF_LOCATION Environment Variable
Take the following steps to implement the VF_MULTI_AGENT_CONF_LOCATION Environment Variable:
- Log into the Windows Server where the .NET Applications run
- Create one vFunction instance for each .NET process to be monitored
- Open PowerShell as an Administrator
- Run the following command to create and install one instance, changing the $ALL_UPPER values
powershell -NoProfile -ExecutionPolicy unrestricted -Command "
$BASE_DIR\controller-installation\create-instance.ps1 -instance $NAME -agentMode true -type dotnet;New-Item -Path Env:\VF_CONTROLLER_$NAME_CONTROLLER_NAME -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_$NAME_CONTROLLER_HOST -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_$NAME_CONTROLLER_APP_ID -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_$NAME_CONTROLLER_ORG_ID -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_$NAME_CONTROLLER_CLIENT_ID -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_$NAME_CONTROLLER_CLIENT_SECRET -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_$NAME_CONTROLLER_INSTANCE_ID -Value '$CHANGE_ME';
New-Item -Path Env:\VF_CONTROLLER_$NAME_CONTROLLER_TAG -Value '$CHANGE_ME';
$BASE_DIR\controller-installation\install.ps1 -instance $NAME -scriptMode true"
- Repeat Step #2 for each .NET process that needs a vFunction instance
- Create a JSON file with references to each .NET process
- Find the Command Line entry for each running .NET process
- Create a vf_conf.json following the example format below for two .NET processes
[
{
"log_conf": {
"level": "debug",
"target_file": "$BASE_DIR\\vfunction\\log\\instances\\$NAME_1\\vfagent.net.log"
},
"instance": "$NAME_1",
"shared_folder": "$BASE_DIR\\vfunction\\agent\\instances\\$NAME_1\\temp",
"cmd": "$CMD_LINE_FOR_PROCESS_1"
},
{
"log_conf": {
"level": "debug",
"target_file": "$BASE_DIR\\vfunction\\log\\instances\\$NAME_2\\vfagent.net.log"
},
"instance": "$NAME_2",
"shared_folder": "$BASE_DIR\\vfunction\\agent\\instances\\$NAME_2\\temp",
"cmd": "$CMD_LINE_FOR_PROCESS_2"
}
]
- Save the file to a location on the Windows Server, such as in the $BASE_DIR being used for the vFunction installation
- Add the System Environment Variables for the vFunction Agent. Note the distinct variable names depending on whether the process is a .NET Framework or .NET 3 /6 / 7 / 8 process. If both types of .NET Applications are running, create all of the Environment Variables
- Log onto the Windows Server
- Search for, Edit the System Environment Variables
- In the System Properties dialog box, click Environment Variables
- Click New below the System Variable list
- Create Variables for each of the fields below from the appropriate column
VF_MULTI_AGENT_CONF_LOCATION | VF_MULTI_AGENT_CONF_LOCATION | $BASE_DIR\vf_conf.json |
COR_ENABLE_PROFILING | CORECLR_ENABLE_PROFILING | 1 |
COR_PROFILER | CORECLR_PROFILER | {cd7d4b53-96c8-4552-9c11-6e41df8eab8a} |
COR_PROFILER_PATH_64 | CORECLR_PROFILER_PATH_64 | $BASE_DIR\agent\vfagent.net.dll |
COR_PROFILER_PATH_32 | CORECLR_PROFILER_PATH_32 | $BASE_DIR\agent\vfagent.net.x86.dll |
COMPlus_TailCallOpt | DOTNET_TailCallOpt | 0 |
- Restart each .NET process