Azure Serverless | end-to-end with Functions, Logic Apps, and Event Grid

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
everyone this is Jeff haulin I'm a program manager in Microsoft Azure and today I'm gonna go over with you building a service app in Azure and to end we're actually gonna build out a pretty cool scenario this is a scenario that every company can relate to it's around onboarding and hiring employees and all of the different processes that need to happen when you hire an employee we're gonna build that using serverless tech so that you can see how it fits together as well as you can see how quickly it enables you to build an deployed cloud scale applications now so this will be fun I'm gonna show you all the components here we will be using Azure functions for serverless compute event grid for events and logic apps for serverless workflow and to start with I am going to give a short introduction on service if you're not already familiar with service and what it means in Azure I would recommend checking out Azure comm slash server list for a little bit more information but for now one of the things I just want to point out is what makes up a service technology and why is it important so service tech enables developers by allowing them to build and ship applications faster because like the name implies you're not worried about managing and deploying servers you just build and deploy your application code and logic and all of the infrastructure scaling everything else is taken care of for you so you can focus just on what you need to focus on to build your application so this gives you reduced DevOps you can ship solutions much faster because you really are just worried about the core logic of your application and you get per action billing so you're only ever charged for the number of events or messages or workflows that you actually execute so that if nothing is ever running you're not paying anything so this is why a lot of people get very excited about server list I would say it's one of those pieces of technology that the best thing for you to do if you haven't done it already is try to build an application and see for yourself where these benefits could come in for you and so to help you do this I as I mentioned at the beginning I am going to build out a scenario and to end and show you how the components fit together and how it enabled me to solve this problem very so the server lists components in Microsoft Azure are threefold you have Azure functions which is your server list compute you can think of this as you give it your little bit of C sharp or PowerShell JavaScript whatever code and it's listening to some events either you know something gets uploaded into storage or you get an HTTP request and that little bit of code will execute on demand you know you have millions of IOT events you'll get million of function executions if you only get one you only have to execute one time as your logic apps is serverless workflows so this enables you to chain different functions together you'll see this with our employee onboarding process where you might need to create the user in Azure Active Directory you might need to create a mailbox forum maybe send them an email all of those types of workflow do this then that capabilities is what logic Apps provides and finally we have the newest member of the serverless family which is as your event grid and this is serverless event routing you can think of this in terms of all of these different systems may have events that you care about and when I say systems I mean everything from your Azure subscription to your storage account to you have an application that has an event of a new employee just got hired that's an event and when that event happens you need it to route that event to all the pieces that need to execute so event grid is serverless and optimized exactly for use in these types of service applications so we will go through where that fits in in this process as we build this out so before I show you any code this slide didn't build out perfect you see I have a straggling arrow right there but that's fine so as I mentioned we're going to automate employee onboarding so if you think about onboarding to any company it can be a fairly manual process today and it's one that server list makes super easy to automate so the steps of of employee onboarding is fairly simple right you have a new employee who's joining your company you need to make sure that they have a login so that when they come to work they can log in and access corporate resources you need to make sure that they're a member of your office 365 subscription your Microsoft teams you need to make sure that they're assigned to their manager that they know who their manager is that the manager knows that they're coming all of these are different pieces that need to happen and we're going to build a service app that does all of that automatically for us so whenever an employee gets an offer accepted you know they're gonna start if fires off an event which will start off this process and do all of this for us automatically and it's just a few steps and a few lines of code so the first thing that will happen is an employee's gonna submit this request to join it's gonna have the information on their employee status you're gonna have some legal documents like maybe a driver's license or social security card so the Azure functions gonna spin up process that information and then it's gonna fire off an event - as your event grid so I'm gonna have a custom event topic so this is my own custom events that I'm going to send not one that's being automatically generated from another service these are events I'm pushing myself saying hey I have an employee hired event so I'm gonna fire off an event saying hey this employees been hired they need to have all the information here's the event and here's some information about how who the employee is or where you can get more information on them so once that event has been sent to event grid this is where I can have different service components responding and reacting instantly when that event gets published so what we're going to have listening is an azure logic app and that as your logic app will be listening for any event on employees and it's gonna say hey there's an employed hired event so now execute this workflow to create the user and as your Active Directory send the email to the employees current email address that says you know hey welcome to the company you know here's your username and password for your email address here's everything you need to get started it's also going to send a calendar info a calendar invite to the manager and the employee so that they have a one-on-one scheduled for the first day when they're reported to come to office so this is what we're going to build and I'm gonna walk you through this application and some of the tools that I used to build it so that you can understand how these components fit together obviously this is employee onboarding but the same principles could be followed whether you're doing you know a customer has just signed up and they want to join the service or any number of other events that might be happening within your business these same tools can be leveraged to help optimize and make this really quick for you so for the next five or ten minutes let's walk through the solution now okay so the first thing that I want to show you is as your functions you can imagine as I mentioned this process is starting off with a form that's being submitted I even have an example HTML page it's really simple where maybe I'm filling in a form and providing information on the employee that I need to on board maybe providing things like a picture of their driver's license and so on and when I click Submit here I need this to be processed in order to do that on-demand processing I'm actually going to be using as your functions so let me show you how easy it is to get started with an as your function so I'm in Visual Studio 2017 I'm just gonna come in here and say file new project and in Visual Studio 2017 I have this as your functions project so I'm just gonna leave this default name there I go ahead and click go and and I'm ready to go so now I have a function app I can start adding functions inside of it so I could say hey I want a new function and call this hello world and I can choose what's the event it's listening for like an HTTP trigger in this case from that webform click OK and I'm up and running so that's it that's as fast and as easy it is to get started you'll notice here I barely have to have any code it will be published to the cloud and run on demand for me and run this code so let me show you what the code looks like that does our employee onboarding application for us so I've switched here over to this employee request function app project and I have a single function in it called receive a request and this is what's listening to that webform that I showed you earlier and again I'll just call out how few lines of code I had to write to process this data I don't have to have any boilerplate code or framework code I just write the function this little bit of logic is how I process employees I'm gonna grab the Social Security card and the driver's license and ride it to an Azure storage account I'm going to generate a temporary password and then I'm gonna fire off an event that event saying we have a new employee and I'm gonna send the data of my employee along with it so I don't have to write very much code at all and I've got just the logic I need I can publish this now to the cloud and it will start listening for those events and running on demand as many events as I need processed for it something else I'll call out quickly here is that because I'm writing this in Visual Studio I do have great tools like I can set a breakpoint right here and I even click this Run button and what's happening is that the Azure functions core tools are actually running on my machine so the exact same environment the exact same runtime that will process and run my function in Azure is now running on my machine it's exposed this localhost endpoint so that I can test this out debug it simulate run unit tests whatever I want against my functions and have confidence in knowing that if it works on my machine if it works in my environment that's how it will work in the cloud with the benefit now that the cloud can scale out and scale infinitely and only charge me for what I need to execute so I've got this running now let me go ahead and simulate a form being sent to this function you'll see I have an employee here that I want to onboard and it hits the breakpoint and just like any other great debugger I can come in here I can you know step through and look at the different values as I'm debugging it just like I would to bug any other application that's what I'm able to do just right here within Visual Studio so that's just a quick example of some of the tools that I have at my disposal for Azure functions and as you notice the last thing I'm actually here's I'm sending an event to as your event grid so I have an event grid called employees in my asher subscription and in this case I'm actually sending off for a quest to add a new event you'll notice I'm doing things like setting the time I'm saying the event type is that an employee was hired I can set a subject if I want to you know distinguish into a little bit more detail on the employee was hired you know with which subject under what resource or what type and then I'm passing in all of my employee details so that I can process that employee on other systems that I need so what event grid is doing for me here is now I can go set up different listeners to as your event grid to fire off an event of a new employee being hired so let's go ahead and switch now and do exactly that so I'm going to switch over here to Microsoft Azure and let's go ahead and show how you can create an azure logic app to do processing on top of event current as well and start off a service workflow so in this case I'm here in the Microsoft Azure portal I'm just gonna head and click new here and under web and mobile you'll see I have a logic app so let's go ahead and create one of these I'll call this you know my event listener and I'll stick it in my as your subscription and now what this is created for me is that serverless workflow so this is where I can start to chain and listen to events either from Azure functions or from any of these other over a hundred and seventy-five services that we have connectors for and I can listen to events from any of these and now start a service workflow to process that so you'll see here there's everything from on-premises sa P to cognitive services like text analytics face recognition language detection github dynamics Salesforce you name it but what I'm actually going to use here is the as your event grid connector and this lets me listen to events that are coming from as your event grid so I'm can go ahead and select that and say hey I want to trigger this serverless workflow whenever an event occurs so let me choose the subscription that has my event grid topic it's actually in this subscription and you'll notice here that it has seen that I have this topic called employee and that's what I'm gonna go ahead and listen on so just that easily now I'm able to register something and start to act on something like when a resource event occurs and now I can start to take actions right so I could go ahead and start adding actions here and and calling things like as your functions maybe I want to send an email right away or just make an HTTP request so the last thing I'm just gonna switch over quickly now and show you what does this logic app look like in the end that on boards this employee so let's go ahead here and I'll go ahead and discard those changes because I have this employee onboarding workflow that we've already built so there's a few things here that I'm doing and I'll walk through this step by step very quickly so I'm getting this event and if you remember from my function code I'll actually show you I'm sending in this data object which is gonna be my employee so I'll show you what an employee looks like this is what an employee is it has a first name a last name an email address start date all of these different things that I'm looking for with an employee I'm gonna be sending that in my event so in order to parse out those values I'm gonna use this let's see if I can get rid of this little pop-up I'm going to use this parse JSON object and I'm gonna say hey parse out the data and grab all these properties I could even just provide a sample of the event and it would have generated all this for me even so now I have you know the employee who's who's being hired I have you know their name their manager when they should start and now I just need to create that process so what i'm doing here is i'm calling the microsoft graph so you can go to graph microsoft com I actually have it open right here this enables you to do a ton of different operations whether it's on users whether it's on mailboxes onedrive Excel OneNote whatever you want you can call the Microsoft graph API directly that's exactly what I'm doing here so I'm calling the Microsoft graph API and I'm saying hey go ahead and create an employee and create them with all of this information you know their display name should be their first name and their last name with the space in the middle here's what their alias is here's what their temporary password should be this is their last name this is what their UPN should be in their email address so you'll see I'm able to just come in here and even if I wanted to make more changes I can just kind of add content I could drop in different properties from different steps or even you know if I want to generate a random grid I could do that with the yeren and my logic app so that just gives you a feel of the tools that you have to write these applications and after I create the user the graph is going to come back to me with the user ID I need to assign their manager and then I need to assign them in office 365 license so you notice none of these steps are overly complex but what logic apps is providing me here is that it will chain these workflow steps together and what's better is that if there's something that goes wrong I could do things like add exception handling I could specify which actions to run on failure I could do conditions so I have this really rich control flow and resiliency across my workflow so that I can just chain these applications and steps together and finally after I've given him a mailbox I've given him a manager I've given him a login I'm gonna do two steps in parallel I'm gonna go ahead and send them an email and I'm using our office 365 connector to do that so I say you know hey we're excited you joined here's your temporary password and your email address here's where you can go to login and then I'm actually going to create a calendar invite for them based on their start date and I'm gonna go ahead and and have a calendar appointment on them and their managers calendars so that they know when they can get started so this is great and it's gonna fire the second and event happens from as your event grid so to prove this happens and how quickly it happens you'll notice here my last run was on 816 so I'm gonna come over here to my Azure function actually run this again let me make sure I don't have my breakpoint sitting there and we're gonna run this request we're gonna onboard an employee watch this whole process happen and then I should get an email as a result of this - since my email address is one of those so let's go ahead here and submit this request so it's sent off the request and it gave me back a 202 response which has now gone and fired an event to event grid so if we come back over here and if I click refresh you'll notice we already had this thing fire and run because event grid fired off the instant the event happened which notified my logic app the instant something happened I can even come in here and see everything that happened here's the event that I created you see here where all my employee details that got sent along with the event I even got sent links to where the driver's license and the social security cards are I went ahead and created a user inside of the Microsoft graph I assigned their manager I gave him a license and I sent him a welcome email in fact I can hear it you you probably can't but I can hear I'm getting some notifications here and that's because I just got this email so you can see I got the email it's saying thanks so much for joining here's your email address and password I could cut him even here and follow the link and log in if I wanted to that's just a quick walk through of the different tools at your disposal I could obviously continue to add on to this to add as your functions or different connectors as I need but that's kind of how logic apps event grid and functions can play together to build the serverless app so now in 60 lines of code and in an eight step logic app I have automated my employee onboarding process I've published it to the cloud and what's great is I don't pay a single thing until this thing runs and even then when it runs it's micro sense like unless I'm hiring a million employees a month I probably will not even notice this workflow in my Asscher subscription so I'd encourage you all to check out as your service offerings give this a shot we have documentation and quick starts across functions logic apps and event grid you can follow the exact same patterns that I've done here and reach out to us if you have any questions as well you can find us on twitter my twitter is at Jeff Hollen or you can reach out to the logic apps functions or event grid teams as well so thanks so much for watching and good luck and have fun building serverless apps
Info
Channel: Technocraft
Views: 27,524
Rating: 4.9123287 out of 5
Keywords: azure, azure functions, microsoft, application developer, serverless architecture, microsoft azure, microsoft ignite, demo, developers, aws lambda, azure cloud, serverless computing, serverless, azure function app, microsoft mechanics, it cloud infrastructure, apps, aws serverless, zero code, azure logic aps, azure serverless, channel9, flow, lambda, cloud computing, microservices, functions, serverless tutorial, aws cloud, amazon, logic apps, machine learning, aws training, tutorial
Id: UNl1zsgYYd4
Channel Id: undefined
Length: 20min 16sec (1216 seconds)
Published: Wed Mar 21 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.