 Hi there and welcome to another edition of Tuesdays with Corey. I'm here with Ziv Who's going to walk us through you maybe remember him from pre you've been on the show before on? Scheduled events I think in the past. Yep We're doing another iteration of scheduled events today because he's gonna show two of my most favorite things together really scheduled events and Event grid all right together. Yep. Okay, so tell us if what are you gonna show us here? So we roll out scheduled event g8 by the way Oh g8 earlier this year finally and what it what so give some background Scheduled events for scheduled event in VM notification prior to any Azure initiated maintenance or any other event So when the VM is going to be rebooted or paused or redeployed or even live migrated Which by the way we also do right so we're gonna raise an event within the VM So for most of those just to be clear most of those are are not impacting for most customers Correct, but it is still valuable sometimes know so like live migration most customer apps wouldn't even notice or care Right, right, but we still are going to let them know yeah We have an impact so like live migration is a good one failure like a machine's gonna fail We know this from our like machine learning algorithms, and we're like oh, we better migrate them try and keep them up But we still give them a little bit of notice correct Okay, we have like a four different impacts impacts ranging from pause to redeploy it okay, and The challenge was that our customers don't really write to like to write code within the VM Yeah, of course a way to respond react from outside of him right or at least take notice right There's no what happened right so they're not investigating and so actually the the first request was always yeah I want to get an email before it happens right so we decided to harness serverless Using event grid. I love it and just build an extension To go monitor for those scheduled events and put them on event grid and then you can do basically whatever you want with Serverless so customers now the flow here the customers can take this extension Which is just a little bit of code that you've written it's up on github You're gonna share with everybody a little bit of code. They inject it. Is it a windows linux? Yes all the above perfect Python perfect, and it's gonna listen to this the scheduled event It's then going to fire an event based on the parameters that the customer sets right so basically the setting is pretty simple You need to give us your event grid topic the key itself And you can decide whether you want to automatically approve the event and move forward or just give the admin more time So so you can have it for us feedback back to the extension and say wait. I'm not ready. Is that right? That's a default actually So you get basically 15 minutes before anything will happen to OVM Wow Yep, and with that we put it on event grid and you can write logic up or serverless 30 seconds well Between 30 seconds to 15 minutes depending on the event if there's a response Yeah, I see. Oh, but some of the events we do have to do in 30 seconds You're correct like a hard work. I'll give you an example actually. I would love low-priorities cassettes. No, uh-huh Evictions we I we I just recently had a show on this. Okay, or we're going to have a show on this Okay, I don't know the timing of some issues, but Megan just showed us this Okay, so show us so shows what you got so basically the extension is has nothing more than a tiny Python code and You just start the experience by deploying this to a running VM Okay, all you need to provide us is point to the VM and provide your event grid topic and Sasky itself so this is basically spinning up the setting out at arm template that will allow you to go to play this sucker VM custom And some people can take bits and pieces of this they can apply to existing games if they want Okay, you can take it and put it in your template for new resources fantastic apply to existing resources fantastic. Yeah, so Okay, there we go. We're gonna go and deploy template nothing fancy here All that it takes is the VM the location and the grid endpoint and there you guys So you had to have created an event great ahead of time. Yes, I did. I see. Okay. Got it. Okay So we can do that. It basically takes two or three minutes. Let's skip to a VM where we love to skip to one already running So this is my the Julia child version Yeah, and one of the settings is the frequency of how often we want to sample those yes Yes, okay, so I think the default we put it a five seconds You can set it to whatever you want so I'm monitoring here for scheduled events nothing happened My VM is still running actually to show you that this is real. Let's start again So I'm monitoring for events in the meantime. So this is on the box This is inside the box. This is running the extension right now So they wouldn't have to have run that it would just run automatically for it Okay, great before actually hitting something on the VM. I want to show you my logic up Okay, which does nothing more than listen to that event listen to that event from event grid What do we got here? I don't know refresh it here There you go Here we go. Yeah, so here we have the logic apps So we have the logic app and basically what it does it listens to the event grid and Put the message in a blob storage. Yes and send an email. Yes, very simple. Even I can write this code, right? I'll show you the designer designer This is very cool. So this is so basically the event grid is using a custom event because you're just calling it It's like a rest endpoint. Yep, right? Yeah, and they go. Okay, fine. So the event has The message itself has an array of events sure array each event may impact multiple messages so basically For each event in the body put in a blob and for each for each blah blah blah send an email, okay? Verical this is the default. This is what build comes out of the box. No, this is something I built I you built this so people have to go build their own logic correct, okay, and it's okay It's something it's pretty easy. It's pretty easy. It's pretty easy Nice trick I learned is if you paste the payload itself to in logic up you get the schema Yes, and then you can you can see that here for example. I can do many things with the Properties of the event. Oh event type event. So yes, so the actual message will look like And then you have the timeline the not before so this is the data that's coming out of your event correct event The details of your events. Yeah, so this is all coming through here. Then yeah, okay. There you go I see so that's the event. So so all I did is I pasted Jason here the Jason and logic up actually build a schema And enable me to use it later on got it and so this is all in your get how the basic the steps of how to do This is all available on there. Yes. Oh, okay. So now let's go and actually run this live and see how fast we're gonna get an event So again, my VM is still monitoring for the scheduled events and what I'll do is I will go to My VM and one of the best thing I scheduled events is that you can yes Sorry, I can't jump the gun on that. I apologize. They've go you know the drill Go so we can actually trigger scheduled events by actually calling any portal activity like restart and redeploy This is your own ass. So your own people's actions can group can basically turn into a schedule event Right, and those will wait if you want them to wait. They'll wait. They will wait forever 50 minutes. Yes, you want forever? Oh, well, okay So so that's the best I can wait to actually test this logic So I'm gonna start I'm gonna click restart and yes, and now Let's look okay, and so this is your it's been dialing bell here. Yeah, so the portal send event hold on It didn't get to the VM. Yes yet Plop-plop-plop portal go find the right region cluster and so on till the fund event Still running so the VM base is being told now to go read now And there you go. Okay. You got told the reboots. I should see how fast I'll see the event Okay, so let's see here hold on schedule event yet. No, yeah, and so this is And so now you see the event ID It says status scheduled reboot scheduled and let me actually go and check my inbox And let's see did it email you alerts There you go 430. That was it. What was it? No, it's right. No, no, you sort of the other way sort the other way This is awesome, right there, that's it right there 430 there you go. Yeah, so you see that the logic app see everything in it See so I get a beautiful there you go and there you go and now it's a warning It's already in the blog and now you could do but you can do with integration and with logic If you can do all kinds of things you can make a service now Yeah, you can make a mess cold We could tweet out The best what if I have a stand by VM I can fire it up fire it up fire it up Yeah, imagine you have two VMs in an availability set one service as your stand-by Anything that you could possibly do with logic apps you do you could do cool. That's it sit up. You got it All right, we're not editing any of that. I know we are and thank you zip This was great and thank you for joining us I hope you have a happy happy Tuesday If you've got questions on this or comments or things that you'd like us to see us Go update this sort of how to you can hit us up on hashtag Azure TWC this first wave is with an extension that installs We are working on this being natively built into the platform where you can just click a little button in the portal And it'll turn this all on and wire it up for you. You can expect that later this year So with that have a wonderful Tuesday. Enjoy playing with this. I hope you enjoy it's gonna be really valuable for you Thanks a lot and thank you. Thank you sir. All right. Bye. Bye We're working on making this is a full-end itself is fully operational This battle stations fully operational Oh, I hope you got that because that's a fantastic quote You can be adding a lot of Right when's the next Okay, we put that like it's a trap So What you know of course all right, how do we get out of here? You started the record yet You know what this is now you're gonna see what it's like to be permission to treat the witnesses All right, we're recording. Can you move your coffee about six inches that way? Thank you. That's good