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 - Check minimum required version of Az modules #582

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.

Same example as #581

EnterprisePolicyAsCode could check what version of required Az modules is imported and see if they are recent enough.

Describe the solution you'd like

Add check for minimum required version of required Az modules.

Describe alternatives you've considered

None yet.

Additional context

581

anwather commented 4 months ago

This has been added to the development environment and will be available in the next minor version

o-l-a-v commented 4 months ago

Where was this added? Seems it was added to the psd1, but then removed again, like here:

It would be good if the issue remained open until a version with this feature actually has been published.

anwather commented 4 months ago

It caused the build process to fail so we had to revert the changes. Will fix next week.

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


From: Olav Rønnestad Birkeland @.> Sent: Saturday, April 27, 2024 1:32:33 AM To: Azure/enterprise-azure-policy-as-code @.> Cc: Comment @.>; Assign @.>; State change @.>; Subscribed @.> Subject: Re: [Azure/enterprise-azure-policy-as-code] EnterprisePolicyAsCode module - Check minimum required version of Az modules (Issue #582)

Where was this added? Seems it was added to the psd1, but then removed again, like here:

It would be good if the issue remained open until a version with this feature actually has been published.

— Reply to this email directly, view it on GitHubhttps://github.com/Azure/enterprise-azure-policy-as-code/issues/582#issuecomment-2079623572 or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACWCJVVXKJYIEV2MK5S4MHTY7JXRDBFKMF2HI4TJMJ2XIZLTSSBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLAVFOZQWY5LFVIZDOMRVHE4DSNBYGOSG4YLNMWUWQYLTL5WGCYTFNSWHG5LCNJSWG5C7OR4XAZNMJFZXG5LFINXW23LFNZ2KM5DPOBUWG44TQKSHI6LQMWVHEZLQN5ZWS5DPOJ42K5TBNR2WLKJTGM3TCNRSHAZTRAVEOR4XAZNFNFZXG5LFUV3GC3DVMWVDEMRVHEZTOMJQGAZIFJDUPFYGLJLMMFRGK3FFOZQWY5LFVIZDOMRVHE4DSNBYGOTXI4TJM5TWK4VGMNZGKYLUMU. 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.

o-l-a-v commented 4 months ago

Ok. For inspiration: AzOps does it in psd1 too, but with RequiredVersion instead:

Edit: My bad, ModuleVersion seems right, ref:


While Az.Resources does it in psm1:

Tha last seems most flexible.


Edit again: I could reproduce the problem in run https://github.com/Azure/enterprise-azure-policy-as-code/actions/runs/8850190182 by removing Az.Accounts from my computer before running Test-ModuleManifest. So the fix is to Microsoft.PowerShell.PSResourceGet\Install-PSResource -Name 'Az.Accounts','Az.ResourceGraph' -Repository 'PSGallery' -TrustRepository -Scope 'CurrentUser' -SkipDependencyCheck in https://github.com/Azure/enterprise-azure-policy-as-code/blob/main/.github/workflows/automated-publish.yaml, right?

Or change publish process to use Microsoft.PowerShell.PSResourceGet cmdlet Publish-PSResource which conveniently has a -SkipDependenciesCheck switch. If it works as intended.

o-l-a-v commented 4 months ago

@anwather

As the OP says, export policies failed with Az.Accounts v2.9.1. So I don't get why EPAC specifies that as a working minimum version in the psd1.

anwather commented 4 months ago

My bad I didn't see that in the original issue - have bumped to 2.15.1 in line with Az 11.3.1 which is the current version of tools in GitHub runners.