My app has a user management interface for delegated administration by users without sufficient permissions to our Azure tenant. When a new user is added to the app, we check if the user already exists in the tenant and, if not, we invite them. Something like this:
var existingUser = // Try to find the user in the graph by email
if (existingUser == null)
{
// User doesn't exist, add and get them.
var invitation = new Invitation
{
SendInvitationMessage = false,
InvitedUserEmailAddress = user.Email,
InviteRedirectUrl = _inviteSettings.AppUrl
};
await _graphClient
.Invitations
.Request()
.AddAsync(invitation);
existingUser = // Get the user from the graph by email...
}
How long should it take for the user to be available through a graph call?
I've seen it unofficially in a comment here that it could take 5 or 10 seconds. (using PowerShell so maybe unrelated?) The MS docs says:
When the user is invited, a user entity (of userType Guest) is created and can now be used to control access to resources.
Further, the response example shows the necessary properties returned from the request.
The problem though is at runtime the users are not always immediately found. Sometimes it takes two or three tries to get it to complete successfully and the time to do so has exceeded the 10 seconds referenced above.
Is it not guaranteed when the graph service call returns that the user has been added to the tenant?
Note: I updated the title from "How long should it take for the user to be available through a graph call?" as I'm more concerned about a guarantee than a typical time span.