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
422 stars 231 forks source link

Export-AzPolicyResources Failing for AzureChinaCloud Tenants #692

Closed ahsulli closed 2 months ago

ahsulli commented 3 months ago

Describe the bug Export-AzPolicyResources results in an error when trying to get the existing policy assignments. The error message indicates that the apiVersion must be specified in the REST call. Upon further investigation, Select-PacEnvironment is never called, so the apiVersion field is not ever set on the $pacEnvironment object.

To Reproduce

  1. Run Export-AzPolicyResources using a pacSelector of type AzureChinaCloud.

Expected behavior All the existing policy assignments at or below the specified pacSelector configuration should be returned as a result of the call.

EPAC Version 10.3.5

anwather commented 3 months ago

We'll have to make some changes to the Export-AzPolicyResources script to enable this to work - but you are correct in why it doesn't work.

anwather commented 3 months ago

@ahsulli - Can you please test the updated Export-AzPolicyResources script in the feature/aw/issue692 branch? Let me know if this fixes the issue.

ahsulli commented 2 months ago

@anwather, that branch's change resolves this issue. It does not resolve issue #691. I provided code to @gregslack78 that resolves issue #691. Please let me know if you need me to create a branch and provide that code.