Demo - Create, update, and delete users with the Microsoft Graph
Key Takeaways
This video demonstrates how to create, update, and delete users in an organization using Microsoft Graph, with a focus on modifying an existing Azure AD app and .NET Core console app to use the necessary permissions and API calls.
Full Transcript
in this demo i'm going to modify the existing azure ad app and net core console app to use microsoft graph to both create update and delete users within my organization now this assumes that i've already created the azure ad app and net core console app from the previous demos in this module which i already have done so the first step is to go to the azure ad app and grant it a new permission so i'm going to go to our app our app registrations i'm going to find my graph console app i'm going to go to the api permissions so i want to add in a new permission it's a microsoft graph delegated permission and this is the user.read write.all and then i'll say add permissions and then i'm going to select the grant admin consent as i've done previously now once that's done let's come back over to our code and i need to find the place where i'm requesting permissions so right here user.read.all we're going to update this to say user.readright.all so i can actually make changes to it now we can go modify our code so what i'm going to do is i'm going to find the part where we're getting the authenticated client and get rid of all the other code from my previous demo now one thing i'm going to need to do with this and i'm also going to need to add a using statement so i'm going to add using system dot threading dot tasks because we're going to have an asynchronous task now the first step that we're going to do is we're going to create a user so i'm going to add in this code to create a brand new user and we need to have a function that we're going to have to define called create user async when that runs we're going to wait for it to finish creating the user and then it's going to write out the new user's id so let's go add a method to go create that user so i'm going to scroll down we'll add it right before or right after the main the main method all right so what is create user async doing is creating a new user object and specifying a little bit of information about them melissa darrow we can see her name we can see your nickname and a user profile name now one of the things i need to do is i need to also update her domain her organization domain to be equal to the same domain that we're currently working with so i'm just going to go ahead and grab the one for the current user and just sign that in using my temporary uh microsoft 365 developer tenant account so just to show that we don't already have this user already added i'm going to come over here to the users collection inside of azure id we're going to search for melissa and we don't have any melissa's listed so let's go back to our application we'll open up the console and let's go do a let's go ahead and execute the code so we'll do that by doing a net build and we need to get the entire user so we'll go log in as the current user we'll also grab the password and we'll create the user so it shows a new user was has been created so let's go back over to azure id to ensure that user was created i'll refresh the page and we'll do another search for melissa and sure enough now we see that melissa has been created so if i go ahead and open this up you can see i can scroll through and i can see some information about the current user so what i want you to notice with the new user we just created take a look at the mobile the mobile phone for melissa notice that there's no mobile phone listed for melissa darrow what we're going to do is we're going to update the code to set her pro her mobile phone number so i'm going to come back over here to the code and what i'm going to do is we're going to get a reference to the user that we just created so let's get rid of the code to create a user so now we're going to update the user so first i want to find the user that we just created so that was melissa darrow and again we need to make sure we pass in her the correct org or the domain for her we're going to get that user and then i'm going to call a method called update user async and we're going to wait for that to finish so let's go add that method for updating the user async and what we're doing is we're going to take the we're going to create a new instance of that user uh user object and we're going to pass in the mobile phone now what we're doing here we're passing in the id of the user we want to update and then we're only passing in a user object that contains the properties that we want to change so here we're only passing in the mobile phone property is the only property that i want to change so now let's go ahead and run this so do a netbuild.net run so go ahead and log in there we go it should have updated the user so let's go back over to azure id this can take a second for the mobile phone to show up so let's see how fast it happens and now we see the mobile phone has been updated with the number that we specified so it took a minute but it did actually show up that's just a propagation thing the last thing that we can do is we can delete the user so in this section we're going to update the code to delete the user that we created in the previous section so what i'm going to do is come back over to the code and in the part where we are updating the user we already have the user so what i'm going to do is we're going to pass in the code that we want to delete the user so after the user we updated them so now come over here and we'll say we'll delete them so here's the user to update we're passing in their id and we need a method here that we're going to define to delete the user and i'll do that by passing in this delete method or pasting in this delete method you can see here that in order to delete all we're doing is we're calling the delete async method on the request object that's returned and then we're going to wait for that to complete so again let's test this out i'll do a net build go ahead and log in wait for it to finish and once it's finished we'll come back over to edge and let's refresh the page and try and find our user and we can see now that the user is not found because they've been deleted if i come back over here to the dashboard for all my users or go to the users page and do a search for melissa you can see she's showing up but it's still taking a second for it to get sync but we can see that the user has actually been deleted so it's just taking a second for azure id to update the ux so in this demo you saw how we modified the existing azure ad app and the net console app and used microsoft graph to create update and delete users in the organization thank you for watching i hope you've learned something now remember that this video is part of a series of videos on this microsoft learning module this video is also part of a playlist that includes all the videos that are associated with this module so that you can watch them in order the playlist and all its included videos are associated with a microsoft learning module that includes hands-on lab exercises and additional resources check the notes for this video and the associated playlist for more information and where to find the microsoft learning module
Original Description
In this demo, you’ll learn how to create, update, and delete users in your organization and the permissions required to do these operations with Microsoft Graph.
This video is part of a series in a playlist and is associated with a Microsoft Learning module: 'Access User Data from Microsoft Graph'.
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/msgraph-access-user-data
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
📰
📰
📰
📰
Why RAM Prices Are Exploding: Inside the DRAM Shortage Fueling the AI Boom
Medium · AI
Reflection inks $1B compute deal with Nebius
TechCrunch AI
You’ve Been Working for Google for Years — And You Never Got Paid
Medium · AI
You’ve Been Working for Google for Years — And You Never Got Paid
Medium · Machine Learning
🎓
Tutor Explanation
DeepCamp AI