在 Linux 上的 Powershell 中使用服务主体登录时出错



我已经在Ubuntu 16.04上安装了Powershell,并尝试使用服务主体登录。

获取证书:-

$cred = Get-Credential -UserName $applicationId -Message "Enter Password"                       
PowerShell credential request
Enter Password
Password for user $applicationId: ********************************************

使用服务主体登录:-

Login-AzureRmAccount -ServicePrincipal -Credential $cred -TenantId $tenantId             Login-AzureRmAccount : AADSTS50001: The application named https://login.microsoftonline.com/$tenantId/ was not found in the tenant named $tenantId.  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 might have sent your authentication request to the wrong tenant.
Trace ID: 3e8b**c0-37b3-4835-9f4e-d59**100
Correlation ID: f79b**f4-8c0d-4d2b-8b80-b2d0**5784
Timestamp: 2018-01-11 12:32:37Z
At line:1 char:1
+ Login-AzureRmAccount -ServicePrincipal -Credential $cred -TenantId "0 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : CloseError: (:) [Add-AzureRmAccount], AdalServiceException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.AddAzureRMAccountCommand

请问有人知道如何解决这个问题吗?

这似乎是一个已知问题。我在实验室进行测试,我得到同样的错误日志。

PS /root> $PSVersionTable                                                                                                                                                                                                                                                     
Name                           Value                                                                                                                                                                                                                                         
----                           -----                                                                                                                                                                                                                                         
PSVersion                      6.0.0                                                                                                                                                                                                                                         
PSEdition                      Core                                                                                                                                                                                                                                          
GitCommitId                    v6.0.0                                                                                                                                                                                                                                        
OS                             Linux 4.13.0-1005-azure #7-Ubuntu SMP Mon Jan 8 21:37:36 UTC 2018                                                                                                                                                                             
Platform                       Unix                                                                                                                                                                                                                                          
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                                                       
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                                                           
SerializationVersion           1.1.0.1                                                                                                                                                                                                                                       
WSManStackVersion              3.0       

如果可能的话,我建议你可以使用 Azure Cli 2.0 或使用 Azure AD 用户登录。

最新更新