Azure应用服务:使用PerformanceCounters [英] Azure App Service: using PerformanceCounters

查看:120
本文介绍了Azure应用服务:使用PerformanceCounters的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Azure Web App设置为包括使用第三方软件,该软件似乎需要访问PerformanceCounters.在本地这可以正常工作,但是当我在Azure中运行它时,出现以下错误:

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

根据此答案,我应该配置IIS以允许访问应用程序池/用户,但是我认为Azure Web App不可能做到这一点.有没有一种方法可以使性能计数器在我的情况下正常工作?

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?

推荐答案

在Windows上,可以通过WMI访问性能计数器:
https://msdn.microsoft.com/en -us/library/aa392397(v = vs.85).aspx

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

WMI在App Service沙箱中受到限制.
来自 https ://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#access-to-out-of-process-com-servers :

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:

访问进程外COM服务器

Access to out-of-process COM servers

Windows Server具有配置的一堆COM服务器,默认情况下可供使用;但是,沙箱会阻止访问所有进程外COM服务器. 例如,沙盒应用程序无法调用WMI或MSIServer.

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.

来自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))

如果绝对必须使用第三方软件,请查看Azure云服务(具有Web角色).在仍然使用PaaS的情况下,您可以完全控制该操作系统.

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.

这篇关于Azure应用服务:使用PerformanceCounters的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆