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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Az context error

ramuvr opened this issue · comments

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 did you try this?
image

parameters ref

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?

@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!

@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. :)