azureazure-active-directoryazure-storage-accountazure-rbac

What is the principal type for user assigned managed identity


While adding role assignments for storage account I use user assigned managed identity

RoleAssignmentCreateOrUpdateContent roleData = new RoleAssignmentCreateOrUpdateContent(
   roleDefinitionId: new ResourceIdentifier(string.Concat("/subscriptions/", SubscriptionId, "/providers/Microsoft.Authorization/roleDefinitions/", roleId)),
   principalId: PrincipalId);

But I am getting an error

ERROR: {"error":{"code":"PrincipalNotFound","message":"Principal xxx does not exist in the directory xxx. 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. In this case, set the role assignment principalType property to a value, such as ServicePrincipal, User, or Group.  See https://aka.ms/docs-principaltype"}}       

It was suggested to add principaltype , what is the principal type for user assigned managed identity, user or group or serviceprincipal


Solution

  • Managed Identities use service principals so you should set the principal type to "ServicePrincipal".