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
410 stars 216 forks source link

Exception calling "Add" with "2" argument(s): "Item has already been added. #607

Closed KennethBess closed 4 months ago

KennethBess commented 4 months ago

Describe the bug We try to deploy ALZ policies, but the below error:

Build-AssignmentPlan: /home/vsts/.local/share/powershell/Modules/EnterprisePolicyAsCode/10.2.1/functions/Build-DeploymentPlans.ps1:310
Line |
 310 |          Build-AssignmentPlan `
     |          ~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "Add" with "2" argument(s): "Item has already been
     | added. Key in dictionary:
     | '/providers/Microsoft.Management/managementGroups/EPAC.TEST/providers/Microsoft.Authorization/policyAssignments/Deny-Subnet-Without-Nsg'  Key being added: '/providers/Microsoft.Management/managementGroups/EPAC.TEST/providers/Microsoft.Authorization/policyAssignments/Deny-Subnet-Without-Nsg'"

##[error]PowerShell exited with code '1'.

image

EPAC Version Version of EPAC module used are 10.2.1.

anwather commented 4 months ago

Fairly sure that policy is meant to be assigned at to different scopes, identity management group and Corp management group.

Check the corp and identity assignment files, you'll need to remove one of the duplicate assignments.

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


From: Kenneth Bess @.> Sent: Thursday, May 2, 2024 9:20:36 PM To: Azure/enterprise-azure-policy-as-code @.> Cc: Subscribed @.***> Subject: [Azure/enterprise-azure-policy-as-code] Exception calling "Add" with "2" argument(s): "Item has already been added. (Issue #607)

Describe the bug We try to deploy ALZ policies, but the below error:

Build-AssignmentPlan: /home/vsts/.local/share/powershell/Modules/EnterprisePolicyAsCode/10.2.1/functions/Build-DeploymentPlans.ps1:310 Line | 310 | Build-AssignmentPlan ` | ~~~~~~ | Exception calling "Add" with "2" argument(s): "Item has already been | added. Key in dictionary: | '/providers/Microsoft.Management/managementGroups/EPAC.TEST/providers/Microsoft.Authorization/policyAssignments/Deny-Subnet-Without-Nsg' Key being added: '/providers/Microsoft.Management/managementGroups/EPAC.TEST/providers/Microsoft.Authorization/policyAssignments/Deny-Subnet-Without-Nsg'"

[error]PowerShell exited with code '1'.

image.png (view on web)https://github.com/Azure/enterprise-azure-policy-as-code/assets/27630182/727de006-7936-43f3-9c4d-e0592b00a296

EPAC Version Version of EPAC module used are 10.2.1.

— Reply to this email directly, view it on GitHubhttps://github.com/Azure/enterprise-azure-policy-as-code/issues/607 or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACWCJVQ4ZSQF4KNG3E2CRI3ZAIOQJBFKMF2HI4TJMJ2XIZLTSSBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJLJONZXKZNENZQW2ZNLORUHEZLBMRPXI6LQMWBKK5TBNR2WLKRSG4ZDKOJYHE2DOOFENZQW2ZNJNBQXGX3MMFRGK3ECUV3GC3DVMWSHI4TVMWSG4YLNMWXHOYLUMNUF6YLDORUXM2LUPGWHG5LCNJSWG5C7OR4XAZNFJFZXG5LFUZ2G64DJMNZZHAVEOR4XAZNKOJSXA33TNF2G64TZUV3GC3DVMWUTGMZXGE3DEOBTHCBKI5DZOBS2K2LTON2WLJLWMFWHKZNKGIZDONJSHEYDONZXQKSHI6LQMWSWYYLCMVWKK5TBNR2WLKRSG4ZDKOJYHE2DOOFHORZGSZ3HMVZKMY3SMVQXIZI. You are receiving this email because you are subscribed to this 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 4 months ago

Closing due to no response