Run PowerShell Scripts with Azure Automation Hybrid Workers on-premises using Azure Arc

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's have a quick look how we can use Azure automation together with Azure Arc as hybrid workers to run your Powershell scripts on premises and also schedule them on your time [Applause] [Music] hi my name is Thomas Maurer I'm a program manager for Azure hybrid at Microsoft I know that like a lot of automation is needed to keep your environment up and running right and with Powershell and others we have great languages to do that now one of the challenges very often is like hey I need to have this automation script I need to schedule it and run it in my environment right and there's the ways of doing that and there's some like on-premises automation tools which are great but then if you're using a hybrid Cloud scenario and if you're using Azure we have a very good solution with Azure Arc for you and this also not just works on premises it actually works also on machines running at other Cloud providers and that's all we're using Azure Arc so here we are in the Azure portal and what I already have done here is I onboard ordered a couple of servers here which are running on premises or at other Cloud providers to my Azure environment using Azure Arc so for example here I have a hyper-v server again this runs locally in my local data center and it is now like an Azure resource it's very simple to onboard basically I need to download an agent install that agent and then register that with my Azure environment and if you want to know more about this I have a video about how you can onboard your service to Azure Arc because every single uh Azure Arc enabled server Linux and windows becomes a hybrid worker you can actually leverage so if you go to Azure automation or automation accounts in the Azure portal that is where you find your automation account now if you don't have one you obviously need to create one and then connect your server to this again I will put some links in the documentation below so you can actually find how to do that if you haven't done that before now one of the things you can do is under run books you can create your Powershell runbook so I'm just going to create one here let's say run book testing I can then Define a type and you can see I have a couple of different options I can use Powershell I can use Python I can use some graphical tooling as well and then you can select the runtime version so we can use like Windows Powershell 5.1 or we can leverage a Powershell the cross-platform Powershell with 7.1 so I'm going to take 7.1 here to use that I would obviously give that run book a description and then actually simply create that so when this is created I get this online editor right and so here I could actually paste or write my Powershell script so what I'm going to do here I'm going to write a very simple one and this does list for example my VMS right it's just simple get VM or for now let's use get service because we can run that on basically any Windows Server very simple command I could obviously go way more complex and really use like whatever I need to do I can build in Loops I can build if statements and so on if I want to do that now let's save that run book and then also publish that runbook when I'm done so if I would run this now so this is the Run book so I could run this it would run by default on a Azure worker note right so I don't need to care of any of that I just like hit run it will run on a temporary machine in Azure and so this is also great if I want to automate things in Azure right if I do want to like get acvm or do some changes on a on a VM I could just simply automate that and then have a couple of other things but in our case we want to run this on a local machine running in my own data center or Edge location right and for that what we need to do in the Azure automation account is we need to go to hybrid worker right so hybrid worker or actually machines which have the arc agent installed and then these are basically targets to run these um uh scripts or these run books on right and usually if you want to automate your environment you don't want to have just one server because if one server crashes for example um you still want the Run book to run right so you create a group of these hybrid workers so you would just go and basically tell this uh this is my um let's say this is on-prem group for example I can then also use what credentials this Powershell run book should run on like if you create a user in um on the machine itself or in active directory it would take these credentials now for this we just use the system as well and then what I want to show you here is you can then add these machines right and what you can add here is basically Azure VMS but then also Azure Arc enabled servers I could basically use a dedicated group if I want to build some automation or if I just want to run on a specific server I could select that I already have done that I already created a group here called The Arc workers so these are again you can see here in my worker group I only have added one server when I now go to run books I can actually go and take a run book here in this case I have created a hybrid Powershell runbook so that's the name again they're better names to choose from depending on what you want to do but then you can go and edit and this one it just says get VM because this I want to run this on a hyper-v server I just want to get all the VMS running on that server so that's why I use this so I'm going to publish that version now of this and what I can do here is I can now simply just hit the start button on that run book and then since I now have a hybrid worker group it add it asks me the question where do you want to run it do you want to run this on an Azure worker or do you want to run it in your hybrid environment so in my case I want to run it on my hybrid workers and then I select my hybrid worker group again I have a couple of them here but I'm going to run it on the Azure Arc workers and select this and this will now basically take that run book queue it up and the agent on that machine will pick it up and then we'll run it now um you see there are multiple options here what I'm interested I'm actually interested in the output right now again in some cases you just want the script to run and to do something and you're only interested in the output if there is something wrong right but to show you what you will actually see let me quickly hit refresh here and you can see here I get like what get VM would give me back so you can see here it gives me all the VMS running on that type of V server pack so that is what I expected right so super simple I can for example also add a web hook so I could like automate it from another tool or I could link it to a schedule so if I click link to a schedule I could create a new schedule and tell this hey this is my first day schedule and then I could basically go and select the next Thursday you can select set the time and then I can make it a recurring schedule so I could set hey run this every week on Thursday and like it could set an expiration date right so let's create this schedule here I can also set parameters right and now again I need to configure if this is running on some Azure workers or on my hybrid workers in our case we want to run this on our hybrid workers and so you will see here I can again choose the group I haven't defined any parameters in my Powershell runbook but if I do I could now say hey on Thursdays I'm going to give that input on Sundays for example I want to use another input so for example if you run this like you want to stop different machines at different times you could use the same runbook but different parameters based on the schedule right so that is pretty cool so I hit ok now and then I basically link that um uh schedule to it and again you can see here it's now linked and so this is how it would now run uh on next Thursday to actually get that information super simple to set up and to do and you can do way more uh with Azure automation right there's also possibilities to store uh securely store credentials on this which you then can reuse again in your own book so you don't need to put credentials in your run books you could safely store them in here um you also get a couple of other features which you can use like different modules you can embed there's even a gallery with run books you can go through the other great thing I want to mention is that you can actually go and integrate your Powershell runbooks together with GitHub for example or git repositories so you can actually do Source com like source code all right so you get like hey this is the version and you actually have that in the repository and you can mention you don't just can do it over the Azure portal but you can actually check in the code into your repository uh which is great so I hope this short video was useful to you and shows you how you can run Powershell script in your on premises or Edge environment to automate all sorts of things there so thank you very much for watching I hope you liked that video hit the like button subscribe to the channel and hopefully see you in the next one foreign [Applause] [Music]
Info
Channel: Thomas Maurer
Views: 5,612
Rating: undefined out of 5
Keywords: Microsoft, Azure, Azure Automation, Automation, Hybrid Cloud, PowerShell, Azure Arc, Hybrid Worker, on-premises, edge, Hybrid
Id: oeKk-Hj3Aw8
Channel Id: undefined
Length: 10min 52sec (652 seconds)
Published: Sun Nov 20 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.