Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error with Az and AzureRM modules #3271

Open
MoZiZ00 opened this issue Mar 4, 2025 · 1 comment
Open

[BUG] Error with Az and AzureRM modules #3271

MoZiZ00 opened this issue Mar 4, 2025 · 1 comment
Labels
bug Something isn't working waiting-feedback An issue or PR that needs author feedback.

Comments

@MoZiZ00
Copy link

MoZiZ00 commented Mar 4, 2025

Existing rule

No response

Description of the issue

Hi All,

please i have an issue related to when i am going to export data from azure i am facing the below warning and there is no Json file exported from azure side and i have tried a lot of articles to uninstall AzureRm "Uninstall-AzureRm" but facing another error and not able to Uninstall it

1-so, anyone faced the same issue and how i can fix it
2-is the mentioned warning can Couse the issue related that there is no json file exported from azure side
3-i am not able to export the Json file

Error messages

WARNING: Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide

Reproduction

i am using this command to export the azure data

Export-AzRuleData -Subscription 'testsbox.01' -ResourceGroupName "test" -OutputPath $outputPath

Version of PSRule

2.9.0

Version of PSRule for Azure

No response

Additional context

No response

@MoZiZ00 MoZiZ00 added bug Something isn't working Needs: Triage 🔍 Needs attention from the team. labels Mar 4, 2025
@BernieWhite
Copy link
Collaborator

@MoZiZ00 I don't think the warning should impact running of PSRule in this case. Things to try:

  1. Import the Az PowerShell module directly on a fresh command line before running PSRule. e.g. Import-Module Az.Accounts.
  2. Verify you are connected to a subscription, by running Get-AzContext and Get-AzResourceGroup. If not connected use Connect-AzAccount. If you are unable to list resource groups, then this could indicate that you don't have Reader permissions in the current session or need to activate Privilege Identity Management (PIM) if you use PIM in your environment.
  3. Try running Export-AzRuleData with -Verbose to get additional logs that may provide additional information to help diagnose the issue.

https://azure.github.io/PSRule.Rules.Azure/faq/#what-permissions-do-i-need-to-export-rule-data
https://azure.github.io/PSRule.Rules.Azure/export-rule-data/


Also:

  • What version of PSRule for Azure do you have installed?
  • Are you running this locally or in a pipeline? Please provide details about the task/ action if you are running this in a pipeline.

@BernieWhite BernieWhite added waiting-feedback An issue or PR that needs author feedback. and removed Needs: Triage 🔍 Needs attention from the team. labels Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting-feedback An issue or PR that needs author feedback.
Projects
None yet
Development

No branches or pull requests

2 participants