Open charliekunkel opened 1 year ago
Most of that error output is from my previous call to Import-Module Az", which looks like was already reported via https://github.com/Azure/azure-powershell/issues/19997 . The call to get-azmetric doesn't seem to produce an error. It just produces warnings, and what appears to be (based on the debug info) no values returned.
Body: { "value": [] }
@charliekunkel could you share detail steps of creating vm and how to get data from Portal CLI? We need to compare the difference.
The VMs have existed for years. They were created via the Azure portal GUI via going to the VMs resource page, then clicking +Create.
If I go to the Azure portal and click the Cloud Shell icon, then enter this:
PS /home/ckunkel> $webserver = "fuzeweb01" PS /home/ckunkel> $st = (get-date).addminutes(-1) PS /home/ckunkel> $et = (get-date) PS /home/ckunkel> $timeg = '00:01:00' PS /home/ckunkel> $creditsRemaining = Get-AzMetric -ResourceId "/subscriptions/4b0ebbb1-8954-4435-b8c0-cc53cf67ff79/resourceGroups/fuzevms/providers/Microsoft.Compute/virtualMachines/$webserver" -TimeGrain $timeg -StartTime $st -EndTime $et -MetricNames 'CPU Credits Remaining' WARNING: 7:40:38 PM - The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases. WARNING: 7:40:38 PM - The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes. WARNING: [Get-AzMetric] Parameter deprecation: The DetailedOutput parameter will be deprecated in a future breaking change release.
It works.
PS /home/ckunkel> write-output $creditsRemaining.Data.Average 1284.54
I need to be able to run this from powershell on the VMs though. It doesn't work on any of them. The same thing happens. It outputs the warnings, but no data is returned to the $creditsRemaining variable.
Thanks
any update? Still, to date, occasionally Get-AzMetric
returns no data.
Description
This DOES work from the Azure Portal CLI. Just not from any of the VMs and I need to run it on the VMs as part of a scheduled task. I tried capturing the results in a variable and outputting .Data.Average property (per https://github.com/Azure/azure-powershell/issues/8970), but that doesn't work either for me. I've already spent 4 hours on this with no results. Yes, I've completely uninstalled and re-installed the Az Module and rebooted several times. Please help.
Issue script & Debug output
Environment data
Module versions
Error output