gpt4 book ai didi

Azure应用服务: using PerformanceCounters

转载 作者:行者123 更新时间:2023-12-05 04:13:07 25 4
gpt4 key购买 nike

我正在尝试设置我的 Azure Web 应用程序以包含第三方软件的使用,这似乎需要访问 PerformanceCounters。在本地,这工作正常,但是当我在 Azure 中运行它时,出现以下错误:

[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

根据this answer ,我应该配置 IIS 以允许访问应用程序池/用户,但我认为这对于 Azure Web 应用程序来说是不可能的。有没有办法让性能计数器在我的情况下工作?

最佳答案

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

WMI 在应用服务沙箱中受到限制。
来自 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.

来自捻角羚:

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

如果您绝对必须使用第 3 方软件,请查看 Azure 云服务(带有 Web 角色)。您可以完全控制那里的操作系统,同时仍然是 PaaS。

关于Azure应用服务: using PerformanceCounters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38393394/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com