This sample contains a class library that demonstrates how to assign a license to a user in real-time using the Graph API. This capability could be leveraged in a scenairo where there are large numbers of users migrating over to a new application, or as a standard automation within a companies Joiner-Mover-Leaver (JML) process.
Note
To test this class library in action, simply leverage the unit test class included with the solution, simply copy or clone this repository and update the following code snippets in the GraphAPITest.cs file.
private static string userId = "";
private static string licenseSKU = "";
and
private GraphAPI setEnvironmentInfo() {
GraphAPI graphAPI = new GraphAPI();
graphAPI.clientId = "";
graphAPI.clientSecret = "";
graphAPI.redirectUri = "";
//graphAPI.graphScopes = "/.default";
graphAPI.tenantId = "";
return graphAPI;
}
The Graph API provides a robust set of tools for managing your Azure AD environment. In this scenario there are two key steps for handling the license assignment, the assignment itself and the reprocessing of the license. The second step is what enables this scenario to be leveraged in real time, as it removes the background delay caused by waiting for the system jobs to update the license assignments.
Important
This scenario does not address the administrative refresh delay between Azure AD and Dataverse. If you need ensure that new users being created are synchronized in near-real time with Dataverse, then consider leveraging the Force Sync Azure AD Group Members to Dataverse Power Automate template