Skip to content

AzureRm.Netcore Login-AzureRmAccount not working on Mac and Linux with Service Principal  #4476

@scgbear

Description

@scgbear

Cmdlet(s)

Login-AzureRmAccount

PowerShell Version

Instructions: to get PowerShell version, type $PSVersionTable and look for the value associated with PSVersion
6.0.0-beta

Module Version

0.9.1

OS Version

Instructions: to get OS version, type $PSversionTable and look for value associated with BuildVersion

Description

Team is having issues executing the Login-AzureRmAccount cmdlet using a service principal from Mac and Linux boxes. The same script (with the same password, tenant id & username) run from a Windows 10 machine works fine. The Login-AzureRmAccount cmdlet works on the linux and mac boxes when executing the cmdlet without any parameters passed in and the user logs in manually. It's using the service principal that is having issues.

Debug Output

Instructions: to get Debug Output, set $DebugPreference="Continue" and then execute the cmdlet or script causing the issue

DEBUG: 1:26:42 PM - AddAzureRMAccountCommand begin processing with ParameterSet 'ServicePrincipalWithSubscriptionId'.
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: 'XXXXXXXXXXXXXXXXXX', Endpoint: 'https://login.microsoftonline.com/', ClientId: 'XXXXXXXXXXXXXXXXX', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/', ValidateAuthrity: 'True'
Login-AzureRmAccount : AADSTS50001: The application named https://login.microsoftonline.com/XXXXXXXXXXXXXXXXXXX/ was not found in the tenant
named XXXXXXXXXXXXXXXXXX. 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: 070ab52b-0a52-4bfd-8951-d160c3531b00
Correlation ID: 10368aee-0a64-4a5b-af11-22116e570920
Timestamp: 2017-08-15 20:26:44Z
At /XXXXXXXX/AzureResources/loginprin.ps1:13 char:1

  • Login-AzureRmAccount -Credential $Credentials -ServicePrincipal -Tena ...
  •   + CategoryInfo          : CloseError: (:) [Add-AzureRmAccount], AdalServiceException
      + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.AddAzureRMAccountCommand
    
    

DEBUG: 1:26:43 PM - AddAzureRMAccountCommand end processing.
DEBUG: 1:26:43 PM - AddAzureRMAccountCommand end processing.

Script/Steps for Reproduction

$PlainPassword = "XXXXXXXXXXXXXXXXXXXXXXXXXX"

$tenantID = "XXXXXXXXXXXXXXXXXXXXXX"

$UserName = "XXXXXXXXXXXXXXXXXXXXX"

$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force

$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, $SecurePassword

Login-AzureRmAccount -Credential $Credentials -ServicePrincipal -TenantId $tenantID

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions