如何在Powershell Core中连接Connect-AzAccount(无提示?)>

问题描述 投票:0回答:1

我确实看到了这个问题:Connect-AzAccount without prompt

但是当我尝试接受的答案时,出现以下错误:

[6/12/2020 12:36:20 AM] ERROR: Connect-AzAccount : Username + Password authentication is not supported in PowerShell Core. Please use device code authentication for interactive log in, or Service Principal authentication for script log in.

因此,我去了Connect-AzAccount文档的example 3,该文档指定了“服务主体”身份验证方法,因此我将两者混合使用,因为建议的普通Get-Credential会触发另一个交互式会话。所以现在是脚本:

    $User = "[email protected]"
    $PWord = ConvertTo-SecureString -String "**********" -AsPlainText -Force
    $tenant = "f*********************************"
    $Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User,$PWord
    # $Credential = Get-Credential
    Connect-AzAccount -Credential $Credential -Tenant $tenant -ServicePrincipal

这带来了我的下一个错误:[6/12/2020 12:45:45 AM] ERROR: Connect-AzAccount : AADSTS700016: Application with identifier 'myemail' was not found in the directory 'f*********************************'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant.

在这一点上,我真的很困惑,因为我目前在Azure中所做的就是:

  1. 创建一个新的Azure帐户
  2. 通过UI提供Azure API管理实例(大约需要20分钟)
  3. 尝试使用上面的代码在本地将Powershell Azure函数连接到Azure。
  4. 我认为我提供的信息或如何配置某些东西有问题。

[$User是我注册到Azure的电子邮件。

[$PWord是我的Azure密码

$tenant是我打开Azure AD时看到的第一件事:

enter image description here

我尝试通过Powershell Core连接到Azure有什么问题?

[我确实看到了这个问/答:没有提示的Connect-AzAccount,但是当我尝试接受的答案时,出现以下错误:[6/12/2020 12:36:20 AM]错误:Connect-AzAccount:用户名+密码...

azure powershell azure-active-directory azure-powershell azure-api-management
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.