Can an Azure website / application determine its processor / instance memory usage?

I need my instances to register their use of cpu / mem (preferably% of the total), but everything I tried on the Azure website does not work. It interrupts the launch and leads to 502 errors. I tried ManagementObjectSearcher and PerformanceCounter. These jobs are discovered locally, but not when deployed to Azure. Is this feature simply disabled? Can WebJob get better lucky?

The only alternative I can think of is that there is no way to do this on an instance of a website, make a PowerShell script or other application that can search it through the Azure API and store it in a common place for instances to search on fly ...

+1
source share
1 answer

You cannot access performance counter data and the like in Azure Webapps. You should be able to use the class System.Diagnostics.Processand get a list of processes and find out the w3wp process and get its CPU and memory usage if you really want to do this in the website code itself.

<%@ Page language="cs" %>
<%@ Import Namespace="System.Diagnostics" %>
<%
foreach (Process p in  System.Diagnostics.Process.GetProcesses())
{
Response.Write ("<br/>" + p.ProcessName + "\t" + p.Id + "\t" +    p.PrivateMemorySize+ "\t" + "\t" );
}

%>

The easiest way is to write a powerhell script and run it as a webjob. Powershell code like the one on your weblog can provide you with the information you are looking for

gps|where {$_.name -eq 'w3wp' }|select PrivateMemorySize, CPU, Id

hope this helps ...

+1
source

Source: https://habr.com/ru/post/1677414/


All Articles