Hi. This, is Steve McCatty of the azure government, engineering, team I'm joined here today by my colleague youjin hyung also on the azure government, engineering team welcome Yujin hi Steve so, as we get into this topic we're gonna talk about serverless. On Azure government, you, and I have had a lot of discussions, in the office about this topic we've, talked about you know what, is server list and how can we communicate this, to our customers and, all the different you. Know options, we have on the Azure platform. So, we thought it'd be good to just come in here and have a discussion about it today to go, through all the options right, yeah totally. Okay. So as, we get into it I think the thing. We've talked about a lot just again these side conversations, in the office are how, do we describe the evolution. So, to speak of serverless. And how did we get here right right so, I think as developers, like we've seen this transition, from building, everything on prem and having to worry about all these things yourself and then starting. To deploy things to the cloud and now their. Server lists and that's another level of abstraction. Right especially when we start getting these buzzwords, like serverless what the heck does that mean so hopefully we can clear some of that up as well so let's talk about that so you just mentioned, on. Prem going all the way from on Prem so when I think about my crusty. On Prem day is going back in the day where we did everything on. Prem, we, had a lot of things to worry about so if we look at just all the questions, we have on this slide these. Are things we had to think about like who has physical access, to the servers what, do we do if there's a hardware failure or a power failure and then, that's in addition to all the concerns we have about our actual. Code and scaling, the app and that sort of thing so as. We, go from the on Prem world to the cloud world what a lot of times we see is that first step is just a lift and shift is. So. When. We get to that lift and shift to I as actually. Things, get a lot better it's not necessarily. That, technologically. Innovative but. Actually things get better and we think about that mess of questions, the. Questions get smaller so, you don't longer see the questions there like who has physical access to the servers no physical, servers you have to worry about there's no power, failures, and hardware you have to worry about Microsoft. Will worry about that, provider but. There are some other questions you do have to worry about these are things like how often do i patch my servers how, do I backup my servers, and again, that's still in addition to the, code we write as developer as well which of course we have to worry about you still have to worry about like how many servers you need and how you can actually scale your application exactly. Exactly, so what we often see is that trend where someone. First comes on there is and then they start realizing let, me get more of these benefits, by going past so. If we keep walking down that evolution. Now when we in the past world we. Eliminate even more questions and so, these questions like how often do i patch my servers those are gone I don't have to worry about those anymore Microsoft. Or worried about patching, my servers and backing things up and managing. It so the past world things are looking actually, pretty good here I think and if. We look at the questions we're asking, we're still asking a few and these questions usually go around well how big are the servers I'm using how. Do i scale em up and down and that sort of thing but.
All The other questions before, that yeah the actual servers. And the infrastructure that's all that's. All disappear exactly, so this is what I really love past because we can get down to this kind of level but, even as we look here this. Is where the idea of server list coming it comes in because when we look at the past world. So to speak we are still asking questions about servers, what, are the right size server, how can I increase my server, utilization, we, put the word server here in bold right and, so, this is where server list comes in so people say what is server list the reality, is yes, we still have servers so server list doesn't mean there's no servers what it means is we're abstracting, away the, concept, of servers, from you the, developer, and so if we go that one extra step here to server list it's that server list is gonna take care of don't worry about what size server. You're on or how many instances, scaling, it up and down the, underlying infrastructure, will do that for you and then, the only question you have left is how to architect your app and as developers technical, people like us that's. The question we want to focus on we don't I want to focus on updating. And patching my outraces. Okay. So this is the evolution of how we get to the server list so. Now if we get real specific it here in terms of like what, serverless. Options, we have on Asscher and specifically, in Azure government, we. Have three that we'll focus, on here one is as your functions and we'll have you show a demo that in a second and then. The next one will be as your event grid and we'll talk about that and then we'll finish up with as your logic, apps so you here are these three things these are three of our server list technologies, we have a couple others too but these. Are the three that are really our core server list technologies. So. With that. Let's. Sort. Of focus on each one of these in turn, starting. With Azure functions. Right. So as your functions, is basically one of our core service, offerings, and it, basically allows you to run pieces, of code that, accomplish. Exactly what you want and you don't have to worry about the, application, or any of the infrastructure, as we kind of talked about before we're kind of taking away that concept, of servers. Away from the developer, so. Some. Of the things that come with functions, is events, so you can react to specific things so like, if you're putting something on a queue or if you're adding something to a storage blob these, things can be triggering. The the functions, can be triggered by these sort of events and then, there's. Different. Kind of runtimes. Supported, and as your function so you can author, and, c-sharp or, node or Java and, then. There's all these outputs, so you, can kind of send the results of your functions, so there's output bindings, so the same way that our functions are triggered by things we can also write to other, azure services okay, so it's really a focus on code so as a web developer it's not that I have this whole web application. But I need to deploy to a server, it's that hey maybe I just have a little snippet of code it might be a single method and.
I Just want to deploy this section. Of code up to the cloud somewhere and let that worry of, Microsoft, worried about it for me exactly, on it okay so. Now let's actually, move, to a very. Simple little demo so. Basically. We have a, very simple web application and, it's. Gonna send a message to a storage, queue and we're gonna have a function. That's going to be listening to that queue for any sort of change or if a message is being written to it and that, will trigger the function, and it will run and it will output something okay, sounds good all right let's get into the demo, so. We've navigated to the azure government, portal. Here have actually clicked into my function application so we can see I already have some deployed, so, I want, to actually click. On new function, and, here. We can see that there are all of these different sugars. That we can integrate. Into our function so there's things like an HTTP, trigger or a Thai, red sugar so you want to function, to run on a specific schedule, okay. So we have all these different triggers set up and it's like I could again. Thinking back to my own Prem days I could write a bunch of code to host maybe a console, app that watches, a. Queue, of some kind boy that's a lot of infrastructure code I have to deal. With and monitor, and maintain now, I can just say what, are the different triggers I have available to me here exactly, so there's like service, bus you, can watch the blob stores like I said you also have an event hub sugar and a cosmos database trigger which you. Know that's a very common use case if you have a database and you want to see the different kind of changes going on there okay cool so we're actually going to create the, as your cue storage trigger but so let's actually just click on that and. Here, we can see we have the name of the trigger and a. Really cool thing is we can actually. Directly. Connect, this, function. To a cue, that we have in our Azure storage account so, we just specify what storage account we want and we, can type in the cue name that we want this, function. To be watching, and then, we just click create, ok. So that's, pretty simple we just say this is the cue I want to watch here's, my trigger now go write some code exactly so some good all of that integration code you're talking about and specifying, which cue you want to watch all that we just did a little click through and we got and we were able to hook our function up to it okay great so, let's click on run just, to make sure we have our logs. Started, so, we can see this, is just a test it's a sample cue dittos we know our function is running correctly yes it's, monitoring, the cue yes. So, let's actually navigate. Yep. Perfect. Alright so I've opened up my visual, studio and this is just a very simple dotnet. Core web application, and if. We look at this index method here we can see on line 31. We have this cue client and this cue client is actually connected to that so, name storage queue that we connected. Our function to all right so when I saw you did that web app alert queue that's the queue we're talking exactly, exactly and then we, have this submit message, method. So we're, basically going to take a user. Input, and send, it as a message to that you okay. So. Let's actually open, up. So we can see we have that application. We're looking at running locally, so, we can submit a message so actually, let's, just send, a very simple test message okay we can click Submit. Let's. Navigate back to our we, have navigate back to the portal we, can see in our logs that, that. Just triggered, our function we can see the data in within data the. Message this is a test that's the exact message that we sent to our queue our function. Detective. That and was triggered. Okay so with literally. One line of code you are able to use, Azure functions, to monitor queue and respond to events in this case someone writing a message tuna thank you exactly and this was just a very simple scenario, but obviously you can integrate functions in your own custom, applications, or user scenarios, and have many. Different input, triggers and output bindings on even just one function awesome, okay cool all right we've seen that look at as your functions, let's dive ahead to the next serverless technology, okay, so the next technology. We're going to talk about is Azure event, Grid and I think that's safe to say based on the, discussions you and I have, had that we we both agreed that this has had a lot of confusion, with some people and this is a technology we now have on Adric government so from a high level let's just explain what event grid is and then, create is this, central.
Publish/subscribe. Mechanism, or we can respond, to events these, events might be things from our resources. Like a VM, was created or. It might be more of an application centric, operation, like someone. Put a message on a queue like we just saw in your web app example, and I think what's interesting from a government, standpoint is, a lot. Of times in government we think about compliance, and so, when you can respond to these operational, events, like someone creating a VM all do they do that in compliance with, your policies. Did, anything about the way they provision, that did. Everything makes sense so. It'd be nice to get these type of alerts for those operational, type. Of activities, but. In addition to that the. Scenarios. As well and you can see the publishers, like these, various things event hubs blob, George that one at the bottom custom, events is really important because that is what we can use this developers, to really do any pub, sub scenario, we want and then, we have these various event handlers we just saw you use as your functions but we have other things like as your logic apps as well so. This I think that slide is really. Really. Helpful but when, I see things like event grid and event hubs and service, bus and as developer, kind. Of they all kind of seem to have similar functionalities. Like what kind of differences, do they really have definitely I think we. Agree this is something that's been very confusing. For a lot of developers out there and we're. Not doing it intentionally but there are different. Reasons. Why we use different technologies, so if we look right here we, have these various Asha event. Messaging. Technologies, and the. Three I have listed here are event grid event hub and service bus and that's not even to mention the. Fact that you just use things like that as your storage queue that we just saw you use in your last demo so. Even. Before I talk about the details of each one of these I think it's important to note the distinction between an event and a message, so, an event is something that's really just a lightweight payload. Hey. Something happened it. Might reference an, entity, or something like that you may need to go and retrieve the, full message but, it then is just a lightweight payload, whereas a message, might be a large payload, that we're sending across the wire for some reason, so.
With The vent grid we're, dealing with events we, want to do reactive programming something, happened a VM, was provisioned. State. Changed, in your application, in some reason this, is ideal for event grid and we have this very rich publish/subscribe. Mechanism, with which to do it the. Second one is event hubs event. Hubs is really there for these, high. Throughput scenarios, like big data pipelines, or IOT, where, you just have massive. Billions, of, telemetry. Mess. Events. I don't want to use the word messages. Telemetry. Events just coming in you need massive, throughput, with something like event hubs and, go, ahead does that mean it's kind, of better equipped, to deal with kind of that higher payload of data definitely, so that is the sweet spot for event, hubs and then, you have service bus which is dealing. With messages. So you can have these large message. Payloads if you need it so whereas a van grandma noventa hub is really more lightweight event, payloads, message. Service. Bus can deal with heavier, weight messages. And not only that it's high value enterprise messaging high value mean we, can't afford to let any messages, fall on the ground we want to have guaranteed, delivery. You, know this is important. For order processing, financial transactions, that sort of thing so that's why we had these different technologies, for different scenarios, okay. So, what I'm gonna do here is I'm gonna show a little Event Grid demo and I'm gonna pick up where you left off so here was your demo where you did the web app went to the storage queue now what's interesting here, is we. We, glazed over this but, it's. Really nice that as you're functions gives you these various triggers like the cue trigger but the reality, is behind the scenes it was pulling off that magic by doing polling right, so it was continuously, checking is there something in the queues or something in the queue and when it found something in the queue it pulled that data in and, that works well and it's nice to abstract that away from us as developers but. Event grid has something slightly different here I'm gonna do the same demo but I'm gonna use a vent grid this is publish/subscribe. Model which. Means there's no polling, and instead. Of a pull model it's gonna be a push model in other words when the web app writes directly to the event grid the event grid knows who its subscribers are it's, automatically gonna push. Instantaneously. To those subscribers so, the azure function, will actually have no need to be pulling at all won't need to use any resources, behind the scenes it will just instantaneously. Receive, the message does that mean that the event grid will have kind of like. A lower latency, and like you it'll be kind of more immediate that's exactly right it'll just and you can have multiple subscribers. So in this case you, know in the queueing example, you gave whoever. The first person to DQ, that message they got it no one else did but with event grid since it is pub/sub, you, could have multiple subscribers. Interested in multiple messages, and it's lower latency, because we are immediately pushing those messages out to the interested. Subscribers. Okay. So with that let me get into a demo of event. Grid. Okay. Here I am back in the azure government, portal and I, can see that right here is the queue trigger that I just saw you build, and I'm, going to add a brand new function. Here and instead, of like. Event grade trigger or any of these other ones I'm just going to use a straight up HTTP. Trigger to illustrate, that this is really like a web hook type of scenario that we can use it for so, I'm going to call this web app alert, func and just, for simplicity I'm gonna use anonymous here and we're gonna create a brand new as your, function, so.
With Your as your function you use the, queue. Mechanism. For, the actual binding what, I'm gonna do here is I'm just gonna put a snippet of code in I just put about 30 lines of code in so let me back. Up and show exactly what I just put in so, that first thing we have is this if statement on, line 15 and this, is when it comes to making a subscription, in event read it. Has to be a valid URL and, we have to give a mechanism to know not only yes am i real URL, but I know how to process event, grade messages, and it, does this by we. It send us a validation, code and we echo the validation, code back which is why you can see us returning it right here so this if statement is a one-time thing only. When we're setting up the subscription, and then after that if. We scroll down a little bit here we can see that I'm just doing similar. To what you did I'm just logging the message, to. The blogging, just to prove that we got the message okay, so, with that it's time to set up our actual, event grid here so I'm gonna flip over to the azure CLI, and I'm, gonna put a couple commands in here so this first command here I'm doing a Z event, grid topic. Create, we're, gonna give it the name of our topic so you had a queue called web app alert I'm creating a rent grid topic, called a web app alert I'm putting, in us covert in Y ax and I'm just putting in a resource group called serverless, demo so. I'm creating, this topic, and, this. Will just take a second to run. Okay. So that topic just got created so, this, topic is kind. Of like a queue it see that as an endpoint in, a way it's like a cube that's like a queue on steroids, because of things like the fact that we can have multiple subscribers, and it can push out instantaneously, so it's actually much more than just a queue but I think, it's good to conceptually, think of it like that in many ways all right so now that we've created a topic we want to create a subscription and so, I'm using AZ event, grid, event. Subscription, create and actually I need an endpoint here, and so, what I'm gonna do is I'm gonna come to this function, that I just created I'm gonna be the endpoint for this, a sure function, because this is the, subscription we say hey when, someone, posts a message to this queue we. Want to be able to run this. This. Is the URL we actually want to be able to invoke, mm-hmm, okay, now actually right here I did this intentionally because I knew we were gonna get an error I wanted. To focus on the fact that we had that validation, code and it's saying I couldn't validate well why not well because I didn't actually run the function so, I'm gonna click Save and, run here so the function is actually going to be invoked, and then, once this runs we can scroll, down a little bit and let me just clear, the, console.log, here, so. We can see this happens now what I'm going to do is I'm going to run this validation, one more time so the validation, to, create a subscription it's going to make sure does, this endpoint exist I don't want to get a 404 and. If it does exist great, does, it know how to deal with event grid meaning I send you that validation code do you know how to parse, the message and send the validation, code back and and make that initial handshake and actually I can see back here in the window right, here there's the validation, code that it's sent we're echoing it back yes we know how to deal with it and so we've created the subscription, okay, so, we've created the topic we've created a subscription. Now, sign for our web app - you actually, post a message to the event hub topic so. In order to do that we, need to get the URL of the event grid topic, and the. Key so. What I'm going to do is run a couple more commands, this first command, is to get the actual end point, of the, event, grid topic, and we, can see the end point right there and the, next one is to get the key so. If we look at this end point this is the end point that I need to invoke to actually pop, you, know publish something on the event grid topic, and then, the key is right here now I'm not concerned about anyone seeing my key because I'm going to delete this resource as soon as this recording is done so I'm not worried about from a security perspective okay.
So I'm going to copy this. Endpoint. Right here and I'm, going to put it into my web app right here and. Then. We're going to do the same thing for the key, we're. Gonna copy this, right here, and we're. Going to paste. It right in there now, what I'm gonna do is I have the exact same home controller code this is on line 31, you have the app cue client I'm gonna take this away, and I'm going to use the eg. Client, the event, grid clients, which, I have and I injected. This into my controller and if we look at this this, is just going to, you. Know if. I go to the definition here we're gonna see that this is literally. Just making. That HTTP request. To, post something on the, event grid here. Okay. So here I'm in the controller the home controller and I am going to now just run the app to, control f5 and. We're gonna post a message to these this, event grid topic so, this is my really. Cool, web. App alert. And. Let's, submit it so, same, exact thing you did if I come back to the portal. Here and I. Can see right here this is the message it was instantaneously. Submitted. And we can see right here it says this. Message is my really cool web apple or we can see right here so on the surface very similar, to what you did under, the cover some significant, differences. Occurred which is the fact that we can have multiple subscribers. For our events. It's. Published, subscribed, so we don't have any latency, we get instantaneous, publications. We don't have to do polling which means we use a lot less resources, internally and, I don't have to worry about any of the plumbing or just just just does the work for me it's awesome. Alright. So now we are gonna move on to our last survivalist. Technology, logic, apps, so while functions, was kind of about the code itself in and running, that code and logic apps is more about a workflow, so, it actually provides a visual design, experience, for creating, service, workflows, without, having to write any code so. No, matter how complex like this logic, can get you can really utilize, all the built in connectors, that logic apps rides and you're. Able to kind of create that workflow and visualize it right in front of you okay. So. I'm. Going to actually, now and like. I said logic. Apps comes with more, than 200, connectors, and, some. Of the examples that we keep we can see on here are you know the azure functions, or app service, cosmos, database so some of the core Azure services that you can kind of connect to the same way that we saw in functions, but, however, logic, apps also provides, all of these other kind, of connectors, for Salesforce, or Twitter you. Can do it with off exciting dynamics. 365. Workday. So you get it kind of provides a better b2b. Experience. And you can easily integrate with, all these other. Connector. With, all these other services you know I feel like this is a really important point because a, lot. Of times when developers. First see Azure functions and logic apps they think well how's. Your functions I can look at a queue and do something, logic. Apps I can look at the queue and do something as, your functions I can look at cosmos or a blob and do something same with logic, apps there's, no difference all right well, it's when you really stand in, a way that's true and in. Those scenarios that's really your preference you want to write code or do you want to do drag-and-drop designers, and what. Do what makes you happy and go. About your way but. When you start looking at all these connectors this is where logic apps are really shines you can't do all, these different connectors, out of the box with Azure functions, and you don't have to actually understand, how any of them work you know you don't have to like, figure out how to integrate with, all these different services. And communicate with them and you, know follow their protocols, as you're kind of takes care of all that for you yes very, cool all right so now we, are going to move on to the demo. So. Here I've navigated to, the azure government portal and I've, actually opened up a logic app that I've already created so. Already I'm seeing a difference because instead of starting. The flow. From a cue message it's. Starting it from a new twitter message. Go so that's pretty cool exactly, yeah and and I might actually want to go here and click on you step so we can actually see all of these different triggers, that we have available so if we go to all.
And, We click on triggers we. Can actually see Twitter, is one of the most popular, triggers. We, have scheduled, so you can run your logic I want to schedule the same way that that it's available for functions as well there's, SharePoint, integration you, can import it also. Integrate with office, 365. And. Then, some of the actions, that are also available so. You can, create. A blog or create a file create. A get. A message from an azure queue so these are also available in, your. Jakub workflow. So. Let me go back up to the top so. Like, we said this, workflow, is actually going to be. Triggered. When a, tweet with hashtag, asier is posted. So we, see that we have this interval we can change, that interval to how much, like and. This is actually connected directly to my Twitter account okay. So. Once, someone tweets something with hashtag, asier the, next step is this text translation so, this is actually, just pulling, from the cognitive services API that we have available in Azure so, it's actually sending this tweet text to that API and it's, translating. It to English so that we can do more text, analytics on dit the tweet and. Then. This also is from cognitive services but this is a text analytics API, so we're, gonna send that translated. Text and if you can see here that translated, text is the output from the step before, so. It's kind of showing the workflow we're taking that output and then we're sending it to the sentiment, analysis, and we're, gonna get a score from 0 to 1 0 being negative 1 being positive. And. Then the next step is we're, also just gonna same, API we're gonna extract some key phrases from that tweet for ones, that are a little bit on the long so you can really string these together so I know I hear a lot of people say oh this is writing 0 lines of code it, it really technically. That's true but the reality is you're writing code but you're writing with pictures instead of text right exactly, exactly and that's that is you know preference, right so. Next. This is a really cool operation, so we saw, all of these different, API is that we're taking we're pulling from and connecting, to but, we also have operations. Available in logic apps such as for, loop or an if statements, or joints so these are things you can do in code and. However. Logic, apps kind of allows you to insert these custom, pieces, of code in here where I'm just joining, the key phrases from, an array to a string yep and then. Last. After. I have all of these kind of transformations. On my data I want to write it to some sort of data source so here I'm actually writing it to a power, bi streaming, data set so, I have that endpoint so I was able to specify my workspace, connect, to my power bi account and then, I writing the tweet, text the sentiment score we had before, the, location, who, was tweeted by and then the key phrases and. Now when we scroll down here we can see we have this condition so like I said before we can have an if-else, statement here so if we're saying if, the score the sentiment score is less than 0.3 that's kind of negative we want to be kind, of aware of that we, can post a message to team's channel okay, so we hope it's all positive but if it's not if. It's negative you want to know, about it so we can address the issue exactly. So, now I'm, going to actually, go. To my power bi account, so this is the streaming, data set that we actually saw before and we. Can see here, we. Have the key phrases that we've extracted we, can see the location that the tweets are from the sentiment, score and then the actual translated. Tweet text so things. Like local testing with live data means faster development with Azure Shearman olynyk's we can see most of these tweets are as, you're related so it does a really good job of doing that search. Great. So now I'm gonna navigate to this. Dashboard. So, we had that streaming data set we're writing everything to it I actually, built, this, dashboard, from that data set so it kind of is better to visualize, our data which is one of the perks of using power bi so, we can see we can have the average sentiment. 0.65. We can see the kind of tweet text by location and then we can see this really cool graph, over here it actually, allows us to visualize where these tweets are coming from and the. Lighter the color is it means the lower the sentiment, and the higher means. You. Know the more positive the sentiment, okay, so we can see from the map not only the, hot. Spots so to speak but also, whether. Those are positive or negative exactly, okay very cool and this is all done with just. Dragging and dropping some shapes and the logic apps connecting, them together in the right way and there's. Your power bi dashboard exactly, very cool okay, all right so we've talked about a lot of serverless technologies, here we talked about Azure functions, we talked about event grid and logic.
Apps These are all available on Azure government, today and I think it really is important, to dive into these technologies, to understand the strengths and weaknesses, of each one so you know what is the right one to use in the in the right. All. Right cool all right this has been Steve McLeod me with ujin Hong of the azure government, engineering, team talking about serverless technologies, on Azure government, thanks for watching.
2019-01-12