Message="The service principal with appId '2565bd9d-da50-47d4-8b85-4c97f669dc36' could not be found in the Azure Active Directory tenant. Please retry

When creating a Domain Service instance in Azure with a Terraform template I ran into this issue, I fixed it by running the following commands:

on the Azure command line - powershell in the actual Azure portal, I tried using regular PowerShell with one set of annoying errors:

  • You must call the Connect-AzureAD cmdlet before calling any other cmdlets. 

  •  New-AzureAdServicePrincipal : Error occurred while executing NewServicePrincipal

and the commands lines I was running were:

  • Connect-AzureAD -AccountId <my account>

  • Select-AzSubscription -Subscription 'subname'

  • New-AzureAdServicePrincipal -AppId "2565bd9d-da50-47d4-8b85-4c97f669dc36"

The fix:

  1. Connect-AzureAD -accountid <the account id>

  2. New-AzureAdServicePrincipal -AppId "2565bd9d-da50-47d4-8b85-4c97f669dc36"

UPN created