【问题标题】:Authentication Error while connecting to Msolservice using azure functions使用 azure 函数连接到 Msolservice 时出现身份验证错误
【发布时间】:2022-08-24 22:22:55
【问题描述】:

我已经部署了一个函数应用程序,其中包含一个连接到 msolservice 的 azure 函数。但这最近产生了身份验证错误。 我正在使用的脚本:

$username = \'xxx\' 
$password = \'xxx\' 
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $username, $(convertto-securestring $password -asplaintext -force)
Connect-MsolService -Credential $cred

它产生的错误: Connect-MsolService:身份验证错误:意外身份验证失败。

功能应用详情 函数运行时:Powershell 运行时版本:3.8.2.0

用户未启用 MFA。 我可以从我的本地 powershell 连接它。有关此问题的任何帮助都会有所帮助

  • 尝试使用 Get-Credential cmdtel 获取 Pscredential
  • 现在有同样的问题。你解决了吗?

标签: azure-functions


【解决方案1】:

这周我遇到了同样的问题。我通过做三件事来修复它:

  1. 将以下代码行添加到脚本以强制 TLS 1.2

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    
  2. 从 Windows 控制面板卸载 Azure AD Powershell 模块。该模块已过时。

  3. 在具有管理员权限的 Powershell 提示符下使用以下命令安装新的 Powershell 模块:

    Install-Module -Name MSOnline -Force
    

    另外,值得一提的是我在解决此问题时发现的另外两个常见问题。首先,用于建立连接的服务帐户必须成为一个完整的全球管理员。其次,如果此脚本要完全自动化,则该帐户不能使用 MFA。这很快就会给我带来更多问题,因为我们正在努力在几乎所有地方都需要 MFA。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-05
    • 2017-06-18
    • 1970-01-01
    • 1970-01-01
    • 2013-03-12
    • 2018-09-06
    • 1970-01-01
    • 2022-01-17
    相关资源
    最近更新 更多