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

EnterprisePolicyAsCode module - Catch and display errors instead of showing hardcoded error messages #581

Closed o-l-a-v closed 4 months ago

o-l-a-v commented 4 months ago

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

EPAC PowerShell tooling should properly handle errors and display relevant error messages dynamically.

Example help script Build-ScopeTableForDeploymentRootScope.ps1 called by EPAC module cmdlet Export-AzPolicyResources crashed for a collegue of mine. As error messages are hardcoded, like this example:

We had little info for starting the debugging. In his example it turned out that Az modules where old, very old. And getting them up to date made this script work again.

So this had nothing to do with Azure RM permissions, like the hardcoded error message indicates.

Describe the solution you'd like

I'd like EPAC PowerShell scripts to properly handle errors, and display the actual error message/exception.

Describe alternatives you've considered

None yet.

Additional context

chaoscreater commented 4 months ago

Same thing and we fixed it by updating AZ modules

techlake commented 4 months ago

Initial report is still valid. We'll stop intercepting the error and let azure bubble it to the user. It will be in the next version after 10.2.0, maybe named 10.2.1

techlake commented 4 months ago

Fixed in 10.2.1