Automate business processes with Microsoft Graph and Azure Functions | B108
Welcome. Welcome welcome topless, join us the Microsoft, graph Azure fun as we marry those two things together, you. Saw it talked a little bit about before as your functions you saw how those work we're now where it's time to actually see how you can become productive and Demetri and I of today I'm Lewis Mariska we're gonna go through a lot of this stuff and how we can marry those two things together and become really productive so. Let's go do storytime now you know what's, what's one of the hardest things you can do today when you're actually building out a service well, one thing is I need to figure out where I'm gonna get the data where, am I gonna get the data all these different heterogeneous endpoints, that I need to get data from I need to figure out how to do that how. I'm gonna create, it all together right, business logic around it but then also where am I going to where am I gonna host this thing where we're gonna put it out there how am I going to integrate it together how am I going to scale it these. Are things that are very hard and complex to do today and. Even when you're using cloud services and VMs to figure, it out you, know so why I entered the business I got, to cut the advantage of really kind of doing very simple utilities. Simple, used services, I didn't really have to build out and really kind of a local audience more than a kind of a global scalable, audience and so, I didn't really have to figure out how to do all these things but. As I kind of moved across and different companies and different jobs I got, the opportunity to build bigger and better things and even when I met Dimitri we got this kind of idea, the ability to essentially, build bigger services, where. We had to figure things out like how are we going to get the data for our services, how are we going to scale it out what, services and machines are we're going to put it on how. Are we going to integrate them together and. We want to really show you how to get there and how to make it easier because one of the things that we had a problem with years. Ago is that we had a customer, come in or you, know a person to come in and say hey we want you to build this really kind of scalable, system for us we want the ability for our Salesforce to really be, productive and be communicative across the across the van and be able to talk to our customers and be to integrate with our customers and the, only way for them to do that is to be signaled, and.
And And whether that from their correspondence, that's coming into to, the service whether. They're sending an email about a particular account or their sale they. Want to make sure the entire sales team is also Salesforce, was was in sync and alerted. And really. The only way to do that is to really build a scalable service, to do it so, Dimitri I kind of got to work and we kind of we, first started with a prototype we start out with one single box weather eather was hosted it was in a data center we. Built this very simple service that, allowed us to, essentially, call into an email service we had to find the end point for that week old in there we thought we got the data for the particular email for every mailbox that we're on a track and then we pulled the emails in and then from there we were able to extract a little bit information about the sender and. Then from there we were label that it called the third-party service and so we kind of figured out what the business logic was but, we didn't really have to deal, with the scalability, side of things so that was kind of the key is we kind of stayed very simple when, we were experimenting. Or architecting, it but, then we found out that this wasn't going to scale and what we've what, we noticed is in reality, we were gonna have to scale it out so then we started scaling it to multiple different machines we, actually created a current cron service or a polling service that, periodically, woke, up and checked different mailboxes, for data and again that's that's kind of difficult to scale because you know more mailboxes come in the more email comes in the more you have to actually scale the service and so that becomes a very difficult way, to actually architect, the system in. Reality, what ended up coming up was this is kind of what the design we had the architecture we had we had to start to scale out the server's even more because now you know the more email. Boxes that we were managing the, more customers, that were writing. In and the. More back-end, that we had to store the data we had to talk to our third-party system around whether the contacts were being tracked or not and. Again we had to talk to the email server and bring, that data and so and again we periodically, woke up and so that's not a deterministic. Thing to be able to wake up so often the more email you get the, the more times you have to wake up the longer time it takes to compute and process and again it's very hard to figure out that scale factor, that algorithm for scaling out and again, we were doing this all on physical hardware, so. You know this, is me I'm a little older a little wiser Dimitri didn't get old he's he's still young and at, age but I think for me I got older I got and he, got wiser at the same sense but I just, had to get a little older and for, me I now, they have better technologies, we have better ways to do this where, we could essentially merge, things together we have the graph and we're gonna meet you is going to talk a lot about the graph today where you essentially have one single place one single endpoint for us to go to pull that data that we need the really rich set of data the relationships, that we have with that data and not.
Only To have to get enough, if I want to data for my email my contacts, my, appointments, everything comes from a single endpoint and then, we can bring that into a rich compute, zone, a service technology, as your functions and allows us to to trigger off events, allows, us to scale based. Off of when there's things when there's traffic not necessarily, having to waste time when, I'm doing things like, polling. And Kron functions, not, definitely not a really easy way to scale and I can trigger and do things and do rich business logic and workflows just by kind of marrying those things together we're going to get into that. You, know also we you know you could always go back to the same architecture well as well we'll talk a little bit about as your functions a little bit you've already heard about it but we want to talk about how there's, special, templates, and bindings that deal, with the graph and how you can also still, do things like timing functions, and as. Well as cron functions that kind of spin up and and. An aggregate data and do processing for you. So. We're, going to talk about the powerful of powerfulness. Of the togetherness of these things we're gonna talk a little bit about how, you know an IT pros, scenario a very simple scenario that could actually be something you could turn into a big workflow, and how those kind of marry together with graph and as your functions as well, we're gonna go a little bit into that sail scenario that we talked about in the beginning and how we can potentially build, out a really, great demo a really, great scenario, in just a small amount of time a small amount of code and not have to really worry about the scalability. And where I'm hosting it so. While further ado Dimitri's, gonna go with what we have next sure. Thanks Lois so, today, we'll be going over Microsoft. Graph and what you can do with the graph as. Your functions, and, how to use them and then putting those two technologies, together build, really powerful business, automation after. That we'll discuss some the next steps and where you can go from there. So let's dive into Microsoft, graph you, might be asking what is the graph in short. Microsoft. Graph is the API for the Microsoft cloud with. It you can access data across. A broad. Spectrum of Microsoft services SharePoint. Active, Directory exchange. And many more and. Not, only can you access the data you. Can see how the data is interconnected as you, can see here each, resource, from, across these services has, different edges to other resources you can, explore each, edge and traverse the graph to, pull in rich context, you can do things like given, a user figure. Out who their manager is or groups, are a part of you. Can go beyond just data and, relationships. And you can get, a sense of what that data and, those relationships really mean with. Insights, API is like, people.
See That I get back Megan Bowen and from. There I can make some of those requests I just showed you so I can say, I want to fetch my, manager and, there's the pen manager and I fetch another. User and please. Note that the properties on both of these users are exactly the same a user, is a user. And I, can do other things with a given user I can fetch the, groups they're part of by just querying member of. And I can see all the groups that they play a role in. One, of the other really important things for organizations, in building business applications, is email email. Is really the lifeblood of a, lot of applications, and. Big, companies so, I can query my messages by making a simple request and, I can get back. All. Of my email and you can see here I have the subject, line I have a preview of the body I even, have a flag to tell me if it's been read and I. Can do querying over these emails so I can say not, only do I want these messages I want specifically. Messages. That I've read. So I can say I want to filter on is, read equals true. I get back a subset, of my emails that, I've already read so, my app can request, data. That's really contextual, and specific to their use, cases versus, getting tons of data back and having to filter it themselves and that. Can go further and I can go beyond just whether, I read the mail and that can depend, whether. The mail contains a, given, string so for instance if the, subject contains marketing, I want, to pull that in and that's as simple as appending, and contains, subject, marketing. Run. That query and I can see here. You can see here that. Have email. That's called evolving, our online. Marketing materials, so. I can really request exactly, the data I want now. Let's kind of pop back up and see. What's available other, than the current user so. I go to groups I can. Query for all the groups available in the work. Let's. Take one of these groups and just copy out their ID let's. Kind of dive deeper. So by appending this ID to the group's collection I inquire, for just that group and here. I see information. About who the what the group is it's, email the. The configuration. Of the group and then I can append members. To, get back to who's, a part of the group so. Now I've pulled in the group from both the. Side of the user and I've pulled in the user from the side of the groups so, as you can see you can really traverse these, relationships, built ways. One of the really cool things groups has is threads. These conversation, threads can be queried by just appending threads. And I get back pretty, good amount of data so, get back a preview, that's it, looks like there's a meeting that's better be set up when, you've got higher education, and if. I'm really interested in these threads I, can. Query, for all of them but, if a billion application, I only really need some of them for. Instance a react app where I only render three components. At a time I really, need to trim, down the information I get back because I can't make use of all of it I can. Do that by just appending, top. And specifying. The number of items I want to see so, in this case I just want the top three items and graph. Does that for me so it gives me back just three items and from. There I can, also get a page for the next set of three items so, graph is really smart about giving you that next link do we you're doing this all without even logging in tree just this is just a great tool to be able to get go out there and test it without a beat yeah well I gotta go that's right all this data is in the sample tenant so you can just make these requests, no, configuration required no coding and required really, powerful stuff. Let's. Jump through some of the intelligence API so I think these are really cool and really showcase the, power of graph so. I can type in me as is it before now, I can go to people as you. Notice I'm typing people, after me so, this is fetching people, in the, context, of a user so, these are the people that are uniquely relevant to me based. On my interactions, so that's emails I've sent meetings.
I've Been in with other people all. That data gets pushed, back as signals to give me ranking of who's, most relevant to me so. As I scroll through this I can, see that each user. Or each person. Has a relevant score and I. Can sort, these, people and build really smart business. Solutions like smart, people pickers that, have the, most likely people you're going to contact show, up first. The other intelligence. EAP I want to showcase is on the beta end point and it's called, insights. Trending. And. This is, gives you back what files are most popular in your organization, and. You can use this to power really intelligent, business applications. That, show you what's what's, most popular and, you, can really make use of the, files that your users think are important, and relevant you, can leverage that to Europe for your own use. Some. Of the really cool api's are, available. On beta, one. Of the really interesting ones requires, me to sign in so I'll do that with my personal account and this. One is called project realm and this is a Windows API. That. Makes. It simple. To query, the devices I'm signed into. And send, requests to those devices. So. As I sign-in. A personal account so this is not, a worker, school account and off. The works just, as you expect it to work this, is the other point I want to reiterate you, can build graph applications, that do that. Make calls, to the different, end points the. Same way for personal, accounts as well as work in school accounts it's, really cool, stuff jumping. Into beta. I can query for me slash devices. And. This will give me a list of the devices I'm currently logged into and. I scroll down here I can see three computers I have the. First all, the way down here this is my work what's, my workstation so this is a desktop. In my office the, next one is my personal computer I see, both of these are offline I see, that there is a surface book that's online which, happens to be the current computer I'm sign-in to I, can. Grab the ID here. Copy. That in and then. I can. Get, just that device oops. And, I. Can send it a command. So one, second let me fix this so. I can create a request to. Do something on this device so. Using the REST API I can specify that. I want to launch a URI on this, device then sign into. And then I provide a payload which, in this case is a JSON object that. Contains more information about that URI, so. I want to open one of my favorite web sites and that's. Graph. Graph. Down, Microsoft, calm it. Sounds to be the same website and sign into right now but, what would I run this query you'll, actually open, the. Graph website on this, computer even though this, could be a computer that I'm not a sign into in this case it's the same computer but. When I run this I give. It a second and it opens up graphed on Microsoft calm it's, really cool stuff and to. Show you that I'm not just doing this. Client-side. Freaking, us tricking, you I, can switch this out and waving to Bing calm I could run that again and this will go too big not calm. It's really cool about this is you can use it to do things like if, you have an application to plays video you can send context, from, your phone to. Your, desktop as you come home and keep, that video playing so you build really continuous, experiences, across devices so.
That's What it's a really cool API is available in beta there's. A couple other ones I want to show you, one. Is extensions. So. Every. Organization has a lot of data that's, specific, to their line of business and. This. Data often gets stored in a database and that requires you to spin up a, new. Database set, up the credentials, keep, it in sync with Active Directory for, instance so, if you have something very specific about a user such. As, your. Internal, user, ID or maybe their, favorite color anything. Like that you, have to set, it set the database and keep them in sync and it's kind of a huge hassle instead. With, graph you can extend that directly, on to the user entity and persist. It on art, on our end so you have all your data consolidated into one place so. I can query from me slash extensions, I can. See some oops I meant. To do a query there. What's, funny is I actually wrote an extension, when I just did that I wanted me to post I wrote a new extension called type. Launched URI which was the payload to the other request, but, here I can also see that persistent one called favorite color is green and when. I query the user back I can even say I want. Back you know maybe their ID and their. Favorite color. And I want to expand on extensions, and I, get back oops. Not, only the user. Whoops. Not. Only the user but also their extensions so I can, use this to when, I fetch back the user to get a favorite, color and Bill, solutions around that so. This is a really powerful way to keep your data in one place if you have roaming settings a great way to put those directly. Into onto the the, data models that they represent so Demetri the. Service, is actually the aggregator service as part of the graph is is aggregating, data for, you so when you call in to it and kind of its kind of traversing, the graph for you and pulling things together is there a way to see that here in the graph Explorer where you can kind of see how that's going on yeah there is so this is one of the really cool things about graph I'll, just sign out for this because one of these, requires. There. Are some things that require organizational. Accounts in, this case I'm going to create something that's available from SharePoint but. I'm gonna make a request where I'm going to ask for the user and. I'm going to ask for two things I'm. Gonna select. Their. Display name and their. About me which is a little bio of who that person is and then I'm. Going to specify what. If and. So. The declaration I want to see what's actually happening under the hood and.
Here I see what the graph stars is doing under the hood so this is a cool way to sort of see, what's happening behind the scenes this, case I see that's making two requests, and merging, back together the, entity responses, in, this case it's making a request to. An actor directory API to get my display name and it's, making a request to a SharePoint API. To, get my about me and. All that complexities, being handled by the service not, my application, that's one of the really powerful things about graph. Jumping back to where. We're, working on and, if you can't see that we know, the fonts a little smaller yeah go out right now go out to a kms. And. That's take you directly to the graphics port we want to see all that traffic coming in so go right now check, it out and, start the demo do those the commands that we were showing you you, know go back in the video try the command enough to see how the service is aggregating, you'll really start to see the power of the graph and how not only performance, it is but, how easy it is to use thanks. Luis. So, the other point I wanted to touch on is the. Graph is growing in, the past year we've seen a lot of new api's come on and we're, seeing the momentum really continue. So, we have cool api's, like I just showed the project Rome API is query. Users sign in devices, we. Have in beta we have the ability to manage. Devices, and such compliance, policies an enterprise. Scale within tune teams. EP eyes organizational. Insights like how, much Skype for business users. Are we getting in our org all that's available in beta so, we really encourage, you to check out beta see, all the cool stuff that's coming in now, let's look at our change log and get, a sense of exactly what's come, in a certain point. So, I'm gonna hand it back over to Luis who's gonna walk us through our functions, and how they complete the picture of, how graph and Azure.
Functions Work together to. Build smarter, business applications, mitri. So we have the really cool stuff was going on the graph I mean essentially, you have a single endpoint that you can call and get really rich sets of data not, only machine, learning insights. But also information, about any entity, within the system and how they relate together using, really easy tools Dimitri showed you graphics for such a cool tool to be able to kind of go in and just try things out experiment. Create. A really rich environment, for you now let's get in the answer functions they know they encourage, you to go check out all the other sessions about Azure functions because it's just a really cool environment to work in but what we want to go to is just give you a really high level and kind of work you through on how graph, kind of relates to it so, what, is surrealists oh you've probably heard about Azure functions, and what service, is and essentially. It's just allowing you to really worry. About what's important, you know what's important to you as a developer, is to build out the rich business, logic the rich like a secret sauce that you want to put in there you really worry your time on what that logic does and how it works just. Like as Dimitri, pointed out you know using the SDKs, and getting up and running really fast and we really just worrying about your logic right and worry about where you're getting the data and how you're gonna get it in a different ways to different schemas the different API is and all that stuff it's, just really worrying about what's important, and this is really what as your functions is and you'll see how that kind of marries really well with the graph and. Again it's a way for you to distract servers away so, you're not not worrying about infrastructure, where I'm hosting, it not. Worrying about the OS, or the infrastructure, that goes along with it or the platform I'm just worrying about what. I'm writing how, I'm writing it where I'm getting my data and what I'm doing with it it's, also about inventing you know what I can do at. A really instant, scale you know as the system kind of like spins, up and I'm running. Off events whether it's web hooks or it's triggers, like HTTP, triggers, you, know whatever I'm doing I can do it off events I can process data I can compute things I can you know run analysis, just, by using as as your functions and of course there's also micro building there's a subset of building you only are build for what you use so, the coolest thing about this is you, know you might have to spin up a big long server that kind of runs maybe it's co-located, it's kind of sitting out there you're paying for being there no matter if you're using it or not really, the great thing about hazard function is you put your data in there you're about your business logic and you just start you run it and for however long you compute, you, basically pay for that so that's kind of the really the power of, as. Your, functions and. Again like I said it's really kind of three things so, it's you know the ability to have triggers events, so you're basically firing, things and in triggering as your functions to run it's it's compute, but. It's also the bindings of the data so you have input bindings, you have the ability to automatically.
Input Data from different places they allow you to declaratively. Define, where, your data is coming from many different cases whether it's you know queues or or in, this case and we're gonna show you graph and. How we can get data from graph really easily and also output data okay. We, also do logic, so that essentially, it's the logic of the application where. That's your writing so you know you could write very rich complex, workflows, that could compete up to ten minutes and they, really, can be a rich environment for your workload and you can almost build these kind of you know building, blocks, Domino. Kind of things where you kind of build them together and lego, blake building blocks to essentially build them together and. You. Know build up my core services so it really kind of a powerful thing so. We talked a little bit about you know in the beginning how i we, hadn't kind of a cron. Service a timer service that kind of runs well you know as your function it has this capability as well it's ways of triggering the function you can set it up to be a specific, schedule it, can trigger and go pull out data from anywhere whether. It's using the bindings that we already have or calling into a separate service to do that again. Maybe, became even calling into graph to get your data you. Could do things like cleaning cleansing data you, can go and process the data run analytics on it pass, it to our set of workloads, or workflows really. Whatever you want to do the admin function can do it again, declare, ee you can set up a set of bindings that can pull the data automatically, or you can write this service or write to a service that actually has your data there's. Also event-driven, so like for instance whether it's a web hook trigger it's from github or, from any other location, that has web hooks you can hook these things up to basically process, and in trigger a as. Your function and the key here is you know now with Microsoft, graph bindings. We have this really great capability. Of, binding. To a set of events this case a change to a workbook, in Excel, we, can try off that function, when it's saved and we can think they'll process the data we can go and do an analysis, on it we can create insights off of it we can signal people whether based off that data we could do a whole bunch of things that we can do that we couldn't do before, that when we didn't have those triggers and that capability of we're just ready business subject and again it it lets you care about what, you want to do so, if I wanted to go an experiment, to figure out hey you know what you know we're just having a spreadsheets sit out there is not really doing a former I need to do something else with it and this really gives you the power to do it. So. Again what we talked about parts, of the function is just as triggers, its bindings, its input and output and of course the logic and you just really let you kind of focus on what, you want to do with the data so if I wanted to go and experiment, today spinning. Up as your functions portal and just going in there and creating a really quick trigger function, like an HTTP trigger and there's a writing code in there you know building the demos that we did it was really fast and easy for us to do that and it, didn't really require too much trouble we didn't have to install viscious to it if you didn't want to you, can but, you don't have to to do that so to kind of get up and running it experimenting.
So. Like when do when do you really want to use functions, so there's there's lots of different obviously ways, to do it you know I'm not gonna even pretend to try to give you all the different ways you could probably use functions but, again you know a lot of times like for instance example that I gave in the beginning when you know email kind of off-peak times it goes down on peak, times it goes up so you want to be able to scale the service based off of you, know whenever there's more. Events than not and so that's really kind of when you have a bunch of sporadic, load in your system you want to be able to scale it in and out and that's what as your function is let you do but, also let you data transform, so if you have really complex, data transformations, that you want to do maybe, it's aggregations. For other places maybe it's not this is a way to do that also isolation. So you can do micro services you can do building blocks you can do piecing together and again each piece having really complex logic. So. Graph functions we're gonna show you a couple demos here and some of the code we're gonna get deep and dive in that and this gives you the ability to again the work off triggers just like mail you. Know when a mail comes in it's, also based off of web hooks we also have input bindings for, one an Excel workbook changes, also. There's, a input bindings for the. Kind of the key here is we also do input binding for providing. Off as well so you don't have to worry about off that's, kind of the key in fact some one of the fastest, ways to get up and running, is graph explorer obviously number one but number two is just go over to to Azure functions and spin up a GP, trigger for graph using. The graph template and bam you're already up and running enough to worry about off you don't have to worry about writing that code and that's, the key so, check it out aka - MS slash, graph bindings, and you can see kind of the tutorials, on that and again this is still preview beta but, Dimitri, will show you in a little bit how, to get that all set up and running so. Again. As your, functions web with the big big thing about web hooks is the fact that we can trigger we can scale based off events based off the off-peak, times or. On peak times the load and it, allows us to kind of do whatever you want but also with this really unique way of, binding. The graph to that it, becomes a very powerful environment, for us to write really unique and experiment with really neat things so, let's put this all together and, Dimitri is going to go through a really cool sample, for you and it's, real son around IT Pro but it's really kind of a great example of how to get these two things married together mitri, yep thanks, Louis so in my sample, it's. Solving, an IT problem so Jane is an IT director or large org and, she wants to make sure everyone's profiles are up to date there's. A lot of new employees that are missing profile. Information missing. Their photos so. What. Jane is trying to do is trying to find a way let, them know that the, needs that their photo. And we can, pose this and solve this with those two technologies so. This. Calls for a flexible architecture, it, calls for being. Able to integrate into existing line of business applications. But. Not be tied down to, specific. Implementations. It's, kind of decoupled, but, it's really flexible you can really easily integrate it into it from scripts. On business applications, and more and. It's only run when Jane, wants it to run she just want to pay for this to be running all the time this, doesn't make sense to run all the time so. It's really build. At. The interval that makes sense to her and it. Works across different services in Microsoft, 365, so. We're combining together data, from Active Directory and. We're using exchange to communicate so, before you'd have to integrate those separately now, with, graph bindings it's really simple to do it all in one step in at your function. So. The, tools are going to use your graph Explorer, for. Prototyping the, graph SDK is to get nice idea, matic bindings. For models visual. Studio or your, browser of choice so. I'm gonna hop in and, I'm gonna show you.
My. I'm. Gonna show you how to get started with, with. The bindings for. For. Microsoft graph so. When you create a function up in Azure, portal you, can go down to application. Settings and, you, can set this flag called, function. Extension, version and if, you set this fight to beta when. You add a new function you, can see the templates that are called Microsoft. Graph I'll, be walking through through the first one which is one I used for my sample and this is gonna walk through the another couple, of those I'm. Gonna have to do. A refresh here. No. Problem. So I'm. Gonna hop back to connect, 17. Which is an app service it's a function app and then. I'll be able to load up all my functions here. And then, I found I create a new function it'll. Just been up here and if I'm in a scenario I can say a Microsoft graph I see, a couple of different. Templates. I can use something, use the first one which is in a graph, token, binding template in. This case all you're given is a token and you just handle you, handle whatever logic you want to do. It's an HTTP, trigger so, somebody has to hit that endpoint but, then all this pretty much figure it out for you so my, function is called fetch users and I'm gonna run it first and then we'll walk through and step through the code so. This. Function I think is already running so I can just get the function URL here and, copy. This out. And then I can paste it into a new window. FLE. This goes. In a minute. Yeah, so I can it, might all be running but just not showing up in exchange so I can just see. If this, is showing up here. There it is so, when. I hit that URL what it did was one, through hit, my function did, the logic I defined, and then, sent out emails here. I see that I got email, to. Myself, so. I was sent for me and it. Was sent to a, couple, people in BCC, such. As Brian Johnson to set their profile photos and inserts, to him how to do so so. I'm gonna hop in the visual studio and really walk through the code and show you how simple it is to get started so. Here to have my, projects, I can. Make, this a little bigger. And this is just a standard HTTP, triggered function that's right cool, let. Me scale this up a little bit. Okay so. The graph binding, defines sort of the structure so these, are the the, parameters I'm passed in and one of these is a graph token so, I were to get a token upfront, which is great because I can just use that pass it into my graph client I can, initialize my client you know all up, and running I can make requests really, simple and from. There I just do a little bit of simple logic I create. A recipient list which is gonna be the eventual list of people I sent us out to and then. I have a couple try-catch blocks just to make sure that I'm, running, into any issues I can log it to console, debugging. Is really simple without your functions you have a console, integrated. Editor. In the function portal, itself but, here I'm using Visual Studio to make a little bit easier to demo, and. Then, I can iterate through users by making a request to users. Using. The graph client, and. You can basically walk the, graph endpoints, and that's DK and use, objects, and have strongly, typed object, requests, builder pattern so, you can get back objects. Rather than JSON and that's really powerful because you get intellisense, really, good stuff and, here I ate, three each user and make, sure that they're not. A conference. Room or some someone that doesn't have a given name and, then for each of those users I make another request to, fetch their photo here. I'm gonna use the graph SDK, I specify, their user ID I make a photo request and if. I run into an issue it, hit if it hits the catch block I know, that that.
Person Is missing their profile photo I ran, into a 404 so, in this case I want to add them as either. As a recipient it to my recipient list and, I'll send an email to them later so. Here I'm using the recipient object and this is one of the, objects that came from the graph SDK, so this is an object, model that represents what a recipient is in graph, and. Then, I create, a new email I specified. The body and I passing the recipients, into. The BCC, list and from. There I make another request using, the graph client to send, mail to that email. And then that's all you. And it's as simple as that I can. Get up and running in minutes and solve. IT. Pros, scenarios, and, Lewis is gonna come, back and walk us through a more intricate scenario that uses the webhooks thanks. Me tree yeah, this is a really good showcase of being able to show how just how easy it is to kind of get up and running and be able to use those templates, and those bindings that are already set up for you to kind of move forward and kind of experiment, and get, moving and I think that's kind of the key is being able to make you productive right away is kind of our major, focus here so, the next moment kind of scenario you want to go through is this kind of the Salesforce one that I gave you in the beginning is, you have this Salesforce, that's out in the wild you might be traveling a lot but they need to be able to communicate and handle, correspondence. That comes back from your customers and you want to make sure you're readily available either you or somebody on your sales team and sometimes if you give out your business card or if they give out their business card and they email directly and you're not available at so you don't have your phone with you I don't know a sales person that doesn't have their phone with them all the time but, just, to say they don't let's say they may be the only vacation where they are the country and they're there they're out of they're out of connectivity, they don't have that so, what's the best way to do that well they let's build a system that, allows us to kind of trigger ourselves, trigger, our other people on the sales team to, be able to go and do something in, order to make to make a better experience for our customers so, that's kind of the way what we're talking about is just a way to signal our sales team and essentially.
What We're gonna do is the way we're gonna decompose this thing is we really want to build an azure functions, we want to be it's event-driven we, want to be able to scale the service I gave you that example that's story in the beginning about how we had to build the system where we had to think, about how, are we gonna process every mailbox all the time and, no matter when you know every so often spin up and go look inside and see if there's changes well, we don't want to do that we want to make this more, streamlined, easier, to process easier to scale we want to make it better that driven, we don't want any more polling services, we want to scale as we need and so that's where we come in with a flex rub block flexible architecture so. We also want to be able to work across many, different Microsoft, State 365, services, and that's where the power the graphs going to come in here we're gonna use that single endpoint from multiple points of data we're, gonna pull in data from exchange, both, our email our contacts. We're gonna use extensions. That Dimitri showed you a little bit about extensions, we're gonna talk a little bit about schema, extensions, and how we're going to kind of expose more data from, a contact, that you've never had exposed before and, we're going to do that all this by using a single employee, so. Again. What we're gonna do is we're gonna go, and have a trigger off a web hook that's basically, any time an email gets sent it gets received, in specific persons an email, box we're gonna trigger a function using a web hook and then we're to go through some a bunch of really complex workload. Logic. That's gonna happen here we're gonna go and we're gonna get the information about the email we're gonna inspect it when you get the from the sender of that email we're, then going to go do a lookup we're gonna go find out if that customers, already been tracked in our system the Varia customer, they're only somebody that we care about let's, go find out and so, we're gonna do a lookup that customer but then the key here is there's already some additional, kind of really uniqueness, about this is in the graph we used schema, extensions, we've extended that contact, within the system to now have tracking capability, whether it's tracked it's ID maybe, that ID is from my third-party system whether it's my CRM system or it's a third party system. That I'm using to kind, of track customers, and other data maybe, that's already there we will use that we can be content to this particular contact, it makes it really easy for us to just use a single endpoint to do that and then, once we have that information we know they're tracked we know it's a really important email we'll send some signals out to our Salesforce, whether it's a separate email whether it's a spreadsheet they can go look at a report whether. It's a you know it could be something else maybe you could use Twilio or something to send a text message it could be really kind of a complex scenario whatever you want to do. So, Demetri, showed you a little bit about the graph SDK, really powerful really easy to use we're gonna show you some examples with that and really. How its kind of an apparent, of way for you to basically build out your request it's. Very close to the semantics, of Oh data obviously, we have requests builders we have the ability for you to select the different attributes you really care about filter. On the different things you really care about order, by and it can you can also expand, on those navigational, properties so you can all bring that all back as one particular. Message, and you'll, be able to render it and it'll, all be deserialized, and really unique object, models for you to use. Again. You already saw kind of an example of that. And I'm not going to go through this but I'm will go jump over to the demo really quick and we'll get we'll start working through that so. I'm, gonna jump back into the azure portal, as we. As Dimitri showed before but. This time I'm actually going to create a different binding, and. The way I'm going to do that I'm gonna jump into Azure functions and it what Dimitri showed you is what you'll notice here is that, you.
Do Have other, templates. Here and there's, three actually three or four other templates there's, both, all of them are kind of related in one way and the read the way they're related is they're actually web hooks and. They have the, four different ones is the one is the creator web hook and. What this does is you create you actually add this function, to your function library here in your as your functions app and what, you can do is no matter what principle DUI you're logged into if they go to that endpoint it will essentially register, a web hook for you for, Outlook for messages and if. That kind of does all the work for you it does the auth for you it does the subscription, kind, of handshake with Outlook it, stores that subscription for you it does all the work all you have to do is add this function and which is what I did here I added an email web hook if I go in here and just look at the logic it's. Really simple logic, I don't even have to touch this code in, fact all I could how'll you would have to do is grab the URL function and run it in my browser and, immediately, it will set up a subscription for me for my particular mailbox in this case I'm logged in as Meghan B so, a very simple way of doing that and you'll want to make sure your ad that creator now in order to have the, creator work it has to have an endpoint that's listening for those web hooks and so you have to add as well before you actually run the creator you want to add the handler, to your as your, function app as well so you're gonna click on there as your function handler you're going to add that and that's, the secret sauce goes that's where your business logic goes because that's what buyers when the webhook fires so, you're going to put your logic in there so, once you add that there's also two other ones one is very required, and I suggest you add it is the, refresher and then what this does is essentially. If the subscription, subsides if it expires and it does do that after a period of time this. Will automatically, go and do it and if in fact it's kind of dogfooding itself it's going in it's using a crime service a timer service, that spins up behind, the scenes and it will go look at all the subscriptions and if they're ready to expire and I'll renew them for you so it you can keep those kind of webhook, subscriptions, alive and then, there's this final one you don't have to add it you should if you need to basically delete these subscriptions over time so you don't they're not continually, refreshing, and you'll, add to delete and essentially that will you could just run that just using the the, URL of the function and it will essentially go and remove the subscription, for that web book for you so. I would already created these so we'd have to wait for them to create they, were fairly fast when they do create so you have to worry about that but, I added, the handle and what I'm going to do is I'm gonna jump over to visual studio to kind of walk you through the code of what the handler is actually doing so. The first thing is you notice I'm pulling in the Microsoft graph SDK. And. The way I'm doing that is now I'm actually. Pulling. That in the actual DLL but also I'm also using the namespace, Microsoft, craft and, what I get here is immediately gonna spit up a proxy ago a graph client and what I'm doing is I'm essentially passing, in now I have I'm, passing, in the graph token, and the graph token is just like Dimitri, says I'm getting this actually. From the. From. The actual Azure function itself so, and this is the same for pretty much all the code so even even that you mean this particular scenario so, I'm passing it in I'm using, that inside, my my, my wheat my graph, client proxy so, the next thing here you'll notice is I'm actually going to make a call to graph and what I'm gonna do here is the.
Nice Thing is I actually get a message, object that. Gets passed into my function so if I go look it back the function you'll notice the first thing the part of the schema of this is that I get a message object and really what's happening is when that web for when, the web hook fires all, you really get is some little small information, you get the email ID you. Get some information about the email but very small amount of metadata around that email but. What that adds your function with the binding actually does for you as it goes back to exchange and it gets that actual all the details about the message it passes you a hydrated. Message object for, you to look at it has all the content in there but from the sender it does all the work does the off loop for you so, you don't have to do that work yourself, so once I have this message object I can do some stuff with it I could. Actually extract the user ID at it so I know what you what what, email, box that came from it. Can also, now. I want to go and say okay well now I know who the sender is the from so I'm gonna go pull that I'm going to parse that off the actual email. And I'm gonna pass it into my separate function here which actually lets me. Go. And actually determine, whether they're tracked or not and the way I actually determine if they're tracked or not is. I'm going to use a schema. Extension and the way I do that is you'll notice that the here's my query here that over here to the end I'm gonna kind of skip over here this side you, notice I'm looking to the contacts. Resource of filtering, based off the email address that I got that's, the sender and I'm selecting, the ID their. Display name their email addresses and then you notice this kind of interesting. Thing to the left here to the right here this is the schema. Extension that I added I asked added what they call customer, track data and that track data can have a property, bag of different different data in there what I added was, essentially, a tracking. ID so, this way I know if they have that they were being tracked and they could have as many cracking, IDs as I want it could be many different third-party, CRM, systems I just, at this point just tracking one single ID but at least I know if they have a tracking ID I care, about it because it's my contact, and I care about it so I'm gonna go and make that request I'm gonna make a standard HTTP request I get all the things, that I'm already familiar, with here it used to be client, I'm gonna do a send. A single on that thing just using directly using my graph client I don't have to do any off there, and. Then once. A if I get a really good status back from that I read, and make sure that it's being tracked and the way I do that as I just pull off the tracking, customer, ID if it's if it's existent, then I pass back saying this is a cost tracked customer, and I returned that back so once I know that it's being tracked I could, pop back up to my main function here I can say okay well now I know what's being tracked so what do I need to do next well next I need to do is I essentially, need to signal the email I need to make sure that it's being, marked this track so if I were to open my email I saw this is this is already been processed by the system it's being tracked so, I'm going to go and actually do a send, email or set email categor and by doing that I can jump in here and that can actually view, the, logic of doing here so what I'm doing next again I'm going to do another call to the graph but.
This Time I'm just passing, the, user, ID that I extracted, from my original message and from. The message context, and then I'm also grabbing the, email ID because I want to basically do, a patch and our update on that and then, the next thing you'll notice is I'm just the content of that is I'm just taking and marking the category and what you'll notice here is I'm actually using the data endpoint, categories, as part of outlook right now is actually. Part of the beta of the preview endpoint. There. Should be part of the main b1 endpoint at. This point you have to kind of switch over to using beta once. You do that you can essentially send in this content message to say whatever you category you want you can add a array. Of content a categories, if you want I just use the email tracked one because I know it's a big, red label, that goes on your email when you open it whether it's an OA is a mac outlook. Or if it's in over in Windows or any, of these kind of email clients it will show the category, and it'll show it as tracked so, I went ahead and did that and then. I run the patch, on it and once, I run the patch and I execute, it same, exact code as I had before I run the send, async and its successful I know that again it's being marked, as tracked now, what you'll see here is I kind of have a little hand, wave and say you can do something else now so once I know that the emails being marked is being tracked, I've already already, figured out it's in my email system now I can go do some really, fancy things I can send text, messages I can send I could update a spreadsheet and and and do reporting, I can call into Excel I can, send another email if I wanted to maybe to a shared mailbox but this hat maybe has some metadata about how many times the, customer, is wrote and they've written in for the day maybe some insights about how many what what kind of interesting, topics they might have so, this allows me to pretty, much experiment. To write really rich applications, without really doing too much work if we pop back over to the portal, what. You'll notice in here is. That if I pop open this got a side pane here you'll notice that there's a couple files in here there's my CSX, file my scripting, file that I kind, of pasted my code in there that it came from visual studio but, also I have my functions Java, JSON file and what this shows is the bindings, that are available to me so in this case I'm actually using, the, the, input. Binding, it's an in binding direction. And again this is the declarative, way of defining your input and your output in, my, case I'm just using the input and I'm grabbing the message so, there's a binding, behind-the-scenes. That's going and actually using the ID that I got from the truth of film the way webhook, it's, pretty actually retrieving, the actual message for me and then I'm using that to pass it into my function and then all I do is I give it a name which is my you know this little guy message and I, just put it as my func as part of my function, a, schema. Here and the key here is what. You'll notice is this is automatically, done for you you don't have to do this yourself, this. This is essentially. Already set up but you can add as many as you want if you're going to write your own bindings, you can essentially, go and extend, this and add more data that you can pass in so it's kind of a key aspect, extensibility, story for this and, again once you notice is the code is fairly is the same here the, only difference is I didn't. Do a little hand waving that I did before where I had to get the graph token but in this case I'm actually having the graph took and it's getting passed to me so I could basically use that from the binding and run it so, if we go over to what, I'm going to do is I'm going to show you an example I'm, gonna say that Kristy here is our customer and she's gonna send an email to Megan. Who's. The salesperson, and she, wants to actually purchase. More. Seats. And. You, know she has she. Wants to purchase like you know forty three more seats.
Which Could be substantial, amount of money so, we want to send that now, if we pop back over here we've, pop up here what we'll notice is we'll. Actually see the. Triggered, function that once it cures there was a trigger function, there's a couple seconds in and it's, completely well you know this is I actually pasted, the graph token in here so you can see that it's actually being given to me here's the users ID mailbox, that I extracted off of it now if I pop back over to Megan's mailbox go, back into the Inbox who notices there's Christie's email and you notice BAM it's, not just tracked so, I went in did a lookup of Christie I noticed that she was a tracked customer. And I. Got, a circle back and I actually marked her as tracked so a very easy way a very powerful way, to, write rich applications. In just, minutes to kind of get yourself up and running and just, using very simple logic. So. Let's pop that go over to slides. So. Make, sure I want to put a handle back over to you sir. So. To put some next steps so what you can do with these two technologies was just showed, there's. A couple ideas so. Functions. Are really well suited to doing data transformations, and doing. Things specific, to your business and then. Graph is really powerful as a data provider it's, a couple ideas of what you can do you can fetch Khan the, context, when a critical customer sends you an email this. Is cool, leverage Lewises code and, it may be an additional lookup of really who that contact is and maybe see if. If. They've already ordered something how much have they ordered maybe, set the priority, to. Match. Basically the priority to match. Like. The size or, the impact the custom will have you, can orchestrate a lot of business processes like, the IT process, you can do things with critical. Excel workbooks you clean up if needed add new, visualizations pull, a new data your, transform. Images. And other kind, of blob formats. So. You can make, a mosaic of different images but, added to a 1/2 drive folder, you know the triggered one things end up in that folder so there's a lot you can do by mixing these two technologies and it, really focuses on what.
Can You do to make it your business process, more powerful. Like. The focus is thinking. About your solving, your business problem not not worrying about the, infrastructure, the. Differences between data sources and just really focusing, on adding. Value to your business. Cool. So there's actually a question that kind of came up before. We jump in who we are is, in the graph Explorer is there intellisense. And so yes there's a built-in intellisense. Sometimes. I think the beta doesn't, sometimes work but you'll notice here is what I just type me I get all the different resources that I can actually talk to and then I start to bail out bail build out my URL. I don't have to go and look up stuff now granted we do have this really kind of cool thing to this left side that Dimitri showed where you can kind of go at your own samples, and you can click on them and they will run and you will see not only the request body the content, but also the URL but, also you can just kind of play with it you can just go in there self, discover, the, different URL endpoints the different resources that available now, some, of them you might have to actually figure it out the different filtering and the selecting, for it but it's fairly straightforward it's just the standard OData syntax, that you'd have when you're doing filtering, and you're doing selecting and order by that kind of thing really. Easy kind of cool things yeah one of the other things I want to talk to you is if. You use the guided pre, can queries, to make requests like getting a user, profile or their photo or their mail on. The, right there's a link to the documentation for that request so. If you try something out you think it's interesting you want more information you just click here and you have taken to our Docs and you have pretty in-depth reference, about how to work with users and graph for instance, so. There's really a wealth of documentation. And it's all unified in one place across. All graph it. Really speaks to how unified the graph developer experience is. So. Great thanks. Well that's all the content we had I am Luis Perez crime a principal engineering manager on in, the office team I'm all about office, extensibility, and graph SDK, and extensibility, there so you know reach out to me I'm on Twitter at Lu mmm at any time so whether, it's a feature whether, it's you have some questions about graph have, some questions about office extensibility feel, free to reach out to me you always check me out at twit that TV on my, daily my weekly show Twilight. This week at Enterprise Tech where I do talk. About enterprise stuff, and. Our podcast so check that out and, I'm Dimitri and I'm a p.m. on the graph team and we're. Going to CK's in the tooling so I'm always interested in hearing more about, your scenarios for graph and figuring. Out how we can make your experience better and you, can find me on github and twitter at at. Him. Thank. You all right thanks everybody.