JulianHayward / Azure-MG-Sub-Governance-Reporting

Azure Governance Visualizer aka AzGovViz is a PowerShell script that captures Azure Governance related information such as Azure Policy, RBAC (a lot more) by polling Azure ARM, Storage and Microsoft Graph APIs.
MIT License
817 stars 295 forks source link

Az context error #169

Closed ramuvr closed 1 year ago

ramuvr commented 1 year ago

AzGovViz version v6_major_20230213_1

CodeRunPlatform Azure DevOps

Describe the bug Occasionally getting the below error on Devops pipeline run

`` Check Az context failed: Az context is not set to any Subscription Set Az context to a subscription by running: Set-AzContext -subscription (run Get-AzSubscription to get the list of available Subscriptions). When done re-run the script OR Use parameter -SubscriptionId4AzContext - e.g. .\AzGovVizParallel.ps1 -SubscriptionId4AzContext Exception: /home/vsts/.local/share/powershell/Modules/AzAPICall/1.1.68/functions/AzAPICallFunctions.ps1:1859 Line | 1859 | Throw 'Error - check the last console output for details' | ~~~~~~~~~~~~~ | Error - check the last console output for details

[error]PowerShell exited with code '1'.

Finishing: Run AzGovViz ``

Screenshots

Additional context

ramuvr commented 1 year ago
Screenshot 2023-02-23 201734
JulianHayward commented 1 year ago

@ramuvr did you try this? image

parameters ref

ramuvr commented 1 year ago

Hi @JulianHayward I am running this as a pipeline so wasn't sure where to add, I have tried adding it to the AzGovViz.variables.yml under parameters but the pipeline ignored the one I specified under default and took a random subscription when it ran. Where else should I specify the parameter or should it go under variables?

JulianHayward commented 1 year ago

@ramuvr almost :) it is a variable in AzGovViz.variables.yml (already exists in the YAML but is not configured by default)

image

Let´s update the error return with more precise information how/where to set the parameter - thanks!

ramuvr commented 1 year ago

@JulianHayward Sorry got distracted in between work. I had added it as variable without realizing it was already present. Now I removed it and used the variable you had in the file and that worked!! Thanks so much. One less thing to worry. :)