Azure – How to get performance metrics for a VM in azure with power-shell and cli

azurecommand-line-interface

Am getting an error while running cli cmd " access denied".

   az monitor metrics list --resource 
   /subscriptions/xxx/resourceGroups/yyy/providers/Micros‌​ 
   oft.Compute/virtualM‌​achines/TestVM --metric-names "Percentage CPU" -- 
   time-grain "PT1M" >> PercentageCpuData.txt

Best Answer

Assuming your using CLI v2 then the command has a number of incorrect parameter names, it should be:

az monitor metrics list --resource /subscriptions/subID/resourceGroups/RGName/providers/Microsoft.Compute/virtualMachines/machinename --metric "Percentage CPU" --interval PT1M

If that still doesn't work you will need to check that you do actually have the right permissions to query this.

Related Topic