简体   繁体   中英

Error when login using service principal in Powershell on Linux

I have installed Powershell on Ubuntu 16.04 and trying to login using service principal.

Get Credential:-

$cred = Get-Credential -UserName $applicationId -Message "Enter Password"                       

PowerShell credential request
Enter Password
Password for user $applicationId: ********************************************

Login using service principal:-

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

Kindly any one know how to solve this?

It seems a known issue . I test in my lab, I get the same error log with you.

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       

If possible, I suggest you could use Azure Cli 2.0 or login with Azure AD user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM