Azure / enterprise-azure-policy-as-code

Enterprise-ready Azure Policy-as-Code (PaC) solution (includes Az DevOps pipeline)
https://azure.github.io/enterprise-azure-policy-as-code/
MIT License
415 stars 219 forks source link

`Set-AzPolicySetDefinitionRestMethod`: Say what file errored #735

Closed o-l-a-v closed 2 weeks ago

o-l-a-v commented 2 weeks ago

Is your feature request related to a problem? Please describe.

When Set-AzPolicySetDefinitionRestMethod errors it does not say what file, or ID/name of policy object failed.

Example:

Write-Error: /home/runner/.local/share/powershell/Modules/EnterprisePolicyAsCode/10.5.6/functions/Deploy-PolicyPlan.ps1:162
Line |
 162 |              Set-AzPolicySetDefinitionRestMethod -Definition $entry -A …
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | definition error 400 -- {   "error": {     "code":
     | "InvalidRequestContent",     "message": "The request content was invalid
     | and could not be deserialized: 'Could not find member 'allowed' on
     | object of type 'PolicyParameterDefinition'. Path
     | 'properties.parameters.effect.allowed', line 1, position 296.'."   } }
Error: Error: The process '/usr/bin/pwsh' failed with exit code 1

Describe the solution you'd like

Error should say what file caused the errored.

Describe alternatives you've considered

None yet.

Additional context

None.