microsoft / microsoft/powerbi-powershell
Login-PowerBI -Credential $cred does not work in Azure Automation
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 413
- Forks
- 134
- Avg merge
- 33m
- Merged PRs (30d)
- 1
Description
This code doesn't work in Azure Automation:
Login-PowerBI -Credential $mycreds
The reason it doesn't work is that it's calling WindowsAuthenticationFactory.InitializeCache which tries to start a process.
https://github.com/microsoft/powerbi-powershell/blob/master/src/Common/Common.Authentication/WindowsAuthenticationFactory.cs
That may make sense for interactive login popups, but for passing -Credential it shouldn't be interactive. (I don't think -Credential currently supports multi-factor auth logins.)
To prove launching a process is the culprit, the following code in a Azure Automation Runbook (PowerShell) will cause it to fail and be suspended after 3 retries just like the Login-PowerBI -Credential $cred code does:
$ps = new-object System.Diagnostics.Process
$ps.StartInfo.Filename = "ipconfig.exe"
$ps.StartInfo.Arguments = " /all"
$ps.StartInfo.RedirectStandardOutput = $True
$ps.StartInfo.UseShellExecute = $false
$ps.start() | Out-Null
$ps.WaitForExit()
[string] $Out = $ps.StandardOutput.ReadToEnd();
$Out
To also prove you can't run an executable inside Azure Automation, see this link:
The reason I'm trying to do credential auth is because service principal auth doesn't currently have access to classic workspaces I believe.
Please enhance the Login-PowerBI cmdlet to avoid launching a process when you use the -Credential parameter only.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/Common/Common.Authentication/WindowsAuthenticationFactory.cs at WindowsAuthenticationFactory.InitializeCache, then trace the Login-PowerBI path used with -Credential. Verify that credential authentication avoids launching a process and works in an Azure Automation PowerShell runbook; the issue provides the process-launch example for comparison.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, powershell
- Domain
- authentication, cli, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100