microsoft / powerbi-azure-pipelines-extensions

MIT License
36 stars 14 forks source link

"Failed to populate environments in settings" from On-Prem ADO, potential proxy issue, limitation of Powershell 3? #11

Closed GitHubJedi closed 1 year ago

GitHubJedi commented 2 years ago

Here are a few assumptions I'm making

  1. I am using On-Premise Azure DevOps Server
  2. The task group connects using Powershell 3 and not Powershell Core based on this line from the AddUsers task group json "execution": { "PowerShell3": { "target": "Run.ps1" } }
  3. Based on a similar Azure module, there is not a great way to set proxy environment variables for Powershell versions lower than 7 https://docs.microsoft.com/en-us/powershell/azure/az-powershell-proxy?view=azps-7.3.0
  4. Normally for other Azure tasks that have issues getting out, we set the proxy variable in the Azure DevOps pipeline variables like this, and this works fine: image
  5. If I force a normal Powershell Task to run as Powershell Core (i.e. Powershell 7+), it takes the http_proxy, https_proxy and I am able to do Invoke-WebRequests to api.powerbi.com and app.powerbi.com. If I do not set this, I cannot reach these hosts image
  6. Given above, I am able to connect to Power BI with a Powershell Task, Connect-PowerBIServiceAccount if I include all of the libraries, etc. if I run as Powershell Core + proxy settings in the env variables

Even with setting the proxy ADO env vars, we receive this error when running the Add-Users task group (other Power BI extension tasks do this as well):

##[section]Starting: Add a user to a workspace
==============================================================================
Task         : Add a user to a workspace
Description  : Add a user to a Power BI workspace
Version      : 1.0.3
Author       : Microsoft
Help         : 
==============================================================================
Importing module MicrosoftPowerBIMgmt.Profile
Connecting to Power BI with ServicePrincipal
##[error]Failed to populate environments in settings
##[section]Finishing: Add a user to a workspace

We would like to continue to be able to set the environment variable proxy within an ADO release, instead of setting this on the Azure DevOps VM server wide so the proxy can be set only as needed. Is there a way we can force this extension to run as Powershell Core/7, or another setting to allow Powershell 3 to pickup a proxy? Thanks.

MahirDiab commented 2 years ago

the power bi extension runs using PowerShell 3, per the Azure DevOps Team there is no support for newer PowerShell versions in the azure pipelines agent so the extension can't run on PowerShell 7 today.

as you mentioned you can install the required libraries and use the PowerShell code from this repo.

GitHubJedi commented 2 years ago

why PowerShell 3? isn't this an ancient PowerShell at this point? why develop a new extension in such an old PowerShell version especially with Azure...?

I guess when I look at Powershell Tasks in Azure Devops, there is an option to run as "Powershell Core"...wouldn't this mean Powershell 7 is supported in ADO...?

I tracked down the commit in Azure Pipelines that adds support for Powershell Core (7), so not sure your statement about no support is correct:

https://github.com/HQJaTu/azure-pipelines-tasks/commit/f00f4c18f160d4a4af47eec84cebbfcd80482200#diff-e3a2d39f030e15c13d7a5e308b1d2749

thanks for the response