Demo - Use query parameters to optimize Microsoft Graph Requests
Skills:
API Design80%
Key Takeaways
Optimizes Microsoft Graph requests using query parameters such as $select, $top, and $orderby
Full Transcript
the current console application isn't efficient because it retrieves all the information about all the users in your organization but it only displays three properties so i can use a query parameter to limit the amount of information that's returned by microsoft graph to optimize that query so let's go back to our main method where we're making the request and so you can see we're making requests right here to client.users so what i'm going to do is right after this request i'm going to add in another statement here for a select statement and what that's going to allow me to do is it's going to allow me to define just the properties that i want to have returned in my query so i'll choose u dot display name and u dot mail so that's only going to fetch two properties so i can get the make the exact same request so net build followed by dot net run and we should see the exact same thing in our results because we're still displaying only the display name and the mail address but a lot more stuff or a lot fewer a lot less data is coming across in fact you can see we're making a reference to the id of the user up here on line 32 but it's not showing up because we didn't say that was one of the properties that we want to return so let's do a little bit more work with this i can limit this even further to just give me the top 15 results so i can do that by after the my select statement i can add a top query or top parameter and so when i run it this time it's only going to show me the top 15 users and here enough you can see a much smaller list of users are being returned this time now another thing that we can do is i can also have microsoft graph sort the list of users that come back so that i don't have to do that in my own code so i'm going to do that by again after the top query i'm going to use the order by and i'm going to pass in a property so i want to sort them by their display name but i want to do it in descending order so i'll say display name and ds desc so by default it's going to be an ascending order but i'm going to flip it around and say no we want it in descending order where it'd be like z through a instead of a through z so now we can see that we have that showing up for us as well now i can further refine the results by selecting users but only have a specific surname so like i only want people that have a last name of a that starts with an a a b or c now to do this what i'm going to do is i'm going to comment out our order by we're not going to use that one but i am going to add in a filter now the filter statement you're going to write this rather lengthy query here but all the query is going to be is you're really just going to say semicolon should be on the outside i'm going to say starts with surname a so what that's doing is that's saying i'm only looking for the surname property that begins with the letter a using by using the startswith operator so what i can then do is i can also add in a boolean statement here so i can see where it's or it starts with a b or it starts with a c and i'll save my changes so now let me go ahead and run this and now we can see we're getting even a smaller list because now we're only seeing people whose last names or surnames begin with the letter a b or c and so in this case we only have five users come back so in this demo you saw how i created an azure ad app and a net console app that retrieved user data from microsoft graph and then i use query parameters specifically the select top order by and f and filter to limit and manipulate the data that's returned by microsoft graph to optimize our query
Original Description
In this demo, learn how to use supported Microsoft Graph query parameters to optimize the performance of your requests, including $select, $top, and $orderby.
This video is part of a series in a playlist and is associated with a Microsoft Learning module: 'Optimize data usage when using Microsoft Graph with query parameters'.
Refer to the following URL to access the Microsoft Learning module for hands-on lab exercises and more resources:
https://docs.microsoft.com/learn/modules/optimize-data-usage
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Microsoft 365 Developer · Microsoft 365 Developer · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Adaptive Cards community call-February 2019
Microsoft 365 Developer
PowerApps community call-February 2019
Microsoft 365 Developer
Microsoft Graph community call-March 2019
Microsoft 365 Developer
Office Add ins community call-March 2019
Microsoft 365 Developer
PowerApps community call-March 2019
Microsoft 365 Developer
Microsoft Teams community call-March 2019
Microsoft 365 Developer
Using React and Office UI Fabric React Components
Microsoft 365 Developer
Build Microsoft Teams customization using SharePoint Framework
Microsoft 365 Developer
Microsoft Graph community call-April 2019
Microsoft 365 Developer
Using Change Notifications and Track Changes with Microsoft Graph
Microsoft 365 Developer
Office Add Ins community call-April 2019
Microsoft 365 Developer
Adaptive Cards community call-April 2019
Microsoft 365 Developer
Microsoft Teams community call-April 2019
Microsoft 365 Developer
Getting Started with Microsoft Graph and Application Registration
Microsoft 365 Developer
Getting Started with Microsoft Graph and the Directory API
Microsoft 365 Developer
Getting Started with Microsoft Graph and Microsoft Teams
Microsoft 365 Developer
Getting Started with Microsoft Graph Explorer
Microsoft 365 Developer
Getting Started with Microsoft Graph
Microsoft 365 Developer
Getting Started with Microsoft Graph and Mail API
Microsoft 365 Developer
Getting Started with Microsoft Graph and Office 365 Groups
Microsoft 365 Developer
Getting Started with Microsoft Graph and the Calendar API
Microsoft 365 Developer
Getting Started with the Microsoft Graph Toolkit
Microsoft 365 Developer
Getting Started with Microsoft Graph and JavaScript SDKs
Microsoft 365 Developer
Getting Started with Microsoft Graph and .NET SDKs
Microsoft 365 Developer
Discover how businesses can be more productive with Microsoft 365 integrations
Microsoft 365 Developer
Adaptive Cards community call-May 2019
Microsoft 365 Developer
Office Add-ins community call-May 2019
Microsoft 365 Developer
Why We Built on Microsoft Teams
Microsoft 365 Developer
Microsoft Teams community call-May 2019
Microsoft 365 Developer
Microsoft Graph community call-June 2019
Microsoft 365 Developer
Build Angular SPA's with Microsoft Graph - June 2019
Microsoft 365 Developer
Office Add -ins community call-June 2019
Microsoft 365 Developer
Build Android native apps with the Microsoft Graph Android SDK - June 2019
Microsoft 365 Developer
Build MVC apps with Microsoft Graph - June 2019
Microsoft 365 Developer
Authenticate and connect with Microsoft Graph - June 2019
Microsoft 365 Developer
Microsoft Graph data connect - June 2019
Microsoft 365 Developer
Change notifications with Microsoft Graph - June 2019
Microsoft 365 Developer
Build iOS native apps with the Microsoft Graph REST API - June 2019
Microsoft 365 Developer
Build Node.js Express apps with Microsoft Graph - June 2019
Microsoft 365 Developer
Smart UI with Microsoft Graph - June 2019
Microsoft 365 Developer
Leveraging the Microsoft Graph API from the SharePoint Framework - June 2019
Microsoft 365 Developer
Build UWP apps with Microsoft Graph - June 2019
Microsoft 365 Developer
Build React SPA's with Microsoft Graph - June 2019
Microsoft 365 Developer
Getting Started with Microsoft Graph and Batching
Microsoft 365 Developer
Getting Started with Microsoft Graph and Change Notifications
Microsoft 365 Developer
Getting Started with Microsoft Graph and Consent Permissions
Microsoft 365 Developer
Getting Started with Microsoft Graph and Education
Microsoft 365 Developer
Getting Started with Microsoft Graph and Financials
Microsoft 365 Developer
Getting Started with Microsoft Graph and Excel
Microsoft 365 Developer
Getting Started with Microsoft Graph and Data Connect
Microsoft 365 Developer
Getting Started with Microsoft Graph and Intune
Microsoft 365 Developer
Getting Started with Microsoft Graph and Notifications
Microsoft 365 Developer
Getting Started with Microsoft Graph and OneNote
Microsoft 365 Developer
Getting Started with Microsoft Graph and OneDrive
Microsoft 365 Developer
Getting Started with Microsoft Graph and Open Extensions
Microsoft 365 Developer
Getting Started with Microsoft Graph and Paging
Microsoft 365 Developer
Getting Started with Microsoft Graph and Schema Extensions
Microsoft 365 Developer
Getting Started with Microsoft Graph and Security API
Microsoft 365 Developer
Getting Started with Microsoft Graph and Query Parameters
Microsoft 365 Developer
Getting Started with Microsoft Graph and Reporting API
Microsoft 365 Developer
More on: API Design
View skill →Related Reads
📰
📰
📰
📰
Musk thanks Micron for chips, and builds a $55bn fab to replace it
The Next Web AI
Jensen Huang calls the AI jobs panic ‘complete nonsense’, and takes aim at his peers
The Next Web AI
IMF says Africa has to keep lights on before it can bet on AI
TechCabal
What Does Job Security Even Look Like In 2026? It Starts With Skills
Forbes Innovation
🎓
Tutor Explanation
DeepCamp AI