Is it possible to loop through all records in User Profile Service using CSOM or any other technique that will run on SharePoint Online?
I want to read all records from Azure AD (which is synced with on-premise AD) having properties such as Name, Email, Designation, Department etc. at a regular interval (for e.g. every hour) and add them in a list in SharePoint Online. Since AD records are already available in UPS so I was thinking if there is some way of looping through all records?
Or if it is possible to directly query Azure AD and read all records but that technique must run on SharePoint Online or Azure.
Can I use Azure web job to achieve this task?
As a last resort, I can create Powershell script or C# service on-premise that will fetch records from the on-premise AD and update them in a list on SharePoint Online (I hope that second part about updating SharePoint Online list using Powershell or C# is possible)
But first priority is to run everything online (SharePoint Online, Azure)
There is no direct way you can get all users from the UserProfile object. Rather, you can achieve this by using the Search API.You need to build your search query to cover all users (say for example you would add a filter to match a department, repeat the api request for each department).