Performance counter error occurs during startup of Commerce Engine instances/roles in Azure


Description

The following error occurs during startup of Commerce Engine instances/roles that are deployed in Azure Web Apps:

ERROR PerformanceCounterCommand Unuthorized Access Exception: Information=In order to use performance counters, proper permissions are required. Please ensure that the AppPool identity has been added to the Performance Monitor Users group..Error: Message=Access to the registry key 'Global' is denied.|Trace=   at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
   at Microsoft.Win32.RegistryKey.InternalGetValue(String name, Object defaultValue, Boolean doNotExpand, Boolean checkSecurity)
   at Microsoft.Win32.RegistryKey.GetValue(String name)
   at System.Diagnostics.PerformanceMonitor.GetData(String item)
   at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String item)
   at System.Diagnostics.PerformanceCounterLib.get_CategoryTable()
   at System.Diagnostics.PerformanceCounterLib.CategoryExists(String category)
   at System.Diagnostics.PerformanceCounterLib.CategoryExists(String machine, String category)
   at System.Diagnostics.PerformanceCounterCategory.Exists(String categoryName, String machineName)
   at Sitecore.Commerce.Core.Commands.PerformanceCounterCommand.Increment(String categoryName, String counterName, String instanceName, CommerceContext commerceContext)
System.UnauthorizedAccessException: Access to the registry key 'Global' is denied.
   at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
   at Microsoft.Win32.RegistryKey.InternalGetValue(String name, Object defaultValue, Boolean doNotExpand, Boolean checkSecurity)
   at Microsoft.Win32.RegistryKey.GetValue(String name)
   at System.Diagnostics.PerformanceMonitor.GetData(String item)
   at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String item)
   at System.Diagnostics.PerformanceCounterLib.get_CategoryTable()
   at System.Diagnostics.PerformanceCounterLib.CategoryExists(String category)
   at System.Diagnostics.PerformanceCounterLib.CategoryExists(String machine, String category)
   at System.Diagnostics.PerformanceCounterCategory.Exists(String categoryName, String machineName)
   at Sitecore.Commerce.Core.Commands.PerformanceCounterCommand.Increment(String categoryName, String counterName, String instanceName, CommerceContext commerceContext)

Solution

This error happens only once during startup (later on the command will be disabled anyway). The error should not interrupt any workflow of a Commerce Engine instance. Therefore the error can be ignored.

The issue is expected to be fixed in a future update.