In the previous blog post, you have learned about the basics of Power Platform and Microsoft Graph. In this one, we will elaborate more on Graph specifically and provide examples in the field ofeducationregardinghow to access user data. After reading this, you will get an idea about how to use Graph to work with users in MS 365 including the required permissions.
Objectives and Prerequisites
Users are the core of most operations in Microsoft 365. Microsoft Graph enables developers full control over the lifecycle of users in Microsoft 365 including creating, updating, and deleting users and listing users in the organization.
Thus,are you interested in...
How to get a list of users?
How to get details, including multi-media, of a user?
how to manage the lifecycle of a user from creation to deletion?
In order to get those objectives,you should have...
Basic knowledge of REST services & APIs
Basic knowledge of Microsoft Graph
Ability to develop with NET Core at the intermediate level
Experience using Visual Studio Code at the beginner level
Access to a Microsoft 365 tenant
However,you don't have to check all those boxes!Your interest and willingness to learn are the key. Once we go through the following demonstration process, there areadditional resourcesfor you to practice and learn more.So, let's go!
Why integrate with education scenarios?
Imagine a teacher who went to a conference and got excited about certain great applications. After she came back, the first thing she need to do is toload the list of students into the app. It doesn't sound like a fun task to do, right? It can also be kind of a barrier to entry at times when there is a large class or a lot of details needed.
This scenario doesn't only happen to teachers, but to students or education software developers who may find key pieces of information are typically locked away inside a school Student Information System (SIS). Any time teachers bring a new application into their classroom, theyspend time manually importing roster datainto the app. Time-consuming, isn't it? And here is whereGraph could come in and help.
What can you do with the Microsoft Graph user resource?
The user resource isthe gateway to resources related to a user. The user can be the currently signed-in user, or another user if your identity and application have been granted the necessary permissions.
Following are someexamples of things you can do with Graph user resources:
Manage your organizationby creating new users in your organization or updating the resources and relationships for existing users. E.g. Create or delete users in your Azure AD organization, Upload or retrieve a photo for the user, etc
Work with calendars and tasksthrough viewing, querying, and updating user calendars. E.g. Find free meeting times for a set of users, get a list of reminders set on a user's calendar, etc
Administer mail and handle contactsby configuring user mail settings and sending mail on a user's behalf. E.g. List mail messages and send new mail, retrieve and update mailbox folders and settings, etc
Gather user insights. E.g. Return documents recently viewed and modified by a user, return documents and sites trending around a user's activity, etc
Microsoft Graph also enables developers to get a list of users. The /users endpoint will return all users in the organization using the Microsoft Graph API. The following code will do the same thing using the Microsoft Graph .NET SDK:
GraphServiceClient graphClient = GetAuthenticatedGraphClient(...); var users = graphClient.Users.Request().GetAsync().Result;
Back to the case
So now after you have a basic idea about Graph's functionality, let's go back to the scenario and seehow to get a class of student info from Graph. There are two ways, build aGraph applicationor access from theGraph webpage.
To begin with, if you haven't used Graph before, developing Microsoft Graph apps requires:
A Microsoft 365 tenant. You can follow the instructions on theMicrosoft 365 Developer Programsite for obtaining a developer tenant if you don't currently have a Microsoft 365 account.
An Azure AD Application you will need to create an Azure AD application, a .NET Core console application, then finally display the currently signed-in user's details. For specific demo videos and documentations, please check it outhere.
Moreover, if you already have an account set up and have some experience with Graph. You can access it fromGraph Explore. For example, if you log in as a teacher account, you can have a look a the list of classes. by using this query:
Then, it'll return a list of class like below.
From there, you can find descriptions of the classes codes for the class you taught and other details. Then, you can copy the class ID of one of those. In the search query, put
Then, you'll get a list of members of that specific class.
As a result, you'll get information about students whose data arealways updatedsince it syncs with the school's back-end system. Pretty cool right?
Interested in learning more about Graph? We saw this ahead and prepared thefollowing resourcesfor you to explore:
Good job on reading so far! In this post, we learned what can you do with the Microsoft Graph user resource, how to access user data through Microsoft Graph in different ways, and how to use Graph to solve problems in the realm of education.