microsoft / microsoft/powerbi-powershell

Cannot authenticate AAD user to PowerBi using the Management PowerShell Module

Open
#349 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
413
Forks
134
Avg merge
33m
Merged PRs (30d)
1

Description

Hi,
I am trying to authenticate to PowerBi service using the powershell management module using a Azure Active Directory user with a PowerBi Administrator role. The reason for this is because I need to perform some actions on the admin Portal which I cannot (as of yet) do with a Service principal, namely assign workspaces to a premium capacity. https://stackoverflow.com/questions/70846646/can-a-service-principal-access-admin-portal-settings-in-powerbi-service/70847582#70847582

I can successfully login with a service principal, create workspaces, assign workspace users etc...
However, when I adapt the same auth code to authenticate a AAD user I get the following error:

Connect-PowerBIServiceAccount: One or more errors occurred. (User and password authentication is not supported in .NET Core or with DeviceCode authentication.)

(I am running the PowerShell on Azure Cloud shell for development, but later will add it to a YAML pipeline)

I am using the following code:

$tenantId = $((Get-AzContext).Tenant.Id)
$PbiUserPassword = Get-AzKeyVaultSecret -VaultName "xxxxxxxxxxxxxx" -Name "pbiAdminPassword" -AsPlainText
$securePbiUserPassword = convertto-securestring $PbiUserPassword -asplaintext -force

$userName = "xxxxxxxxxxxxxxxxxxxx"
$userEmail = "$userName@xxxxxxx.onmicrosoft.com"
$userId = "xxxxxxxxxxxxxxxxxxxxxxxxxxx"

echo "Tenant Id found ===> $tenantId"
echo "User Email found ===> $userEmail"
echo "App secret found ===> $securePbiUserPassword"
echo "User id ===> $userId"
# all echoes are displaying the correct credentials

# echo "Install Power BI Management PowerShell Module..."
# $moduleName = "MicrosoftPowerBIMgmt"
# $module = Get-Module $moduleName -ListAvailable -ErrorAction SilentlyContinue
# Install-Module -Name $moduleName -Force -Scope CurrentUser -SkipPublisherCheck 

$credentials = New-Object System.Management.Automation.PSCredential ($userId, $securePbiUserPassword)

echo "Log in to Power BI"
Connect-PowerBIServiceAccount -Credential $credentials 

The documentation available is very focused around login in with service principals so would really apreciate any guidance on this aspect as this a critical aspect for our team. It would also be amazing to see enhanced permissions for the powerBi admin API for service principals!

Thank you
Joao
@CattieCat

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Connect-PowerBIServiceAccount and the PSCredential construction shown in the issue, then review the Power BI management module's authentication documentation and behavior in Azure Cloud Shell/.NET Core. Done means identifying a supported AAD user authentication path or clearly documenting that this scenario is unsupported and what limitation applies.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
authentication, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.