Azure Event Grid Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

We started using Event Grid a few months ago and it quickly spread throughout our engineering teams. I wish there were another way to provide security for webhook subscribers that wasn't merely [a secret in a query parameter](https://docs.microsoft.com/en-us/azure/event-grid/security-authentication#event-delivery-security) (which will be visible upstream in things like Nginx logs). On the whole, however, we are really happy with Event Grid: it's easy to set-up and it "just works".

👍︎︎ 1 👤︎︎ u/erewok 📅︎︎ Oct 01 2019 🗫︎ replies
Captions
if you're building real-time applications or applications that react to events I have a just perfect service for you it's a highly scalable highly reliable and a cheap service Azure event grid this is Adam and today introduction to Azure event grid stay tuned so let's talk about event grid, event grid is a fully managed event routing service so its main purpose is routing events so if you're building those real-time near real-time applications that needs to react to events being in Azure or non azure services this is one of the best services you can use so let's talk about some key concepts first of all you have event there's a description of something that happened you have event source this is the place where the event was taking place for instance a lot of event sources in Azure la are lob storages resource groups and other subscriptions so you can react to events for something that is happening within your subscriptions there are event hubs media services IOT hubs and many other services next you also have something called topic a topic as simply said is a restful endpoint where you can send your custom events if you're building applications there's an even subscription so whenever there's an event coming into a topic you can subscribe and handle those events within your applications those are called subscriptions and lastly you have even handlers so those are the applications that handled those subscription and the event that are coming from them and here you have a lot of life examples like serverless code with functions you have integration services like logic apps you have some buffering and competing consumers like event hubs storage queues and other applications like web hooks which pretty much is any service out there other automation but also it's not mentioned here but you can use that with services like data factory to trigger your ETL workflows whenever there are new files coming in so couple of scenarios first of all one of the most common scenario for event base architecture using even grid is serverless so you can instantly pretty much near instantly react to events like on blob storage so whenever there's a new image coming in you can react using event grid and process that image immediately additionally you can do operation automation since I already mentioned you can react to events in your resource group and other subscription you can notify services like other automation to run some Diagnostics run some operation automation scripts on your infrastructure in Azure additionally you can do any sort of application integration because there is something called even grid topics which allow you to create custom endpoints and send custom events to your other application so it's a great tool to do application integrations what are the key benefits first of all simplicity is just couple clicks and the service is working there's something called filtering so you can actually when creating subscription you can create filters and only react to a subset of events coming through out of the box without needing to code anything you can do fan out scenarios so when one event is coming through you can have multiple subscribers listening to the same event so you can very easily code that functionality you have reliability in which cases one of the actually very cool features when your service will fail to process the event event grid will try to send that event over and over to your service for 24 hours with an exponential back-off so it's very very good feature and lastly the cost is actually quite small because you pay only for one million operations for 60 cents so it's quite good price for what you get what are the capabilities of course you pay per event so the pricing is very good it's one of the key features of the service there's a very high throughput because you can actually process even millions of events per second it's a it's amazing feature there are built-in events so as we already been saying you can react to blob changes to Azure resource changes a lot of built in events that can you can already hook up to and you can build custom events if you need that additional integration between your application components so today we're gonna have three demos first of all I'm gonna use logic apps to consume built-in events in Azure to react to blob changes second we're going to also use logic apps to send some custom events to our event grid topic and the third I'm gonna use the custom event grid topic and a create subscription so that a lot of services in this case I will use logic app and I will use Azure storage queue to handle those events so let's go into the portal so for our first demo we're gonna need a storage count so let's go and create that let's go hit on storage account select our subscription and select our resource group let's give it a name I'm gonna called event grid demo that's already taken so I'm gonna add one I'm gonna leave everything else as default so hit review and create and hit create this deployment takes about two minutes I'm gonna wait for that and we're done the reason that I wanted to wait for storage account is because event grid is different than any other service because normally you would go to this plus and just type event grid to get your event grid service the difference is event grid is essential service in Azure so the only things you actually create are topics and subscriptions but since first demo is using built-in events we don't actually have to create anything so you can go directly and start creating our logic app so let's do that so our logic app will be called new blob event and I'm gonna put it in our resource group and leave it in north Europe so review and create and let's wait that was pretty quick we already have the logic app so we can go to the resource group and see our resources so in order to do this demo I need to first go to the storage account and create a container called demo to this container I will upload a file but before I do that we need to make sure about two things first of all you need to go to your subscription and to check if there is event grid registered so this is one time operation that your administrator of your subscription needs to do because if the event grid is not registered globally you're not going to receive any events so go to your subscription go to something called resource providers and find event grid so in my subscription is already registered that means it's centrally working and I can start using it so since we have our storage account and a container ready let's go to logic app and start from the blank application and use event grid you can search for it but I already have it here and there's a built in event when the resource event occurs so I'm gonna use that as a trigger I'm gonna sign in I'm going to sign in using my account but you can also use it using service principle so what do you need to pick in order to use built in event you need to pick a subscription you need to pick a resource type in this case this is a storage storage account type of resource and next we need to pick a resource name that's going to be our even grid demo1 and what kind of event you're reacting to in which case I'm reacting to Microsoft storage blob created so now I can actually save this and test this so I'm gonna open one more tab actually two more tabs in this tab I will open our storage account so we can quickly upload files and go back to the logic app to see the results so we'll go to the blob go to the demo hit upload and select from the file any sort of fun this can be this movie CSV file let's upload this and let's go back to our blob and refresh and notice that this logic app already run it run really fast we didn't have any delay no no waiting no no checking it immediately run as soon as the file landed because even grid is really fast it's designed for those real-time applications but notice something interesting if I will go back to blob and create another container called demo 2 and upload file there let's go to my sample files and upload three files and go back to logic app and hit refresh it also run on a second container and this is one of the good features but also a feature that you should be aware of and be vary of when you're designing you need to use filters to filter only events from a single container to do that you go to edit and you need to edit the trigger and add a filter so you add a new parameter and a prefix filter and put the prefix filter like this this is a static way of managing and events and filtering events from containers and you basically just grab this from documentation so by typing hidden demo - I'll make sure that I only react to events from blob services default containers and a container called demo2 so let's save this again and test again so I'm gonna upload two files into this container I'm going to overwrite those and I will go back to the demo container and upload six files actually seven so let's hit that lets upload we're done I would be expecting that since I uploaded only two files in a second container I should have only two executions of the logic gap so let's go here refresh and we have only two more that's perfect you should remember to make sure that this filter is there because it's very easy to make a mistake and do a circular dependency when you're triggering of the storage account and putting the files on the same storage account and burning through money like butter so make sure to get that filters in so this was the first demo this was how you can actually consume built-in events in very rapid manner you just use any service that can hook up to even grid like logic apps restful APIs and just use the events that are already there so let's go for the second demo in the second demo we're gonna create a custom event to do that I'm gonna hit plus and type even grid and I'm gonna create a new topic this topic will be my custom even than I want to do so it's gonna do I'm gonna call it new cars I'm gonna select subscription I'm gonna select the resource group a region of course I like to have everything in the same regions are north Europe and leave the schema as default hit create and wait a minute since this is done we can go to the resource in our resource group we see our new event grid topic called new cars and right now we can start sending events to this endpoint let's try that let's go to and actually let's create another logic app that will be called some send events we will use this logic app to send some custom events to our event grid topic so let's get create and within a couple of seconds we will be able to create a logic app so let's go to the resource go to designer I like to start for the demos with httpd trigger because it's just manual since I will be hitting run anyway so I'm adding a new step and I need to this time instead of using azure event grid I need to use azure event grid publish so I'm hitting on this step and there's a action called publish event so I need to specify what is in the name of the connection that's gonna be in new cars I need to specify what is the endpoint so the URL for your event grid endpoint to get it you go back to your event grid and there's a topic endpoint here so I'm just gonna copy that paste it here and you need to give shared access signature SAS token to authorize to this service you can get it from the access key blade so copy that again go back to this and hit create now that you saved the connection you can start sending events so first of all you need an ID for ID I like to always use expression with GUID what is the subject I'm gonna call it new car what is the even type well that can be the same it's not really relevant those information are relevant if you're writing those filters later on so it's already your application logic from the perspective of this service this can be any value here and of course the data single aside and JSON so there's gonna be audi and maybe I'm just gonna add some random number and I think that's it so let's save and let's test this so I'm gonna be sending one custom event with randomized car into my event grid that we successfully checked the trigger and we manually run the step and we've sent our Audi 75 into even grid and that was the second demo because this is already sending events to your topic but as you can imagine this is not full integration yet because no one is listening for those events there are no subscriptions on this event grid yet and to do that I will go back to my event grid topic and hit here on event subscription so I'm gonna hit plus and create new subscription I'm gonna call this logic app subscription to create logic app subscription I need to have logic app that will allow me to call it and before I go there and create that logic app you need to know what endpoint is supported and there are a couple of endpoints that are supported right now from drop-down here you select what kind of endpoint this is there it's a web hook so this can be any application is gonna be that case for us for the logic apps we're gonna use a web hook but you can automatically put it into storage queues I'm gonna show that in a second but there are also event hubs hybrid connections and service bus queues so I'm gonna use web hook and before I can actually give it I need a new logic gap so I will hit plus and create third logic app I'm gonna create a logic app that will be a simple web hook that I can call to simulate our restful endpoint for our applications go to the resource and I don't really need anything besides HTTP trigger and just saving it after we saved it we get a unique web hook URL to our logic app so I'm just gonna copy this URL and go back to our subscription select an endpoint paste it here confirm selection and hit create subscription was created we now have one subscription that is listening for our car events so if you go back to our logic app designer the one that is sending events send events logic app I'm gonna run it again in the meanwhile I will go back to the web hook demo and I will focus here on a rough refresh history so let me actually refresh and it already came through so this that furnished published even to even tab and even have immediately sent event to the subscriber to this web hook and lastly let's show you how easy it is to get multiple subscribers in I'm gonna go back to the resource group I'm gonna open the resource group and for this demo I will use the storage account queues so I'm gonna go here open storage Explorer and create new queue called new cars I'm gonna open that queue and show you it's currently empty so to take leverage of of this functionality you go back to your resource group go back to your even great topic and create new subscription since subscription we already said is this fan out scenario you can have multiple subscription for a singular topic so this is gonna be our queue and the end point type in this case is storage queue you need to select an endpoint select the storage account hit this one and select the queue confirm selection and hit create before I do that this is also the place where you can specify filters so you can react to subset of changes if you want you but I'm not gonna do that there's gonna be separate training on that and you of course have some more advanced filters here as well so let's hit create and right now we have two subscriptions so going back to our example let's refresh the resource group on this tab we have sent even slogic up and let's run that trigger a couple of times see you see I've run it three times therefore I'm expecting that on my cue I have three events so it's working just fine and of course I can go back to to the resource group and also confirmed that my webhook was also called three times each with a new car information and that's it this is how easily you can leverage even grid in your applications now that you know event grid just go and start using it in your appli cation it's fast and easy so just go for it that's it for today if you liked the video hit thumbs up leave a comment and subscribe if you want to see more and see you next time
Info
Channel: Adam Marczak - Azure for Everyone
Views: 51,530
Rating: undefined out of 5
Keywords: Azure, Event Grid, events, messaging, Beginners, Tutorial, How to, azure event grid, event grid
Id: TujzkSxJzIA
Channel Id: undefined
Length: 21min 43sec (1303 seconds)
Published: Mon Sep 30 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.