I have a fairly simple requirement. I am trying to use the Get-AzMetric cmdlet for PowerShell to extract "Request Count" with aggregation "SUM" metrics for an Azure Classic Cloud service. (This is same information shows in the portal under resource group --> Front Door and CDN profiles --> Monitoring -> Metrics.)
Get-AzMetric : Exception type: ErrorResponseException, Message: Microsoft.Azure.Management.Monitor.Models.ErrorResponseException: Operation returned an invalid status code 'BadRequest' at Microsoft.Azure.Management.Monitor.MetricsOperations.<ListWithHttpMessagesAsync>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Even I have tried to get the result with below frontdoor cdn profile but getting an access error (With the same reader role I am able to get result via GUI)
When I execute second script it gives me access error.
Get-AzFrontDoorCdnProfileResourceUsage : The client 'xyz@**.net' with object id '******' does not have authorization to perform action 'Microsoft.Cdn/profiles/usages/action' over scope '/subscriptions/*****/resourceGroups/*****/providers/Microsoft.Cdn/profiles/*****' or the scope is invalid.