Monday, September 11, 2017

An approach to working with Schema Extensions in the Microsoft Graph

I wrote a post last week about my issues with custom metadata and the Microsoft Graph. The week ended leaving me on the fence on which way to go. However, a couple of days off has sorted my brain a little bit, and I’ve had dialogs with the Graph team on these three Stack Overflow questions:

I think I’ve finally landed on using Schema Extensions and the approach below seems like something I can work with.

First off I’ve created an ADAL app which will be used in my service application. This application is of type Web app / API, as I’m using app-only permissions.

Creating Schema Extensions requires a user login, and I’m using the Graph Explorer for this purpose (as Microsoft fixed a bug on Friday for this). You may also add delegated permissions to your service ADAL app, but I found using the Graph Explorer easier. Below is a screenshot of a request to create a schema extension.


If you however want to code this part you need to get the bearer token using a POST to"><tenant>, with the following payload:


When creating the extension using Graph Explorer it’s important that you set you ADAL appid as the owner of the schema extension (as seen in the image above). If not creation fails.

On creation the schema will get a random prefix added to the id you specified (unless you use a verified domain) , for example extijtiwmr7_CollaborationMetadata.

Below is a sample where I have extended an Office 365 Group with GroupType set to Project in my custom scheme. The advantage with using Schema Extensions over Open Extensions is full filtering capability.


Initially the schema have a status of InDevelopement. When you are certain the fields are what you want, and have tested using the schema on your resource objects it’s time to publish the schema by setting the status to Available.


When the schema is made Available, you can no longer delete properties in the schema or the schema itself. You can only deprecate it.

When moving my solution to a production tenant I can live with the manual steps of creating the schema. In the case of a multi-tenant app, the schema will be available for all tenants once the app has been consented in the tenant – which is pretty darn cool!