Azure Function ~3运行时PS7.0下连PowerBI报SHA256Cng加载失败问题问询
Azure Function Power BI连接异常说明
当前部署的Azure Function应用运行时版本为*~3*,使用PowerShell 7.0编写业务逻辑,需实现对接Azure Active Directory的Power BI连接能力,所用脚本如下:
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
运行中触发的两类异常
- 直接执行上述脚本时,抛出类型加载错误:
Could not load type 'System.Security.Cryptography.SHA256Cng' from assembly
经测试,这段脚本在PowerShell 5.1环境下可正常运行,但Azure Functions平台不支持使用旧版本PowerShell承载当前函数应用。 - 为兼容旧模块,尝试添加
-UseWindowsPowerShell参数导入模块,即执行Import-Module -Name MicrosoftPowerBIMgmt -UseWindowsPowerShell时,抛出模块代理生成错误:ERROR: Failed to generate proxies for remote module 'MicrosoftPowerBIMgmt'. Running the Get-Command command in a remote session returned no results.
核心诉求
目前无法理解Azure Active Directory对接的Power BI连接配置为何流程如此繁琐,恳请协助定位上述异常根因,给出适配当前运行环境的可行实现方案。
内容的提问来源于stack exchange,提问作者hagarwal
相关产品推荐
相关产品推荐

