>> Hi, welcome to Microsoft Build 2018.
I'm Jeff Sakowicz, a Program Manager at Microsoft Graph.
In this video I'll give you
an overview of the Microsoft Graph,
Webhooks and Delta Query capabilities.
Tell you about some exciting new features
and show you how you can use
them to keep important information
up to date in your apps.
I'll start by explaining what
Microsoft Graph is to give you some context.
For the rest of the video,
I'll go over how you can use Webhooks and
Delta Query to learn about changes to data efficiently.
We'll specifically focus on
some newly available features that have been
highly requested by our developer community,
and I'll show them to you with a quick demo.
So what is the Microsoft Graph?
If I were to give it a textbook definition,
I'd say that it's a unified REST API,
and comprehensive developer
experience for integrating with
the data and intelligence exposed by Microsoft services.
But what does this actually mean?
Microsoft Graph is your one stop shop for accessing data,
relationships, and insights across Microsoft 365.
It's a REST API that
lets you build rich applications that
integrate with services used by
over 100 million active users.
These services include Azure Active Directory,
SharePoint, OneDrive, Outlook, Teams,
Intune, Windows and more.
There's also some exciting new security APIs and
even APIs built specifically for the education space.
All in all, there are over eight trillion resources
available in Microsoft Graph.
Now let's talk about Webhooks.
This capability allows Web apps to subscribe to
push notifications for Microsoft Graph resources.
They can be used to inform the app about created,
updated or deleted entities in the Graph.
These notifications are just a poke,
they don't contain any data.
So after getting notified,
your application should call back to
the graph to see exactly what has changed.
We'll talk about how Delta Query
fits in this picture in just a moment.
I'm very excited to announce
that Webhook subscriptions for
Azure AD users in groups are now
available in the Microsoft Graph V1 endpoint.
Meaning that they're ready for use
in production applications today.
Another cool addition to Webhooks,
is the new list subscription API,
which allows developers to see what
Webhooks subscriptions have been created by their apps.
In certain scenarios an app might need to see
all the subscriptions that have been created for
a given user or organization.
We have a new permission that apps can request in order
to do this, subscription.read.org.
This is especially useful
in audit and compliance situations,
but keep in mind this permission is highly privileged.
It requires admin consent and only should be requested
if absolutely necessary in a given scenario.
And likewise, administered only
granted if they really trust the app.
Now let's talk about Delta Query.
This capability enables applications
to discover newly created,
updated or deleted entities without
performing a full read with every request.
It's basically a Get Changes API.
Applications with local data stores can use
Delta Query to officially
synchronize data with Microsoft Graph.
Stateless apps without local data stores
can also take advantage of it by
using it to perform simple change
tracking on the resources they're interested in.
We also have some great new capabilities
available for Delta Query.
This includes the ability to track changes to
specific Azure AD users and groups using the V1 endpoint,
instead of all users and groups in the entire tenant.
As far as preview features go,
Delta Query can now be used for planner entities on
the Beta endpoint and clients using Delta Query
with Azure AD resources can use
token equals latest to ask for
a Delta token only without having to parse
through the entire payload of results first.
All right, now let's jump into some demos.
All right, so now let's take a look at what
Delta Query and Webhooks
look like when they're used together.
So imagine you're building
a workflow that monitors for when users
leave the sales department in
order to assign their open sales lead to their managers.
So I'm here in Graph Explorer and
I'm going to kick this off using Delta Query.
So I could just tack on slash
Delta to the end of my normal slash user's query,
but in this case I'm going to use
some query parameters to just
get back the data I actually care about.
So first things first. I'm only
going to go back the department
because this is the only attribute that I
care about whether it's changed.
I'm also going to use a filter here and just
track changes for two users that
I know are currently in the sales department.
This will avoid me having to deal with responses I don't
care about for when users in
the rest of the organization change.
So let's go ahead and run this query
and see what we get back. All right.
So we get back two users
who are in the sales department and we get
back a Next link which
means there might be some more data to be retrieved.
Let's use the Next link.
In this case there is no more data.
I've reached the end of my pages but I do get
a Delta link letting me know basically this
is my sync token that I'm going to keep
and use when I actually want to go get
some changes when I know something's changed,
all right,
or when I want to check if something's changed.
So now I'm going to come over here and let's
actually get some change data that we can track.
So I'm going to come over here to Alex's profile,
and we're going to update
his department from sales to marketing,
and we are going to save it.
Okay. So at this point,
if I was only using Delta Query,
I would actually- I'd have to make a hard choice.
I would either have to be polling constantly
in the background to learn about this change,
and risk getting back a ton of
empty responses saying that
there's nothing that has been changed,
and burn up resources that I don't need to use.
Or I could poll very
infrequently and risk having
out-of-date data in my application.
But now since we've got Webhooks
ready for use in production,
I don't have to make this hard choice.
I can have the best of both worlds.
I can wait for Webhooks to
let me know that something's changed and
come back and actually get
the change data with Delta Query.
Okay. So I've got the sample running
here which already has created a subscription for me,
and what's going to happen is when there's
a change to a user object that I care about,
I'm going to get a push notification sent to
an endpoint that's associated with an Azure function.
And that Azure function is going to
drop the notification into a queue,
and then I'm using this Azure Web jobs
STK to monitor
that Azure queue for incoming notifications.
As you can see here,
I'm hitting the V1 endpoint to create my subscription,
and I am tracking changes to users,
and I'm looking for updates in the leads specifically.
So let's see if we've got
some change data. All right, there we go.
So here we can see we have a user
with a specific object ID that has been updated.
So this would let me know it's time to use my Delta
token and run Delta Query to see what's actually changed.
So it's popped back over to Graph
Explorer and I'm going to
use my Delta token I received last time,
and there we go, there's
Alex object ID and we can see his new department is
marketing and we can go ahead and automatically
assign all those open sales leads to Alex's manager.
In this video, you've seen how you can use Delta query to
synchronize data or track changes
to various resources of Microsoft Graph.
You've also seen how Webhooks can be used to
get push notifications when data changes,
and how these two capabilities work better together.
We've also talked about
some great new features that make
these capabilities even more useful.
To learn more including supported entities and queries,
please check out our documentation at
graph.Microsoft.com and try all
of our samples on GitHub
including the one I showed today.
Tell us about what you're working on Twitter,
and ask us any questions you have on
Stack Overflow using the Microsoft Graph tag.
Thanks for taking the time to learn about
Microsoft Graph Delta Query and Web host with me today.