1 00:00:01,040 --> 00:00:02,080 In this demonstration, 2 00:00:02,080 --> 00:00:05,670 I'll show you how to synchronize IIS website content between 3 00:00:05,670 --> 00:00:09,780 servers, and we'll also examine Hyper‑V live migration. 4 00:00:09,780 --> 00:00:14,350 We are on, I believe, my win, well, let's just check. Let 5 00:00:14,350 --> 00:00:17,240 me bring up VS Code and do a hostname. 6 00:00:17,240 --> 00:00:17,450 Yes, 7 00:00:17,450 --> 00:00:24,190 I'm on my source server, the Windows Server 2019 box, and the exam alert here 8 00:00:24,190 --> 00:00:29,640 with regard to migrating IIS servers in your environment is to use msdeploy. 9 00:00:29,640 --> 00:00:34,820 Now as my UK‑based friends say, it's a fiddly technology, and so you'll see 10 00:00:34,820 --> 00:00:36,800 in my sample PowerShell script here, 11 00:00:36,800 --> 00:00:42,580 I've got several calls of msdeploy. There's quite a few dependencies really. 12 00:00:42,580 --> 00:00:47,040 You need to make sure that your IIS website is configured properly. 13 00:00:47,040 --> 00:00:47,820 It's just fiddly, 14 00:00:47,820 --> 00:00:51,140 it's not necessarily overly complex, as I said. You'll just want to 15 00:00:51,140 --> 00:00:54,340 check the documentation. There's a great docs article actually 16 00:00:54,340 --> 00:00:59,060 called Sync, S‑Y‑N‑C, Sync IIS Websites. 17 00:00:59,060 --> 00:01:00,780 Again, just for completeness, 18 00:01:00,780 --> 00:01:07,400 let me show you sync iis websites docs, and let's see, 19 00:01:07,400 --> 00:01:09,480 yeah there it is, Synchronize IIS. 20 00:01:09,480 --> 00:01:14,270 This one right here is what you're after. Now, I have just a simple, 21 00:01:14,270 --> 00:01:20,240 lightly modified, very lightly modified, IIS website on WIN2019OLD. 22 00:01:20,240 --> 00:01:24,140 All I have here actually is the default IIS splash screen image 23 00:01:24,140 --> 00:01:28,140 that I've modified with this banner so that we can see what it is. 24 00:01:28,140 --> 00:01:32,070 And, you'll also want to have Web Deploy installed on both your 25 00:01:32,070 --> 00:01:34,740 source and destination computers. 26 00:01:34,740 --> 00:01:35,920 Just do a google search, 27 00:01:35,920 --> 00:01:39,570 you can download Web Deploy from the Microsoft Download Center, but 28 00:01:39,570 --> 00:01:42,810 make sure that you've installed all the components, 29 00:01:42,810 --> 00:01:47,400 particularly on the target machine you need to have this Remote Agent 30 00:01:47,400 --> 00:01:50,580 Service running. If you want to do bidirectional sync, 31 00:01:50,580 --> 00:01:53,540 you'll need to have it installed on both machines. 32 00:01:53,540 --> 00:01:58,460 I found I had errors unless I installed everything in Web Deploy 33 00:01:58,460 --> 00:02:01,940 on both my source and destination machines. 34 00:02:01,940 --> 00:02:03,280 Once I had that, 35 00:02:03,280 --> 00:02:08,130 then we can add msdeploy to your path, and then we can start to set it up. 36 00:02:08,130 --> 00:02:11,660 And the idea is that to do periodic website synchronization, 37 00:02:11,660 --> 00:02:16,670 you can just maybe create a script and run it using scheduled task, or 38 00:02:16,670 --> 00:02:19,950 whatever, to periodically perform that synchronization. 39 00:02:19,950 --> 00:02:27,990 Let me bring my terminal up and do an msdeploy/?, the old‑school 40 00:02:27,990 --> 00:02:31,660 help. And as you can see, there's quite a bit here, 41 00:02:31,660 --> 00:02:39,440 what might work better actually is to do the msdeploy and then redirect that to, 42 00:02:39,440 --> 00:02:45,870 I'm going to call this, msdeploy.txt, and then I'm going to do a code, 43 00:02:45,870 --> 00:02:50,350 msdeploy.txt, to bring that into a separate file here. 44 00:02:50,350 --> 00:02:53,180 It's worth your studying for sure because number 45 00:02:53,180 --> 00:02:55,290 one, the syntax is not that great, 46 00:02:55,290 --> 00:02:59,730 but number two, it's actually a very powerful command line executable, you can 47 00:02:59,730 --> 00:03:04,430 do a lot of powerful stuff. You can grab multiple websites, 48 00:03:04,430 --> 00:03:08,740 you can grab just selected elements of the configuration. 49 00:03:08,740 --> 00:03:13,830 There's a lot going on here as you can see, the Supported Verbs here, sync is 50 00:03:13,830 --> 00:03:18,120 what we're concerned with, but you can gather dependencies, 51 00:03:18,120 --> 00:03:21,560 you can just retrieve metadata, very powerful. 52 00:03:21,560 --> 00:03:26,650 So what I've done is, ultimately what I got to work is down here on lines 60 53 00:03:26,650 --> 00:03:34,590 and 63, where I did an msdeploy verb:sync, the source type is webServer, and 54 00:03:34,590 --> 00:03:37,410 what I found in my particular environment, 55 00:03:37,410 --> 00:03:41,810 I was having network problems doing a direct over the network transfer, 56 00:03:41,810 --> 00:03:45,310 that's what you have up here, for instance. You've got msdeploy 57 00:03:45,310 --> 00:03:49,290 ‑verb:sync source: apphostconfig, the friendly name of the website, 58 00:03:49,290 --> 00:03:54,580 destination, and then providing the computername. As an alternative, you 59 00:03:54,580 --> 00:03:57,630 can do a two‑step approach, and like I said, 60 00:03:57,630 --> 00:04:01,600 this is what I had the best luck with, where I would do an msdeploy and 61 00:04:01,600 --> 00:04:06,590 export that website as a package on my C drive. And then on the 62 00:04:06,590 --> 00:04:09,640 destination, or I could actually run it here, 63 00:04:09,640 --> 00:04:12,990 I'm doing a ‑verb:sync, specifying the source path to that 64 00:04:12,990 --> 00:04:17,730 package and then the FQDN of my destination server, and then I'm 65 00:04:17,730 --> 00:04:20,740 putting that in an msdeploysync.log. 66 00:04:20,740 --> 00:04:24,590 I think I've got that file right here, let me do a dir, yeah, 67 00:04:24,590 --> 00:04:29,250 so let me do a code .\msdeploy log, and we can take a look at it. 68 00:04:29,250 --> 00:04:33,940 It's in the traditional IIS format so it's not particularly easy to 69 00:04:33,940 --> 00:04:36,050 parse, and as you can see in the mini map, 70 00:04:36,050 --> 00:04:40,570 it's actually a very long document. Now, if it creates this much 71 00:04:40,570 --> 00:04:45,740 output for just a stock IIS website with one page, 72 00:04:45,740 --> 00:04:49,000 you can see how robust that synchronization is, 73 00:04:49,000 --> 00:04:53,340 at least initially, when you have a more substantial application. 74 00:04:53,340 --> 00:04:57,480 So, that's the idea. You'll periodically run that msdeploy to do your 75 00:04:57,480 --> 00:05:01,670 synchronization, and I can test that I've already done this just by 76 00:05:01,670 --> 00:05:06,420 pointing my browser to the destination server, mem1, and you can see 77 00:05:06,420 --> 00:05:07,950 it's got the same content. 78 00:05:07,950 --> 00:05:11,160 All right, so, mission accomplished on that. Now, 79 00:05:11,160 --> 00:05:12,760 as far as the live migration, 80 00:05:12,760 --> 00:05:16,150 that's pretty straightforward as well, actually. Let me open 81 00:05:16,150 --> 00:05:23,040 up Hyper‑V Manager here, and let's see, we've got our vm9 virtual machine. 82 00:05:23,040 --> 00:05:27,850 This is, if memory serves, just a Windows Server core box, yes, 83 00:05:27,850 --> 00:05:29,540 here it is right here. 84 00:05:29,540 --> 00:05:33,380 And, the idea is that we want to move this to a new server. 85 00:05:33,380 --> 00:05:38,090 So let's bring in that new server by right‑clicking the Hyper‑V Manager node 86 00:05:38,090 --> 00:05:42,870 and connecting to mem1. Mem1 has its own machines of course, 87 00:05:42,870 --> 00:05:45,880 but it doesn't yet have the one from WIN2019OLD. 88 00:05:45,880 --> 00:05:49,560 Now the catch here is that you need to make sure that the receiving machine, 89 00:05:49,560 --> 00:05:54,060 that is the Windows Server 2022 machine, is configured to support incoming 90 00:05:54,060 --> 00:05:58,150 live migrations. So we can right‑click the machine and go to Hyper‑V 91 00:05:58,150 --> 00:06:01,970 Settings off the shortcut menu, and come over to Live Migrations, and 92 00:06:01,970 --> 00:06:03,900 there's two elements here to configure. 93 00:06:03,900 --> 00:06:08,220 One is we have to explicitly enable incoming and outgoing live 94 00:06:08,220 --> 00:06:13,090 migrations, how many in parallel do you want to support, and then you 95 00:06:13,090 --> 00:06:17,520 can constrain to particular networks, but I'm doing any available 96 00:06:17,520 --> 00:06:20,810 network for live migration, and I have that configured on both 97 00:06:20,810 --> 00:06:23,740 machines to support bidirectionality. 98 00:06:23,740 --> 00:06:28,240 Let me verify that, enable, and yes, so that's good. 99 00:06:28,240 --> 00:06:32,380 If I go back to my PowerShell script one more time, scroll down, you can 100 00:06:32,380 --> 00:06:36,980 also set up the machines, the hosts that is, for live migration support 101 00:06:36,980 --> 00:06:42,620 using PowerShell as you can see, Enable‑VMMigration, you can constrain the 102 00:06:42,620 --> 00:06:46,850 migration network, and then you've got a Set command where you can specify 103 00:06:46,850 --> 00:06:48,940 what kind of authentication. 104 00:06:48,940 --> 00:06:53,440 And then lastly, as you can see on 76, we're calling Move‑VM, 105 00:06:53,440 --> 00:06:56,860 against the name of the VM specifying the FQDN of the 106 00:06:56,860 --> 00:07:00,140 DestinationHost and we want to include storage. 107 00:07:00,140 --> 00:07:04,480 What is the DestinationStoragePath on that remote machine, and then we have a 108 00:07:04,480 --> 00:07:09,170 whatif. I like to do a whatif just as a final check that says here that the 109 00:07:09,170 --> 00:07:13,490 whatif will move the virtual machine to that computer. Now I want to make sure 110 00:07:13,490 --> 00:07:16,570 that that DestinationStoragePath exists. 111 00:07:16,570 --> 00:07:22,700 Let me do a quick Enter‑PSSession on mem1, and let's do a cd 112 00:07:22,700 --> 00:07:26,290 c:\vms. Yes, it looks like there is a VMs director, 113 00:07:26,290 --> 00:07:28,420 I just wanted to verify that quickly. 114 00:07:28,420 --> 00:07:32,410 So let's get rid of that whatif flag here and let me add in Verbose so I 115 00:07:32,410 --> 00:07:36,330 can see as much output as possible, and there we go. 116 00:07:36,330 --> 00:07:38,810 We can expect that's going to take a little while to do, 117 00:07:38,810 --> 00:07:42,180 but the value proposition here is that this is indeed a 118 00:07:42,180 --> 00:07:46,700 live migration over the network, so it's going to involve no downtime of the VM. 119 00:07:46,700 --> 00:07:49,540 If we come back to Hyper‑V Manager, 120 00:07:49,540 --> 00:07:53,520 we've got this machine running, and we could have connected users who are 121 00:07:53,520 --> 00:07:57,720 consuming it and having a good time. Whoop, there it is, it looks like it went 122 00:07:57,720 --> 00:08:04,010 away from WIN2019OLD, and if we head over to mem1, there we have vm9 running 123 00:08:04,010 --> 00:08:14,000 over there, and if we double left‑click it, do a Ctrl+Alt+Delete, and there we've got our machine. Migration completed.