1

I am trying to setup my Azure Web App to include the use of a third party software, which seems to require access to PerformanceCounters. Locally this works fine, but when I run it in Azure I get the following error:

[UnauthorizedAccessException: Access to the registry key 'Global' is denied.]
Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str) +5230217
Microsoft.Win32.RegistryKey.InternalGetValue(String name, Object defaultValue, Boolean doNotExpand, Boolean checkSecurity) +11769029
Microsoft.Win32.RegistryKey.GetValue(String name) +40
System.Diagnostics.PerformanceMonitor.GetData(String item) +102
System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String item) +186
System.Diagnostics.PerformanceCounterLib.get_CategoryTable() +105
System.Diagnostics.PerformanceCounterLib.GetCategorySample(String category) +17
System.Diagnostics.PerformanceCounterLib.GetCategorySample(String machine, String category) +61
System.Diagnostics.PerformanceCounterCategory.GetCounterInstances(String categoryName, String machineName) +70
System.Diagnostics.PerformanceCounterCategory.GetInstanceNames() +25

According to this answer, I should configure IIS to allow access to the app pool/user, but I don't think that is possible for a Azure Web App. Is there a way to get performance counters working in my situation?

Community
  • 1
  • 1
nforss
  • 1,098
  • 1
  • 14
  • 30
  • Try adding the cache client application account to the following groups: Performance Monitor Users group and Performance Log Users group, and Restart the cache client application. – Thennarasan Jul 25 '16 at 08:21
  • Try wbemtest "Win+R" and type wbemtest and check for an error. – Amit Shakya Jul 28 '16 at 17:10

1 Answers1

1

On Windows, Performance Counters are accessible through WMI:
https://msdn.microsoft.com/en-us/library/aa392397(v=vs.85).aspx

WMI is restricted in the App Service sandbox.
From https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#access-to-out-of-process-com-servers:

Access to out-of-process COM servers

Windows Servers have a bunch of COM servers configured and available for consumption by default; however the sandbox prevents access to all out-of-proc COM servers. For example, a sandboxed application cannot call into WMI, or into MSIServer.

From Kudu:

PS D:\home> Get-Counter -Counter "\processor(_total)\% processor time"
Get-Counter : The specified object was not found on the computer.


PS D:\home> Get-WmiObject -Class WIN32_OperatingSystem
Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 
(E_ACCESSDENIED))

If you absolutely have to use the 3rd party software, look at Azure Cloud Services (with a Web Role). You have full control over the OS there while still being PaaS.

Community
  • 1
  • 1
evilSnobu
  • 19,691
  • 5
  • 31
  • 62
  • This is what I was afraid of. I previously ran the software using a Worker Role in a Cloud Service, but for testing it was overkill, so I wanted something less costly. Seems I'm out of luck. – nforss Jul 29 '16 at 12:26