AzureMid

PrincipalNotFound when assigning a role to a new identity

A role assignment right after creating a user or service principal can fail from replication delay. Set principalType, or wait before assigning.

What you see

  • PrincipalNotFound followed by Principal {principalId} does not exist in the directory {tenantId}. Check that you have the correct principal ID. If you are creating this principal and then immediately assigning a role, this error might be related to a replication delay.

What it means

The new principal was created in one region. The role assignment can happen in another region that has not replicated it yet. So the assignment sometimes fails and sometimes works.

How to confirm the cause

  1. 1
    Confirm the principal ID is correct
    az ad sp show --id APP_OR_OBJECT_ID

    Use the matching az ad user show or az ad group show for users and groups.

Causes and fixes

  • Replication delay

    HOW TO TELL
    The ID is right, the principal was created seconds ago.
    FIX
    Set the principalType property when creating the role assignment (User needs API version 2020-03-01-preview or later; ServicePrincipal needs 2018-09-01-preview or later). In PowerShell set -ObjectType to User or ServicePrincipal. For a new group, wait a few minutes.
  • Using --assignee with a service principal that cannot read Entra ID

    HOW TO TELL
    Insufficient privileges to complete the operation when the CLI runs as a service principal.
    FIX
    Pass the object ID instead of a name so the CLI skips the Entra lookup, or give the service principal the Directory Readers role.
    az role assignment create --assignee-object-id OBJECT_ID --role "Contributor" --scope "/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP"

How to stop it coming back

  • Always set principalType in templates and pipelines that create identities and assign roles in the same run.

Keep going

Sources

Microsoft Learn (learn.microsoft.com), read 18 Nov 2026. The page's own metadata shows it was last updated 5 Nov 2026.

Search

Search cheat sheets and projects