Mystery of the Windows Azure Diagnostics Performance Counter table
Are Performance Counter Diagnostics logs not getting created in your Azure development storage? Or is your Azure development fabric displaying similar error messages, while getting your specific performance counter to register
PdhAddCounter(\Process(MonAgentHost#0)\ID Process) failed
The problem could lie with pointers to your system performance counters being corrupted. Here is a step by step guidance to investigate and resolve the issue.
Symptoms:
1. Azure development fabric displaying Error message PdhAddCounter(\Process(MonAgentHost#0)\ID Process) failed"
2. WADPerformanceCounters Azure table not created in the Azure development Storage
3. Performance Counters configured in the Windows Azure application are not being captured in the WADPerformanceCounters table
Identify cause:
Build a separate application (there are several samples easily available on the public domain), preferably outside the cloud development environment and access the performance counters programmatically. Do you get the following exception?
"Cannot load Counter Name data because an invalid index was read from the registry
Yes, then here is what you need to do?
Steps to rectify problem:
1. Launch Command window in elevated mode
a. Click Start
b. Type CMD -> Triggers search for cmd and displays cmd.exe
c. Right click on cmd.exe
d. Click on "Run as administrator"
Command Window is launched in Administrator mode
2. Repair performance counter pointers ( those stored in registry)
a. Type Lodctr /r //to reset counters, will lead to pointers being enabled
Performance Counters to be rebuilt from system backup store
3. Check status of performance counters
a. Type Lodctr /q //to check state of counters
Status of performance counters listed
4. If any of the performance counter is disabled run the following command to enable the counter
a. Type Lodctr /e: <Name of performance counter which is disabled> //To enable counter
<Name of performance counter> is the string between the [ ] at the beginning of the entry listed after running the command previous step
Performance counter is enabled
Check resolution:
Run your Windows Azure application in the development fabric with the Performance counter configured as per the instructions provided here
The WADPerformanceCounters log table should now be visible in the development storage.
NOTE: The above problem is more likely to occur within the local development environment than on the cloud hosted instance, primarily due to the standardized nature of the VM instances hosting the Windows Azure application.
Hope this information is found useful to developers troubleshooting diagnostic issues on Windows Azure.


