Add a new user to Azure Entra External ID programmatically by C#

53 views Asked by At

We have had a C# code to create a user in Azure AD B2C per the following snippet:

var addedUser = await graphClient.Users.PostAsync(new Microsoft.Graph.Models.User
{
    GivenName = givenName,
    Surname = surname,
    DisplayName = displayName,
    UserType = "Member",
    Identities =
    [
        new ObjectIdentity()
        {
            SignInType = "emailAddress",
            Issuer = graphClientServiceSettings.Value.TenantId,
            IssuerAssignedId = request.EmailAddress
        }
    ],
    PasswordProfile = new PasswordProfile
    {
        Password = Guid.NewGuid().ToString(),
        ForceChangePasswordNextSignIn = true,
    },
    PasswordPolicies = passwordPolicies
}, cancellationToken: cancellationToken);

We want to create some users by C# in Azure External Entra ID, and the question is that whether or not this code is valid for this purpose? If so, what settings should we use for the graph services? Is there a document to walk us through the necessary steps and configurations?

0

There are 0 answers