Azure Monitor with Automations

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello world and welcome to this edition of tech on fire with blaze i'm blake stewart architecture one luck and today we're gonna be looking at how to use automation with azure monitor [Music] hi guys today we'll be talking again about azure monitor and how you can use this for monitoring azure as well as responding to events that happen in your azure environment today we're going to be extending azure monitor looking at how you can use it to invoke automation that is integrated with azure monitor so that you can do things on azure so first we're going to do a quick review of what azure monitor can do and then we're going to go right into the azure portal and set up some automation just using some tools that are readily available in the azure portal so just a quick review of what azure monitor can do azure monitor is a solution for monitoring things deployed to azure vms web apps or other services that you have running on azure it can also monitor azure itself so you have all of this telemetry coming out of all these different resources into azure monitor then azure monitor can perform a lot of different tasks on that it can do things like monitoring obviously that's building things like dashboards it can look at things like logging which we're going to be looking at in a future video it can do alerting which we looked at last week and it can also do various kinds of automation and that's the purpose of today's video where we're looking at how you can use azure to do automation it looks very similar to how you can do alerting but there's some nuances and some extensions that you need to be aware of for doing this so azure monitor is a triggering mechanism for triggering automation jobs that exist in the context of azure or off of azure and there are a couple ways that you can do that so you can have azure automation runbooks automation runbooks are basically scripts that you can run on azure to do various kinds of things so this could be like a powershell script that will turn on a vm or turn off a vm or update some kind of database or add something to a log or anything that you could automate with powershell is something that you could probably trigger through azure monitor and then have it run as an azure automation runbook it also supports python as well so you can write scripts in both python and use the azure sdks to do things on azure or you can just simply use powershell scripts and there's a whole lot of plugins there inside of azure automation for running powershell scripts there you can also trigger things like azure functions azure functions are on top of azure web apps or azure app services so that you can write serverless code and then have that triggered by azure monitor and it will be able to invoke those functions and it can do any number of things that you can do with an azure function then you can also use itsm solutions with azure and an it sm is an it service management this is basically for managing things like help desk tickets so if you have an itsm solution you can plug that into azure monitor and then you can automatically generate tickets for people to respond to so if there was something that you're monitoring with azure monitor and say there was a fault and it had a severity of say zero and you wanted to work with that you then you could go into the itsm solution and connect that up to azure monitor and then have it automatically generate a ticket and then your it help desk or your engineers can respond to whatever event is going on in your environment you can also run logic apps from azure monitor logic apps are the serverless model for building out various kinds of integrations on top of azure or outside of azure it's really designed for building workflows in a visual designer you can do some of that in automation run books but logic apps has plug-ins that extend well beyond the scope of what you can do with something like automation runbooks which are principally oriented around azure resources logic apps has a whole suite of plugins for various kinds of things like sap it can integrate with different kinds of storage options and databases it can also be triggered by azure monitor or through web hooks or any other number of things like that so it's a very rich ecosystem for building out basically workflows for managing things on azure and lastly you can hook into web hooks both secure and unsecure web hooks on azure now it does have the ability to choose between a secure or unsecure a web hook and an unsecured one would be one that's just on the http protocol and one would be on the https protocol and the amount of telemetry it sends to that web hook will vary depending on what you're doing with that web hook and if whether or not it's secure or not and it's not going to be able to send all of the same kind of data on an unsecured channel as it would on a secure channel you want to make sure that you have https for most of the time if you're going to be doing web hooks anyway that way you can just choose secure web hooks for that reason so all of these different kinds of solutions for automation exist inside of azure monitor and you can just hook up those solutions right into azure monitor right in the azure portal so we're going to look at how to do this in a quick example where i'm going to use azure automation runbooks and integrate that with azure monitor to be able to automate something on a virtual machine so i'm here in azure and i want to show you what i have set up for this so to make this work i need something that can be triggered by azure monitors so to do this particular demo i use azure automation accounts now azure automation accounts are a tool for running things that are in the azure ecosystem this is something that you would use for automating things within azure now if you want to go beyond that of course azure automation is probably not the best tool for that logic app or functions might be a better choice there but azure automation gives you a lot of pre-built scripts for doing a lot of different kinds of tasks on azure so that's why i chose it for the particular scenario that i'm going to be looking at here today so what i have here is an automation account and i have here a virtual machine now the simulation that i want to do here is i'm going to suppose that i have this vpn and i have an app running on it and i want to in the event that perhaps this vm got shut off by accident i want to start it up automatically i want something to just start the vm whenever it's it gets stopped so that's the scenario i'm going to simulate here and i'm going to use azure monitor to monitor the vm when it shuts down but i'm also going to use azure automation to bring that vm back up once that event is triggered so i already showed you how you can use alerting last week's video whenever we looked at alerts and it's basically that same alert but i'm going to add a piece to it through the automation and that's what i'm going to look at in azure automation i'm not going to spend a lot of time talking about azure automation in particular because it's not really what i want to demo here but i do want to look at it just because it's the tool that i've chosen for this and the principles that i'm talking about here would need to be applied to whatever uh various kind of environment that you're going to be triggering from monitor the trick here is just making sure that you can trigger it from monitor so for my scenario here i just simply went down into azure my automation account that's in the same region and in the resource group that i have and i went over to the gallery and i chose a runbook from the gallery and if i go to runbook gallery here you can see that there are a bunch of different kinds of scripts that you can use and you can say where's the source coming from come from powershell gallery and from github and come from script center any one of those would be fine most everything's going to be moving to github anyway in the future i guess that's what this script center is retiring everything's moving good up yeah okay and then you can say what where what kind of script is it powershell graphical or python who published it microsoft for the community and so on i chose one of these right here to start my vm so start azure 2v2vm that's what i have so i'm going to choose that one and that is what i used for my runbook so once you choose this you can simply click import and then that puts it into my runbooks on my automation account so if i go to my runbooks i now have it right here and i can see it and my run books these are just the defaults that you can see these are samples you can delete those if you don't care but here's the one that i'm going to be working with and it's currently in edit because i haven't published it because i added it so i'm just going to simply that's going to show me the history if i want to edit this one i can click on the the edit right here and then go into publish and that's basically what saves it makes it available for running and so i have now published this and now it's ready for you so this is where i can then hook up azure monitor to my automation runbook here now of course the process for getting something like logic app or something like a function is going to look different you get in a state where it can be invoked but the same principle applies you need to have it in a state where you can call it and in that case for a web app or a serverless application on azure functions you would need to put that function in a place where you could call it and then same thing with logic apps you need to have that published as well so let's go back over to our resource group and let's take a look at our vm here and the vm is going to have a couple of alerts connected to it now the alert that we looked at last week was one that was simply doing some kind of job to alert me when the vm got turned off or and deallocated and that basically sent me an email and that's still what i want to happen but i want to automate it so it comes back up so i'm going to basically just use the same event to trigger the same the to trigger the alert as well as trigger the automation run bug so if i come down here you can see actions the criterion up here the condition for it all that stays exactly the same down here under actions last week i set up this blaze group email group for notifications now i want to extend this by adding a script to start the vm up and that's what i did right here in this action name so let's go over here to manage the group and i'm just going to drill down into this one right here and i can turn it off and on i'm going to create a new one just to show you what this process kind of looks like and if i was to go into this one i can just say you test123 and go over to notifications i can skip this all together and go straight to actions i could also put notifications and actions on the same the same event and have them fired at the same time i have them separately because i was demoing them separately and here's where i can choose the kind of integration i want to use and so i notice i have automation run runbooks azure functions itsm that's your it service management and here's my logic apps and here is my webhooks that i can use there and so if i went into automation runbooks it's going to ask me do i want to use a built-in runbook or a user book and then i can pick the subscription and then the automation account and then choose the the run book that i want to use and here's where i can configure the parameters here uh give it this is my resource group name and the vm name that i'm using for this particular one i've already gone through this process so i'm not going to do it again but the basically the logic is the same the process is the same if i was going to do it for brand new runbook and once you have that saved you'll see it show up right here underneath the actions so i didn't have to write any code for this i just used one of the available scripts out of the gallery i put that in my automation account and then i just plugged in the variables for it and then i connected that up to actions underneath my rules underneath my azure monitor instance here so what should happen in this case is if i start stop my vm it should come up automatically after a period of time from this particular runbook and i should also get an email because that vm was stopped so let's go ahead and stop the vm and see if all this actually works so i'm going to come back over here and i'm just going to come up to my overview on my vm and i'm just going to stop it and then we'll come back whenever this comes back up and then we'll look at the history and then how the job got invoked and all of that okay it looks like everything came back up and my vpn is running so let's look at the actual alert and see what happened so here is the alert panel for this particular vm that is powered by azure monitor if i come over here into the alerts i should be able to see something that fired recently so i have this one right here 12 35 and it is now 12 41 so about five minutes ago this fired so if i come down into the event itself i can get a more detailed view about what happened here so this particular event happened because i turned off and deallocated the vm by hitting the deallocate button or the stop button inside the azure portal and that then fired this event and that triggered the actual jobs and actions that i have associated with it so if i go over to history it'll show me the actions it took that are associated with this particular alert and this is the one that sends the notification and i will get an email telling me this action fired the the vpn was turned off and it'll tell me when it happened and so on and we've seen that already this is the one that fired whenever i turned it off and it triggered the automation run bug so if i go into this it's just going to show me the settings for this particular action that i have here and i can just you know see it and see the settings for it and it's just an automation runbook and there's the script i have associated with it but if i wanted to see the history of the actual automation runbook i can come over here to automation account and i can click on jobs and this will show me the run history for the jobs that ran with this one and this is the one that looks like it was associated with it right here i click down on it it shows me the actual parameters that i had with it and it started up the vm and everything looks to be running fine because it got called with the parameters that i put in inside of azure monitor for this particular script inside of my automation account and you can see here it was calling it through webhook data if you wanted to use webhooks this is also the object you would get for web hooks if you got called from azure monitor you get this basically the same data right here but all in all you can see here this is the output essentially from the automation run job that was triggered by azure monitor and now i have my vm that will turn back on in the event that it gets turned off so again this is one way that you can use azure monitor because you can integrate this with so many different solutions the sky is the limit really what you can trigger from azure monitor you can basically tailor it for whatever needs you need it to do in azure or outside of azure you can do all kinds of cool things with it if you like this content please consider visiting us online at www.wintelec.com and there you can find about services that whenelect offers including training and consulting services also please consider subscribing this channel by clicking on the subscribe button and clicking the bell icon to get notifications when new content becomes available and also comment down below you can also follow me on twitter at the one mule and also follow intellect on twitter at winnelec now or at whenelect we are constantly posting things about azure related technologies and things related to software development you can also reach us by email at consulting whenelect.com until next time thank you [Music] you
Info
Channel: WintellectNOW
Views: 521
Rating: 5 out of 5
Keywords:
Id: nab0EyG5H5c
Channel Id: undefined
Length: 16min 14sec (974 seconds)
Published: Fri Jan 22 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.