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 ...
source
share