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

Error building exemptions with Build-DeploymentPlans #701

Closed P-M-Carroll closed 2 months ago

P-M-Carroll commented 2 months ago

Describe the bug When running Build-DeploymentPlans receive error Get-CalculatedPolicyAssignmentsAndReferenceIds: ****\EnterprisePolicyAsCode\10.4.2\internal\functions\Build-ExemptionsPlan.ps1:51:26 Line | 51 | -Assignments $sortedAssignments ` | ~~~~~~ | Cannot bind argument to parameter 'Assignments' because it is null. WARNING: Row 2: policyAssignmentId '/providers/Microsoft.Management/managementGroups/mgmt-grp/providers/Microsoft.Authorization/policyAssignments/np-loc' not found in current root scope /providers/Microsoft.Management/managementGroups/-mgmt-grp, skipping row WARNING: Row 3: policyAssignmentId '/providers/Microsoft.Management/managementGroups/mgmt-grp/providers/Microsoft.Authorization/policyAssignments/pr-loc' not found in current root scope /providers/Microsoft.Management/managementGroups/mgmt-grp, skipping row

Do not get error when running Build-DeploymentPlans -BuildExemptionsOnly

To Reproduce Using CSV with following headers. name,displayName,description,exemptionCategory,expiresOn,status,expiresInDays,scope,assignmentReferenceId,policyDefinitionReferenceIds,resourceSelectors,metadata,assignmentScopeValidation

Run Build-DeploymentPlans recireve error

Expected behavior A clear and concise description of what you expected to happen. Processing of exemption file csv to work as it does when running Build-DeploymentPlans -BuildExemptionsOnly

Screenshots image

EPAC Version 10.4.2

anwather commented 2 months ago

Are you using EPAC to manage assignments? It's a bit weird that $sortedAssignments would be null since it is built from the deployed managed assignments.

P-M-Carroll commented 2 months ago

Yes using it to deploy assignments and that works as expected when I don't have a csv file for exemptions.

anwather commented 2 months ago

OK that's a bit weird, I spoke to Ajay this morning about what you're trying to do - if you have time today we can catch up and have a look? Ping me on teams at anwather at Microsoft dot com.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: P-M-Carroll @.> Sent: Friday, July 12, 2024 11:59:16 AM To: Azure/enterprise-azure-policy-as-code @.> Cc: Comment @.>; Assign @.>; Subscribed @.***> Subject: Re: [Azure/enterprise-azure-policy-as-code] Error building exemptions with Build-DeploymentPlans (Issue #701)

Yes using it to deploy assignments and that works as expected when I don't have a csv file for exemptions.

— Reply to this email directly, view it on GitHubhttps://github.com/Azure/enterprise-azure-policy-as-code/issues/701#issuecomment-2224278522 or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACWCJVT7KXUHETJ26UN32BLZL4Z7JBFKMF2HI4TJMJ2XIZLTSSBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLAVFOZQWY5LFVIZDOMRVHE4DSNBXHCSG4YLNMWUWQYLTL5WGCYTFNSWHG5LCNJSWG5C7OR4XAZNMJFZXG5LFINXW23LFNZ2KM5DPOBUWG44TQKSHI6LQMWVHEZLQN5ZWS5DPOJ42K5TBNR2WLKJTGM3TCNRSHAZTRAVEOR4XAZNFNFZXG5LFUV3GC3DVMWVDENBQGIZDANJQGI3IFJDUPFYGLJLMMFRGK3FFOZQWY5LFVIZDOMRVHE4DSNBXHCTXI4TJM5TWK4VGMNZGKYLUMU. You are receiving this email because you commented on the thread.

Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

anwather commented 2 months ago

Issue resolved - incorrect pac environment