Demo - Use query parameters to optimize Microsoft Graph Requests

Microsoft 365 Developer · Intermediate ·📰 AI News & Updates ·4y ago
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 Adaptive Cards community call-February 2019
Adaptive Cards community call-February 2019
Microsoft 365 Developer
2 PowerApps community call-February 2019
PowerApps community call-February 2019
Microsoft 365 Developer
3 Microsoft Graph community call-March 2019
Microsoft Graph community call-March 2019
Microsoft 365 Developer
4 Office Add ins community call-March 2019
Office Add ins community call-March 2019
Microsoft 365 Developer
5 PowerApps community call-March 2019
PowerApps community call-March 2019
Microsoft 365 Developer
6 Microsoft Teams community call-March 2019
Microsoft Teams community call-March 2019
Microsoft 365 Developer
7 Using React and Office UI Fabric React Components
Using React and Office UI Fabric React Components
Microsoft 365 Developer
8 Build Microsoft Teams customization using SharePoint Framework
Build Microsoft Teams customization using SharePoint Framework
Microsoft 365 Developer
9 Microsoft Graph community call-April 2019
Microsoft Graph community call-April 2019
Microsoft 365 Developer
10 Using Change Notifications and Track Changes with Microsoft Graph
Using Change Notifications and Track Changes with Microsoft Graph
Microsoft 365 Developer
11 Office Add Ins community call-April 2019
Office Add Ins community call-April 2019
Microsoft 365 Developer
12 Adaptive Cards community call-April 2019
Adaptive Cards community call-April 2019
Microsoft 365 Developer
13 Microsoft Teams community call-April 2019
Microsoft Teams community call-April 2019
Microsoft 365 Developer
14 Getting Started with Microsoft Graph and Application Registration
Getting Started with Microsoft Graph and Application Registration
Microsoft 365 Developer
15 Getting Started with Microsoft Graph and the Directory API
Getting Started with Microsoft Graph and the Directory API
Microsoft 365 Developer
16 Getting Started with Microsoft Graph and Microsoft Teams
Getting Started with Microsoft Graph and Microsoft Teams
Microsoft 365 Developer
17 Getting Started with Microsoft Graph Explorer
Getting Started with Microsoft Graph Explorer
Microsoft 365 Developer
18 Getting Started with Microsoft Graph
Getting Started with Microsoft Graph
Microsoft 365 Developer
19 Getting Started with Microsoft Graph and Mail API
Getting Started with Microsoft Graph and Mail API
Microsoft 365 Developer
20 Getting Started with Microsoft Graph and Office 365 Groups
Getting Started with Microsoft Graph and Office 365 Groups
Microsoft 365 Developer
21 Getting Started with Microsoft Graph and the Calendar API
Getting Started with Microsoft Graph and the Calendar API
Microsoft 365 Developer
22 Getting Started with the Microsoft Graph Toolkit
Getting Started with the Microsoft Graph Toolkit
Microsoft 365 Developer
23 Getting Started with Microsoft Graph and JavaScript SDKs
Getting Started with Microsoft Graph and JavaScript SDKs
Microsoft 365 Developer
24 Getting Started with Microsoft Graph and .NET SDKs
Getting Started with Microsoft Graph and .NET SDKs
Microsoft 365 Developer
25 Discover how businesses can be more productive with Microsoft 365 integrations
Discover how businesses can be more productive with Microsoft 365 integrations
Microsoft 365 Developer
26 Adaptive Cards community call-May 2019
Adaptive Cards community call-May 2019
Microsoft 365 Developer
27 Office Add-ins community call-May 2019
Office Add-ins community call-May 2019
Microsoft 365 Developer
28 Why We Built on Microsoft Teams
Why We Built on Microsoft Teams
Microsoft 365 Developer
29 Microsoft Teams community call-May 2019
Microsoft Teams community call-May 2019
Microsoft 365 Developer
30 Microsoft Graph community call-June 2019
Microsoft Graph community call-June 2019
Microsoft 365 Developer
31 Build Angular SPA's with Microsoft Graph - June 2019
Build Angular SPA's with Microsoft Graph - June 2019
Microsoft 365 Developer
32 Office Add -ins community call-June 2019
Office Add -ins community call-June 2019
Microsoft 365 Developer
33 Build Android native apps with the Microsoft Graph Android SDK - June 2019
Build Android native apps with the Microsoft Graph Android SDK - June 2019
Microsoft 365 Developer
34 Build MVC apps with Microsoft Graph - June 2019
Build MVC apps with Microsoft Graph - June 2019
Microsoft 365 Developer
35 Authenticate and connect with Microsoft Graph - June 2019
Authenticate and connect with Microsoft Graph - June 2019
Microsoft 365 Developer
36 Microsoft Graph data connect - June 2019
Microsoft Graph data connect - June 2019
Microsoft 365 Developer
37 Change notifications with Microsoft Graph - June 2019
Change notifications with Microsoft Graph - June 2019
Microsoft 365 Developer
38 Build iOS native apps with the Microsoft Graph REST API - June 2019
Build iOS native apps with the Microsoft Graph REST API - June 2019
Microsoft 365 Developer
39 Build Node.js Express apps with Microsoft Graph - June 2019
Build Node.js Express apps with Microsoft Graph - June 2019
Microsoft 365 Developer
40 Smart UI with Microsoft Graph - June 2019
Smart UI with Microsoft Graph - June 2019
Microsoft 365 Developer
41 Leveraging the Microsoft Graph API from the SharePoint Framework - June 2019
Leveraging the Microsoft Graph API from the SharePoint Framework - June 2019
Microsoft 365 Developer
42 Build UWP apps with Microsoft Graph - June 2019
Build UWP apps with Microsoft Graph - June 2019
Microsoft 365 Developer
43 Build React SPA's with Microsoft Graph - June 2019
Build React SPA's with Microsoft Graph - June 2019
Microsoft 365 Developer
44 Getting Started with Microsoft Graph and Batching
Getting Started with Microsoft Graph and Batching
Microsoft 365 Developer
45 Getting Started with Microsoft Graph and Change Notifications
Getting Started with Microsoft Graph and Change Notifications
Microsoft 365 Developer
46 Getting Started with Microsoft Graph and Consent Permissions
Getting Started with Microsoft Graph and Consent Permissions
Microsoft 365 Developer
47 Getting Started with Microsoft Graph and Education
Getting Started with Microsoft Graph and Education
Microsoft 365 Developer
48 Getting Started with Microsoft Graph and Financials
Getting Started with Microsoft Graph and Financials
Microsoft 365 Developer
49 Getting Started with Microsoft Graph and Excel
Getting Started with Microsoft Graph and Excel
Microsoft 365 Developer
50 Getting Started with Microsoft Graph and Data Connect
Getting Started with Microsoft Graph and Data Connect
Microsoft 365 Developer
51 Getting Started with Microsoft Graph and Intune
Getting Started with Microsoft Graph and Intune
Microsoft 365 Developer
52 Getting Started with Microsoft Graph and Notifications
Getting Started with Microsoft Graph and Notifications
Microsoft 365 Developer
53 Getting Started with Microsoft Graph and OneNote
Getting Started with Microsoft Graph and OneNote
Microsoft 365 Developer
54 Getting Started with Microsoft Graph and OneDrive
Getting Started with Microsoft Graph and OneDrive
Microsoft 365 Developer
55 Getting Started with Microsoft Graph and Open Extensions
Getting Started with Microsoft Graph and Open Extensions
Microsoft 365 Developer
56 Getting Started with Microsoft Graph and Paging
Getting Started with Microsoft Graph and Paging
Microsoft 365 Developer
57 Getting Started with Microsoft Graph and Schema Extensions
Getting Started with Microsoft Graph and Schema Extensions
Microsoft 365 Developer
58 Getting Started with Microsoft Graph and Security API
Getting Started with Microsoft Graph and Security API
Microsoft 365 Developer
59 Getting Started with Microsoft Graph and Query Parameters
Getting Started with Microsoft Graph and Query Parameters
Microsoft 365 Developer
60 Getting Started with Microsoft Graph and Reporting API
Getting Started with Microsoft Graph and Reporting API
Microsoft 365 Developer

Related Reads

📰
Musk thanks Micron for chips, and builds a $55bn fab to replace it
Elon Musk thanks Micron for providing Tesla with a significant allocation of memory chips, highlighting the scarcity of this crucial component in the AI boom
The Next Web AI
📰
Jensen Huang calls the AI jobs panic ‘complete nonsense’, and takes aim at his peers
Nvidia CEO Jensen Huang dismisses AI job replacement panic as 'complete nonsense', offering a contrasting view to his peers
The Next Web AI
📰
IMF says Africa has to keep lights on before it can bet on AI
Africa's AI ambitions are hindered by unreliable electricity, highlighting the need for basic infrastructure before investing in AI
TechCabal
📰
What Does Job Security Even Look Like In 2026? It Starts With Skills
Job security in 2026 requires adapting to AI and economic uncertainty by acquiring in-demand skills
Forbes Innovation
Up next
Claude's Small Business Plugin: 31 Workflows You Can Run Today
Kevin Farugia AI Automation
Watch →