Microsoft Graph Delta Query from Microsoft Flow: Part 3
We’re in the home stretch! If you are reading this post without reviewing the two previous posts, beware, we have covered a lot of configuration to get to this point. Make sure you’ve completed Part 1 and Part 2 before you get started on this last part. In this post we’ll add the final plumbing to use the Delta Query that we stored in SharePoint in Part 2 of the series. As I said before, this is a long detailed post, but this one brings it all home. If you get lost in the details don’t despair and don’t panic! I captured the entire flow in a single graphic at the end of this page so you can use it as a map if you get lost.
Part 1: The App, Consent, and the Plan
At this point we have the Flow working to perform the initial query, process users, and store the deltaLink
. We need to add an action to fetch the Delta Link from SharePoint (if it exists) and then process the Delta query. If SharePoint returns an empty link, the Flow path we created in Part 2 runs to generate a new deltaLink
. So, in this post, we’ll edit the Flow and add the necessary logic.
After we have the access token, we need to determine if were starting fresh without a deltaLink
, in which case we’d run the Flow from Part 2 to perform the initial query and user processing, or running a Delta Query. In this section we’ll add a condition to check the result from SharePoint and then branch accordingly.
@empty(variables('DeltaLink'))
.{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#groups(displayName,description,members)",
"@odata.deltaLink": "https://graph.microsoft.com/beta/groups/delta/?$deltatoken=rUj7-LdP8JZhP1eR4xwz8RFLB10gzqT4VuUmz2aba8tcB5NxzFGmUQgI3AlFDJJc4d9ZzgtsbBAsOodPpYW4d-mq1jGwJJxgeIx7w06Sfj1lZ3DjfrZ5LK84qT-c_5ghdwmt96DHVOrgfscS",
"@odata.nextLink": "https://graph.microsoft.com/beta/groups/delta/?$skiptoken=rUj7-LdP8JZhP1eR4xwz8RFLB10gzqT4VuUmz2aba8sDbpfE38oeFi6if63K9w1nK9VN1n4yiakdtAI8XJ_8vQUL4rbSs8El740j...",
"value": [
{
"displayName": "Spanning Protected Users",
"description": "Users protected by Spanning Backup for Office 365",
"id": "d3dd0158-a239-4417-bd75-150a16bfdc99",
"members@delta": [
{
"@odata.type": "#microsoft.graph.user",
"id": "e2e6d7ad-eb03-4466-a05c-74dee6b60b10",
"@removed": {
"reason": "deleted"
}
},
{
"@odata.type": "#microsoft.graph.user",
"id": "13af31a2-18e9-432e-bb21-c6989c85af18"
},
{
"@odata.type": "#microsoft.graph.user",
"id": "d04f8905-55e3-4be9-af52-5c4abe131989"
}
]
}
]
}
deltaLink
and nextLink
properties.@odata.nextLink
@odata.deltaLink
First(body('Parse_JSON_-_Group_Delta')?['value'])?['members@delta']
@odata.deltaLink
.OK, You have made it this far, congratulations. Before you test your Flow, clear out the DeltaLink Value field in the FlowGroupsConfiguration list item. Also delete all of the entries in the FlowGroups list. For testing we want to see two things happen. On the first run we want to see the initialization logic run. On the second and all subsequent runs we want to see the Delta logic run.
You may have noticed when we received the results from the Group request there were User objects that were tagged as removed and reason:deleted
was included in the response. When we processed the User Array we added a Condition - User Not Removed so that we could only process the “active” or “existing” users. What if you want to do something with those deleted users? You can process those users by adding Flow actions to the If no side of the Condition - User Not Removed.
Congratulations! You have done an epic amount of work to follow along with this whole post series. There is still a bit of work to be done. For example, you can get additional details about your users by making an additional Graph request for User information. I’ll show you how in a different post I have planned. For now, if you made it all the way through, you have the basics of what you need for working with Azure AD Groups and the Microsoft Graph. You can use the Save As… menu to make a copy any time you get asked for this kind of functionality. Let me know what you think about the series and post any questions. I’ll be happy to help out if I can.
Ready to start your next project with us? That’s great! Give us a call or send us an email and we will get back to you as soon as possible!
+1.512.539.0322