1 00:00:00,740 --> 00:00:02,680 [Autogenerated] Alright, let's continue on our journey. 2 00:00:02,680 --> 00:00:05,110 We're going to go back to the automation account, 3 00:00:05,110 --> 00:00:09,240 we're going to take a look at run books and desired state configuration. 4 00:00:09,240 --> 00:00:13,930 So let's go to run books and let me give you the rundown on run books first. 5 00:00:13,930 --> 00:00:15,600 Under process automation. 6 00:00:15,600 --> 00:00:16,320 Run books. 7 00:00:16,320 --> 00:00:19,510 This is where you can create a run book from scratch. 8 00:00:19,510 --> 00:00:22,740 We can import a run book safe from our local system 9 00:00:22,740 --> 00:00:24,510 or we can browse the gallery. 10 00:00:24,510 --> 00:00:25,760 The gallery is pretty cool. 11 00:00:25,760 --> 00:00:29,690 It defaults to GitHub but you can also look at the PowerShell gallery and 12 00:00:29,690 --> 00:00:32,930 you may find that somebody has already created a run book that 13 00:00:32,930 --> 00:00:35,700 accomplishes the goal that you had for your business. 14 00:00:35,700 --> 00:00:38,730 So the idea here is that you can import one of these, 15 00:00:38,730 --> 00:00:41,730 you bring it into scope into your subscription, 16 00:00:41,730 --> 00:00:45,170 need to give it a name, I'll just call this import run book, 17 00:00:45,170 --> 00:00:47,290 you choose what PowerShell engine. 18 00:00:47,290 --> 00:00:48,280 runtime you want, 19 00:00:48,280 --> 00:00:51,610 you've got 5.1 that's PowerShell desktop or 20 00:00:51,610 --> 00:00:53,870 PowerShell core that is in public preview. 21 00:00:53,870 --> 00:00:56,250 As of this recording, I'm going to choose 51, 22 00:00:56,250 --> 00:00:59,440 then you import now things can get a little bit hairy 23 00:00:59,440 --> 00:01:02,260 in the run book space number one, 24 00:01:02,260 --> 00:01:05,930 you want to make sure that you've updated your PowerShell modules. 25 00:01:05,930 --> 00:01:07,840 If you're going to use PowerShell seven, 26 00:01:07,840 --> 00:01:11,750 you want to make sure that you have the seven modules actually available. 27 00:01:11,750 --> 00:01:15,820 You can install your own custom modules into the automation 28 00:01:15,820 --> 00:01:19,380 account and reference those something else to be concerned with 29 00:01:19,380 --> 00:01:21,620 is the concept of authentication, 30 00:01:21,620 --> 00:01:25,800 I had mentioned that the default way to authenticate or at least 31 00:01:25,800 --> 00:01:30,250 the V one way to authenticate is to use the run as credential 32 00:01:30,250 --> 00:01:33,750 but the V two way to go is to use a managed identity that can 33 00:01:33,750 --> 00:01:35,190 get a little bit snarly. 34 00:01:35,190 --> 00:01:37,530 The good news is that we don't have to worry about 35 00:01:37,530 --> 00:01:39,630 that for the purposes of the exam. 36 00:01:39,630 --> 00:01:45,190 The idea is that you can work on your code here and then you can test the run 37 00:01:45,190 --> 00:01:48,540 book before you publish it and make it available for you. 38 00:01:48,540 --> 00:01:53,330 So let me go back to my run book list and I have a gallery run book 39 00:01:53,330 --> 00:01:56,530 that I've brought in called Start Stop VM by tag. 40 00:01:56,530 --> 00:02:01,130 This is going to allow you to either issue a shutdown or a startup command to 41 00:02:01,130 --> 00:02:05,560 Azure or non Azure VMS based on their taxonomic tag value. 42 00:02:05,560 --> 00:02:09,520 So this could be useful because you may want to schedule a fleet of 43 00:02:09,520 --> 00:02:12,770 virtual machines to start and stop on your schedule. 44 00:02:12,770 --> 00:02:15,230 If you don't need them for certain periods of time, 45 00:02:15,230 --> 00:02:18,340 why pay for them to run This is one of the most popular 46 00:02:18,340 --> 00:02:20,980 use cases of the run book in general. 47 00:02:20,980 --> 00:02:23,580 I want you to think about the automation account. 48 00:02:23,580 --> 00:02:27,160 Run book is a convenient cloud store for your systems 49 00:02:27,160 --> 00:02:29,390 administration automation scripts. 50 00:02:29,390 --> 00:02:29,850 Okay, 51 00:02:29,850 --> 00:02:33,400 now let's go to edit and we'll look at the raw code then 52 00:02:33,400 --> 00:02:36,040 we can go to test Pain and test it out. 53 00:02:36,040 --> 00:02:39,040 So you're going to wind up if you're using the portal to be 54 00:02:39,040 --> 00:02:42,770 doing your debugging and optimization here by iterating 55 00:02:42,770 --> 00:02:45,710 between the edit and test pain screens. 56 00:02:45,710 --> 00:02:49,490 In this case I have a virtual machine named VM three A and 57 00:02:49,490 --> 00:02:52,170 let me verify on my other monitor because I actually 58 00:02:52,170 --> 00:02:53,750 forgot what the tag is called. 59 00:02:53,750 --> 00:02:54,950 The tag is called. 60 00:02:54,950 --> 00:03:00,270 Post name and the tag value is VM three A and again the parameter 61 00:03:00,270 --> 00:03:05,140 definitions are entirely up to you or whoever created the script. 62 00:03:05,140 --> 00:03:09,100 It's just that there's surfaced graphically here in this test console and 63 00:03:09,100 --> 00:03:14,400 the logic of this script is shut down True will do a shutdown shutdown false 64 00:03:14,400 --> 00:03:19,280 will do a startup and you can run the run book in the cloud or if it's an 65 00:03:19,280 --> 00:03:21,980 unprejudiced sys or off cloud target, 66 00:03:21,980 --> 00:03:25,950 you can specify hybrid worker and then choose a hybrid worker group. 67 00:03:25,950 --> 00:03:28,200 I'll make sure to show you that in just a moment but 68 00:03:28,200 --> 00:03:30,060 for now I can click start now. 69 00:03:30,060 --> 00:03:33,250 Unfortunately it's not going to show your verbose warning and 70 00:03:33,250 --> 00:03:36,720 error screens until the test completes here and it can take a 71 00:03:36,720 --> 00:03:39,140 little while for automation to work. 72 00:03:39,140 --> 00:03:43,320 I think it's what's called the Cold Start problem that Azure has to scramble 73 00:03:43,320 --> 00:03:48,840 to allocate a VM to power your job etc looks like I've got some debugging 74 00:03:48,840 --> 00:03:53,620 here nuts Well again this is a real world case where you wind up iterating 75 00:03:53,620 --> 00:03:58,330 in between the edit screen and the test screen over and over Once you're 76 00:03:58,330 --> 00:04:00,320 satisfied with your run book, 77 00:04:00,320 --> 00:04:03,240 you can publish it and that then makes it available 78 00:04:03,240 --> 00:04:04,940 in your account for execution. 79 00:04:04,940 --> 00:04:09,540 So we can come down in the automation account properties under run books. 80 00:04:09,540 --> 00:04:11,570 Let me choose a published one. 81 00:04:11,570 --> 00:04:13,110 Start stop VM by tag. 82 00:04:13,110 --> 00:04:15,380 I know I'm not going to actually be able to do this. 83 00:04:15,380 --> 00:04:20,070 You can run it manually by clicking start or we can link it to a schedule. 84 00:04:20,070 --> 00:04:22,760 So if you want your run book to run on a schedule, 85 00:04:22,760 --> 00:04:26,230 the first thing you'll do is come under resources schedules and 86 00:04:26,230 --> 00:04:29,520 create yourself a schedule one or more schedules and then you 87 00:04:29,520 --> 00:04:31,700 can link the job to your schedule. 88 00:04:31,700 --> 00:04:36,510 You might have one or more schedules, one for startup, one for shutdown. 89 00:04:36,510 --> 00:04:41,090 These run books can also be triggered through webhook you can create 90 00:04:41,090 --> 00:04:45,710 an http listener and then when you send a request to that listener 91 00:04:45,710 --> 00:04:47,870 that would trip off the run book as well. 92 00:04:47,870 --> 00:04:51,940 Let me see, I had mentioned hybrid workers and that kind of stuff. 93 00:04:51,940 --> 00:04:54,760 But let me come back to the root of my automation account 94 00:04:54,760 --> 00:04:57,300 again will come down to hybrid worker groups. 95 00:04:57,300 --> 00:04:57,570 Again, 96 00:04:57,570 --> 00:05:01,380 the concept of the user hybrid worker group is it provides 97 00:05:01,380 --> 00:05:03,560 high availability for your machines. 98 00:05:03,560 --> 00:05:06,750 So in this case I've created a default worker group 99 00:05:06,750 --> 00:05:12,180 and if I select hybrid workers, I've got my arc to machine and VM one in here. 100 00:05:12,180 --> 00:05:14,370 Now I don't want VM one in here, 101 00:05:14,370 --> 00:05:19,710 I'm going to create a worker group that includes just my to Azure arc machines. 102 00:05:19,710 --> 00:05:22,710 So I now can click add let's for some reason. 103 00:05:22,710 --> 00:05:23,380 Arc one. 104 00:05:23,380 --> 00:05:25,790 Oh, here it is, win, it has a different host name, 105 00:05:25,790 --> 00:05:29,320 I'll select my first arc machine and add this to the group. 106 00:05:29,320 --> 00:05:29,780 And again, 107 00:05:29,780 --> 00:05:33,190 the idea here is that we've got high availability if one of 108 00:05:33,190 --> 00:05:36,090 our machines is unavailable or offline, 109 00:05:36,090 --> 00:05:40,990 the run book jobs on prem or off cloud will still work because they're all 110 00:05:40,990 --> 00:05:45,580 communicating with each other and with Azure over TCP 443. 111 00:05:45,580 --> 00:05:49,570 Take in a little while for Azure to boot out my Azure virtual machine, 112 00:05:49,570 --> 00:05:53,790 let me try a hard refresh and see if that fixes it hasn't shown up yet. 113 00:05:53,790 --> 00:05:56,900 But eventually we should find that just my two arc 114 00:05:56,900 --> 00:05:59,010 servers are in this worker group, 115 00:05:59,010 --> 00:06:03,510 we can go to jobs to see a history of run book executions. 116 00:06:03,510 --> 00:06:05,590 Lastly under shared resources. 117 00:06:05,590 --> 00:06:06,470 This as I said, 118 00:06:06,470 --> 00:06:08,560 is a place where you can store and reference 119 00:06:08,560 --> 00:06:11,010 credentials and digital certificates. 120 00:06:11,010 --> 00:06:15,230 If you're doing python run books, you can stage python packages, 121 00:06:15,230 --> 00:06:18,340 you're doing PowerShell you can add modules here. 122 00:06:18,340 --> 00:06:22,550 Again, you'll notice historically this has been a PowerShell 51 back end. 123 00:06:22,550 --> 00:06:25,990 So you have the Azure RM modules indicated if you want to 124 00:06:25,990 --> 00:06:28,370 standardize again on PowerShell seven, 125 00:06:28,370 --> 00:06:31,460 you'll want to verify and do the work to make sure that you've 126 00:06:31,460 --> 00:06:34,060 got the latest and greatest modules available. 127 00:06:34,060 --> 00:06:37,940 Likewise, in order to use your administrator created modules, 128 00:06:37,940 --> 00:06:44,000 You'll want to install those here, so they're available in your automation account