How can I resolve the 'Cannot find user or service principal in graph database' error when assigning a role in Azure Digital Twins using a Microsoft account email?

hwajeong lee 25 Reputation points

I'm attempting to do the Digital Twins hands-on lab from GitHub (, and I need to assign the Azure Digital Twins Data Owner permission using the following code:

plaintextCopy code
az dt role-assignment create -n $dtname -g $rgname --role "Azure Digital Twins Data Owner" --assignee $username -o json

However, when I enter this code in PowerShell, I get an error:

plaintextCopy code
Cannot find user or service principal in graph database for ''. If the assignee is an appId, make sure the corresponding service principal is created with 'az ad sp create --id'.
Unable to assign role.

How should I proceed?

Azure Digital Twins
Azure Digital Twins
An Azure platform that is used to create digital representations of real-world things, places, business processes, and people.
224 questions
Azure Role-based access control
Azure Role-based access control
An Azure service that provides fine-grained access management for Azure resources, enabling you to grant users only the rights they need to perform their jobs.
715 questions
A family of Microsoft relational database management systems designed for ease of use.
337 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sander van de Velde | MVP 31,116 Reputation points MVP

    Hello @hwajeong lee,

    welcome to this moderated Azure community forum.

    I tried the command on a Azure Digital Twins environment myself and it works as expected:

    User's image

    You need to fill in the name of the ADT environment, resource group and email address of the person

    Check if the email address is already registered within EntraID/AAD.

    Please check the actual values of $dtname etc.

    I did not need to use quotes for the values.

    I expect you performed an 'az login' already, pointing to the right subscription.

    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful