Forum Discussion
Roy Hochstenbach
Jan 18, 2018Copper Contributor
Cannot login using ServicePrincipal: Application was not found in the directory
I'm trying to set up an automation script that allows me to start up and shut down virtual machines in Azure without any user input. I've created an application registration (Web app / API) in Azure AD and in Subscriptions I've assigned the Virtual Machine Contributor role.
The application ID is: a8faf7f8-a0c2-4c03-8989-0a2d32915cd9
The tenant ID is: 696c6a65-a325-4af4-bfc4-f67a88425e4b
I have assigned a credential to the ServicePrincipal:
New-AzureRmADSpCredential -ServicePrincipalName https://mydomain.com/0f7b7873-2354-48ad-9ee4-9e6cfefd04d4 -Password "mypassword"
I try to log in as follows:
$applicationid ="a8faf7f8-a0c2-4c03-8989-0a2d32915cd9" $principalPassword = ConvertTo-SecureString "mypassword" -AsPlainText -Force $psCred = New-Object System.Management.Automation.PSCredential($applicationid, $principalPassword)
Login-AzureRmAccount -Credential $psCred -ServicePrincipal -TenantId 696c6a65-a325-4af4-bfc4-f67a88425e4b
But when I do, I get the following error message: Login-AzureRmAccount : AADSTS70001: Application with identifier '8faf7f8-a0c2-4c03-8989-0a2d32915cd9' was not found in the directory 696c6a65-a325-4af4-bfc4-f67a88425e4b
I am 100% sure that both the Application ID and Tenant ID are correct. What am I doing wrong?
I got an error on the password, below was successful for me
$principalPassword = ConvertTo-SecureString "mypassword123" -AsPlainText -Force New-AzureRmADSpCredential -ServicePrincipalName https://domain.com/xxxxxxxxxxxxx -Password $principalPassword $applicationid ="d35a3b69-98f8-4dbb-abf8-1660ed11fadd" $psCred = New-Object System.Management.Automation.PSCredential($applicationid, $principalPassword) Add-AzureRmAccount -Credential $psCred -ServicePrincipal -TenantId 6f0ebec4-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxxxx
6 Replies
Sort By
- Hannel HazeleyIron Contributor
Hello Roy,
When you set the credential was it successful?
New-AzureRmADSpCredential -ServicePrincipalName https://mydomain.com/0f7b7873-2354-48ad-9ee4-9e6cfefd04d4 -Password "mypassword"
- Roy HochstenbachCopper Contributor
Hi Hannel,
It did not show any error message when issuing that command.
- Hannel HazeleyIron Contributor
I got an error on the password, below was successful for me
$principalPassword = ConvertTo-SecureString "mypassword123" -AsPlainText -Force New-AzureRmADSpCredential -ServicePrincipalName https://domain.com/xxxxxxxxxxxxx -Password $principalPassword $applicationid ="d35a3b69-98f8-4dbb-abf8-1660ed11fadd" $psCred = New-Object System.Management.Automation.PSCredential($applicationid, $principalPassword) Add-AzureRmAccount -Credential $psCred -ServicePrincipal -TenantId 6f0ebec4-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxxxx