>> Hello. I'm Dan Kershaw,
a program manager on the Microsoft Graph.
In this video, I'm going to give you a quick peek at
Microsoft Graph Extensibility and show you how you can
use it to extend Microsoft Graph
with your own custom app data.
So, what is the Microsoft Graph?
It's a unified REST API
and comprehensive developer experience
for integrating with data and
intelligence exposed by Microsoft services.
It lets you build rich applications that integrate
with services such as SharePoint, OneDrive,
Outlook and Teams as part of Office 365,
or manage your identities and devices using
Azure Active Directory and InTune as part of EMS,
or create applications
targeting schools and universities.
This all works whether you are
building an application for work,
school, or personal use through
a single authentication endpoint.
So, Microsoft Graph gives you access to
tons of data, relationships, and insights.
And while we're constantly growing these datasets
by adding new Microsoft cloud services,
there are ways for you to extend Graph with
your own application data by adding
custom properties to existing Graph resources.
For example, your app might want
to extend your user's profile information.
You might decide to keep your app
lightweight and store app specific user profile data
in Microsoft Graph by extending the user resource.
Alternatively, you might want to retain
your own application user's profile store and
join this to users in the Graph by adding
your app's unique identifier to user resources.
Microsoft Graph offers two mechanisms
to extend Graph with your own data.
Open extensions gives you a very simple way to add
untyped data to a resource in the Graph.
Schema extensions are a more versatile mechanism
where you define the schema to
use to extend the resource type with.
Once created, you can use the schema to extend
resource instances with strongly typed custom data.
You can also search resources
based on the element values.
Even better, your schema, if made public,
is also discoverable for other application developers
to find in use and build further experiences on top.
You should pick the extension mechanism
based on your requirements.
For example, if you need to find users based
on an extension value, use schema extensions.
But now, onto the exciting part, demos.
So, imagine I'm building an application that is available
on lots of different client platforms
on desktop and mobile.
I want my app to allow users to
configure their UI experience so it's
consistent no matter which device
they use to sign into my app.
So, how could I do that?
First, let's look at the call to get the
singed in user's profile using Graph.
Here, I'm signed in as Sarah David and I'm calling
the me endpoint to get Sarah David's user profile.
So here, we can see various different properties
of Sarah like her display name and her mobile phone.
Graph Explorer allows me
to explore Graph by making Rest API requests,
as it's conveniently named.
So now, I want to add
some roaming settings to my user profile.
So, I'm going to click on
this saved example, and in here,
you can see that I'm posting to the extensions entity.
And in here, I'm setting
various different settings for
theme, color, and language.
But I don't really speak Japanese so
I'm going to change this to
something a little more appropriate,
and I'm going to run this query and bingo, that's it.
That's all there is to storing the data.
Now, imagine that I'm retrieving
my profile record from any device.
I can get the roaming information
as part of the response by
just expanding the extension.
So here, you can see,
I have expand on the extensions property, and in here,
in the returned response,
not only do I get profile information about Sarah,
but also, I get the extension data that I just saved.
There we go. Job done.
How easy was that?
Now, we'll take a look at the other mechanism
for adding data to Graph, schema extensions.
Let's imagine, I'm a Developer in
a learning management software company called
AdatumISV that builds training courses
and materials for businesses.
Office groups with their rich collaborative experiences,
seems to be a fantastic way to deliver course
content and record exercises amongst
participants for both online courses
and instructor-like courses.
I want to make Office groups use for
training courses easily identifiable as
training courses which will allow other Developers to
build rich experiences on top of our courses.
Now, how can I make this work?
First, I'm going to show you how to
extend the group resource type with
some rich training course metadata
defined by a schema extension.
For this, I'm going back to Graph Explorer.
We're going to register a new schema extension
by posting to schemaExtensions.
Here, we're defining the name of the schema extension.
You'll notice that it's kind of name
spaced in here and it's based
off of the domain name that I have in my directory,
and I've added an additional name to it
after the domain name portion called "Learn."
So this gives it a unique identifier
and name description,
and here, I've got target types.
So target types represents
the resource types that
this schema extension will apply to.
I have an owner which is
the owner application identifier or client
ID and so this is
the application that will be
tied to the schema extension that I create,
not actually Graph Explorer.
And finally, I have the set of properties that
make up this schema extension.
So in this particular named extension,
I have an ID,
a name, and a type.
The ID's an integer type and
the other two properties are strings.
So let's run this registration
of a schema extension and there we go, as simple as that.
I've created a new schema extension
called "adatumisv_learn" and you'll notice here,
all the properties are set and I have
this new property in
the return that tells me about the status of this schema.
So schemas have a life cycle and in the life cycle,
they start off in development,
then in that case,
they're only available to other applications within
the scope of the tenant that
the application was registered in.
If you make the status available, now,
any application can discover
this schema extension and use it in any tenant,
and then we have a deprecated status if you want to,
in effect, delete your schema extension.
Okay, so I can also query for schema extensions.
So in here, I can just go
"adatumisv_learn" and I need to
change this to "GET"
and if I run the query, there you go.
I get back the same information
that I got in the response from the post.
Okay, so now, I've created
my extension and it's registered.
We can go ahead and use it.
So, now I'm going to create a new office for you.
Here, I have a standard request
and body for group creation.
So in here, we can see
the various different elements of group.
But what's new in here is,
I'm defining the custom data that I
want my application to
add based on the schema extension I just registered.
So, I'm going to create an ID,
a name for the learning which is for new managers,
and the type which is an online training course.
Okay, let's run the query.
Clean that up and run again.
Okay, and there, we have a new group created.
So, we can see,
it's got all the information
that's necessary around a group.
So now, imagine that I want
to use a different application to sign in and read
the same data and even find
all 123 training courses using
a filter request on the ID extension.
So here, I have the filter.
It's querying under my namespace and the ID,
looking for everything starting with 123,
and selecting certain properties.
So, let's run that query and there we go.
I get back the group information and the extension data
for the course that I just
created based on a group. How easy was that?
So in this video,
we've seen how you can easily
extend Microsoft Graph resources with
your own custom data using
both open and schema extensions.
These extension mechanisms are available for
both Outlook and directory resource types like messages,
calendar events, users, groups, and organization.
Try out Microsoft Graph
using Graph Explorer and extensions.
You can find the steps and the demos I just
showed in these first two links,
or try out one of our samples.
Also, we'd love to hear from you on Twitter,
or Stack Overflow, or any of our communication channels.
Please share your Graph code samples, too,
on our Graph community samples GitHub site.
Thank you for taking the time to learn about
the Microsoft Graph Extensibility with me today,
and happy coding, folks.