problem with aggregation?
Hi
Please validate that the aggregate syntax is correct. Trying to run your command from powershell, it seems to fail
PS: az policy state list --apply "groupby((policyAssignmentId, policySetDefinitionId, policyDefinitionReferenceId, policyDefinitionId), aggregate($count as numStates))"
az : ERROR: (InvalidApplyInQueryString) 'with' expected at position 116 in 'groupby((policyAssignmentId, policySetDefinitionId, policyDefinitionReferenceId, policyDefinitionId), aggregate( as numStates))'.
At line:1 char:1
+ az policy state list --apply "groupby((policyAssignmentId, policySetD ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (ERROR: (Invalid...s numStates))'.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
This one using AzureRM works fine... I think I'll revert back, as even the outcome is displayed much better than having to process json file.
Get-AzureRmPolicyState -Filter "IsCompliant eq false" -Apply "groupby((PolicyAssignmentId, PolicySetDefinitionId, PolicyDefinitionReferenceId, PolicyDefinitionId), aggregate($count as NumStates))" -OrderBy "NumStates desc"
`
Thanks
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: ca46c96d-8c88-7c4a-d75f-1c6c45d0f75c
- Version Independent ID: 9b8bdef9-8f67-7e82-1ae8-9356b62e84b0
- Content: az policy state
- Content Source: src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/_help.py
- Service: azure-resource-manager
- GitHub Login: @rloutlaw
- Microsoft Alias: routlaw
Since you are in powershell, the $count will be interpreted as a variable and becomes an empty string, so avoid such behavior, you need to use single quotes. My PR #8668 will clarify this