I have an azure function app with runtime version ~3 and powershell version 7.0 creating a connection to powerbi that is connecting to azure active directory.
Import-Module -Name MicrosoftPowerBIMgmt
$id=$user
$password=$token | ConvertTo-SecureString -AsPlainText -Force
$credential=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $id, $password
Connect-PowerBIServiceAccount -Credential $credential
Throws an exception Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly
Above script works fine on powershell version 5.1 however not able to use old version on Azure Functions.
Tried to import with UseWindowsPowerShell Import-Module -Name MicrosoftPowerBIMgmt -UseWindowsPowerShell
however it also throws an exception ERROR: Failed to generate proxies for remote module 'MicrosoftPowerBIMgmt'. Running the Get-Command command in a remote session returned no results.
Not able to understand why creating a connection to active directory is so hard and cumbersome, could anyone please help to resolve the above issue. Thanks in advance!