When configuring Atatus environment variables for IIS Application Pools via AppCmd.exe, you may encounter the following error:

Cause

This error occurs when the environment variables have already been added to the application pool. IIS does not allow duplicate entries in the environmentVariables collection. Running the configuration script multiple times without removing existing entries will trigger this error.

Solution

Use the following script which removes only the Atatus-managed environment variables listed in the script and re-adds them with updated values. Other environment variables in the application pool are not affected. This makes the script safe to run multiple times without errors.
The above script uses CORECLR_* variables for .NET Core applications. For .NET Framework applications, replace CORECLR_ENABLE_PROFILING, CORECLR_PROFILER, and CORECLR_PROFILER_PATH with COR_ENABLE_PROFILING, COR_PROFILER, and COR_PROFILER_PATH respectively.