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
432 stars 241 forks source link

Build-DeploymentPlans fails in workflow because az.login is using an earlier version of Az.Accounts #645

Closed Jonatan-Bradley closed 5 months ago

Jonatan-Bradley commented 5 months ago

Describe the bug The bug is related to https://github.com/Azure/login/issues/447 which effects the EPAC workflows. The Enterprise Policy-as-Code module relies on newer versions of the Az module as a whole, and any downgrading of az.accounts will effect the remaining workflow.

To Reproduce Steps to reproduce the behavior: Run the epac-dev-workflow.yml workflow and the plan job will fail.

Expected behavior A clear and concise description of what you expected to happen. Build-DeploymentPlans module would run without Az.Accounts version 3.0.0 error

Screenshots build-deploymentplans

downgrading

EPAC Version Version of EPAC module you are using. EnterprisePolicyAsCode 10.2.11

anwather commented 5 months ago

Did you try running with the uses: azure/login@hf_447_release release?

Jonatan-Bradley commented 5 months ago

I did try and run into the same issue where later steps relies on Az.Accounts version 3.0.0 and the workflow breaks. The Azure login job will work but not the plan job after.

anwather commented 5 months ago

I can bump the required version of Az.Accounts to 3.0.0 in the module - would that solve the problem do you think?

anwather commented 5 months ago

The other thing I need to check is if we even still required the Az.ResourceGraph module (which is causing all of these issues with versions)

Jonatan-Bradley commented 5 months ago

Isn't the requirement of version Az.Accounts 3.0.0 in the module what's causing the issue? Since the specific error is:

 | The 'Build-DeploymentPlans' command was found in the module
 | 'EnterprisePolicyAsCode', but the module could not be loaded due to the
 | following error: [The running command stopped because the preference
 | variable "ErrorActionPreference" or common parameter is set to Stop:
 | This module requires Az.Accounts version 3.0.0. An earlier version of
 | Az.Accounts is imported in the current PowerShell session. Please open a
 | new session before importing this module. This error could indicate that
 | multiple incompatible versions of the Azure PowerShell cmdlets are
 | installed on your system. Please see https://aka.ms/azps-version-error
 | for troubleshooting information.] For more information, run
 | 'Import-Module EnterprisePolicyAsCode'.

Sorry if my interpretation is off here

anwather commented 5 months ago

I just checked the code, we don't need to use the resource graph module which also forced a newer version of Az.Accounts - give me 30 mins I'll remove all the required modules and then we'll see what hapoens

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


From: Jonatan-Bradley @.> Sent: Tuesday, May 28, 2024 6:37:41 PM To: Azure/enterprise-azure-policy-as-code @.> Cc: Comment @.>; Subscribed @.> Subject: Re: [Azure/enterprise-azure-policy-as-code] Build-DeploymentPlans fails in workflow because az.login is using an earlier version of Az.Accounts (Issue #645)

Isn't the requirement of version Az.Accounts 3.0.0 in the module what's causing the issue? Since the specific error is:

| The 'Build-DeploymentPlans' command was found in the module | 'EnterprisePolicyAsCode', but the module could not be loaded due to the | following error: [The running command stopped because the preference | variable "ErrorActionPreference" or common parameter is set to Stop: | This module requires Az.Accounts version 3.0.0. An earlier version of | Az.Accounts is imported in the current PowerShell session. Please open a | new session before importing this module. This error could indicate that | multiple incompatible versions of the Azure PowerShell cmdlets are | installed on your system. Please see https://aka.ms/azps-version-error | for troubleshooting information.] For more information, run | 'Import-Module EnterprisePolicyAsCode'.

Sorry if my interpretation is off here

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

@Jonatan-Bradley - can you please test again for me?

anwather commented 5 months ago

Ensure if you have steps in the workflow that install the Az.ResourceGraph module you remove them as well.

Jonatan-Bradley commented 5 months ago

That did the trick! Thank you for the quick response and solution, much appreciated!