In this demonstration, let's work with Hyper‑V VHD files.
And we're right in medias res.
In other words, we're right in the middle of things.
On my server here, I'm in Hyper‑V.
I'm looking at the settings for the server1 VM on my ARC2 host.
This is the server and VM we've been working with historically.
And in the previous module we worked with checkpoints,
and I wanted to take you into the VM settings to inspect the hard drive and
particularly notice that the path ends in an avhdx extension.
That's an indication that we're working on a checkpoint
disk rather than the parent disk,
and it's not going to allow us to edit to do things like resize the disk,
change its orientation, etc.
because checkpoints exist.
So what I'm actually going to do is temporarily disabled checkpoints,
and let me come back to Hyper‑V Manager,
and let me delete the checkpoint subtree for this machine.
And notice it says Merge in Progress.
So now we should find if we go back to VMConnect here and open up
Settings and come down to the Hard Drive again,
we're using the VHDX file.
In fact, I need this path for the other stuff we're going to do.
Let's assume that we're going to migrate this machine up into Azure as an image,
as an operating system image.
Now, normally, hopefully you know this, but if not,
but normally the last thing you do before you create an OS
image is that you generalize the environment.
In other words, you remove the hostname,
IP address, security IDs,
anything that you don't want to duplicate because the idea with an OS image,
we may create a number of running VM instances off the single image.
So we would open up, or what I would do is open up Run,
type sysprep, and go to the Windows, C, Windows,
System32, Sysprep directory,
and I would choose Enter System Out‑of‑Box Experience,
Generalize, and then at Shutdown we're going to shut down the machine.
I'm not actually going to do that on server1 because I want to
continue to use this VM through the rest of the training,
but let's assume that that's what I've done because our goal ultimately is
to have images hosted in our Azure subscription to build new VMs that look
initially exactly like our server1 right here,
okay?
Now I can tell you that when I created this disk,
it's a generation 2 dynamically expanding disk,
and we can do generation 2 disks in Azure,
but we have to make a fixed size, and we also need it to be VHD,
not VHDX.
So, you know what I'm going to do, bring out Visual Studio Code,
and I have my trusty admin VM PowerShell script that's in the exercise files,
and here we can see on line 7 we can make use of the
Convert‑VHD command to accept that VHDX as its input,
and then we specify a destination path.
Let me make a directory called vm‑upload,
and then we can change the destination path to c:\vm‑upload.
And notice that I'm changing the VHDType here to Fixed.
That's really important to do.
So let me right‑click Run Selection.
Whoops, it expected a full path, not just a directory path.
Reading that red error output from PowerShell is a
highly educational experience for sure.
So there you go.
So I'm going to just do C:\vm‑upload\server1.vhd,
so let me right‑click and run that selection.
Ah, okay, we can see over here there's not enough space on the disk.
All right, well you see the idea.
Can't do anything about that right now, so let's just continue.
Let's assume that that conversion process finished.
Really,
all we would have at the end of the process is a server1 VHD
file that's in the vm‑upload directory, okay?
And at that point we would have a generation 2 VHD that's fixed size,
and therefore, it's ready for upload to Azure.
Now how do you upload your VHDs?
There's so many different ways,
but I wanted to show you a couple just in case there's any references
on the exam that might go to that level of depth.
One would be for you to install the AzCopy executable This is an EXE on Windows,
it's available as just an executable file on macOS and Linux as well,
and it's a command‑line utility where you can do blob copies,
binary large object copies, to Azure, from Azure,
between Azure locations.
And once you install AzCopy on your machine,
I give you some notes in the exercise files so you can learn all of the steps,
you have to authenticate to Azure in one way or the other.
One way would be to interactively sign in.
You can use AzCopy interactively.
Another would be in your storage account in Azure,
create what's called a SAS token, or a SAS URI,
and this is going to give you time‑limited access
into your Azure storage account, and that's what I have in this example.
So we would do an AzCopy copy, and we would do C:\vm‑upload\server1.vhd.
Then we would need to get a SAS token from our storage account.
I'll show you how to do that in just a moment.
And then we have to specify the blob‑type.
There's a few types of blobs that you have in Azure.
PageBlob is what you need to remember for VHDs.
The blob type that's used with regular file data is
normally called a block blob, okay?
So AzCopy is one way to go.
Another way to go, if you just want to use a desktop application,
is to use Microsoft Azure Storage Explorer.
This is a free cross‑platform desktop application,
runs on Windows, Mac, and Linux.
Let's go over to, let's go to the user menu and sign into our subscription.
I'll sign in at the Subscription level into the Azure public cloud,
and then depending upon my role‑based access control
authorization in that subscription, I can then choose,
first of all, which subscriptions.
I'll just choose my Sponsorship subscription.
Then I'll click Open Explorer,
and momentarily Azure will enumerate the storage accounts that I have access to.
And there's other stuff.
Notice that you can directly get access to Azure VM disk storage.
I don't want to focus on that now though.
I want to focus on let's say in my timstorage001
storage account I have my blob service,
and the blob service is just a non‑hierarchical collection of files or objects.
You create a container here.
In fact, let me click Load more.
I've got a container called vhd in here already.
And let's say I want to be able to upload that vhd from my local
system server1.vhd up into my storage account.
What I can do is right‑click the vhd container,
and I can get a shared access signature,
which, like I said, is going to give time‑limited access.
In this case it's defaulting to 24 hours, but in this case I would do Read.
I would want to add additional permissions.
I'm not sure exactly what I need here, so I'm just going to do Read,
add, Create, Write,
and then you authenticate that HTTPS URL with one of the two API
keys that you get in your Azure storage account.
It doesn't matter whether you choose one or two.
Now the hazard with shared access signatures is that anybody
who has that URL can use it if you're within that time period
because it's a portable unit.
So if I go back here into PowerShell,
what I'd want to do is paste in that SAS token here,
and so now this would instruct AzCopy to take my
server1.vhd and put it into that container,
the VHD container, authenticating to Azure using the rest of the token here.
So that's one way to go.
Another way is to do the upload directly from within Storage Explorer.
You saw right here there's an Upload.
We could just do an Upload Files to bring the file over that way.
And something that I think is pretty cool,
at least worthy of letting you know about,
if we go to Edit, Settings, and we come down to Transfers,
notice that AzCopy is built right into Storage Explorer.
You might think, well, what's so good about AzCopy?
Well, AzCopy is a great control over file transfers to,
from,
and within Azure because you can do things like maximum
transfer rate to make sure that if you're uploading to Azure
you don't chew up all of your bandwidth.
You can do concurrency both in the network and at the file levels.
You can do buffers.
Very importantly,
you can calculate MD5 hashes to make sure that your
uploads and downloads have integrity, that is that they're valid.
So AzCopy is a pretty cool tool for you to be aware of.
To finish this demo, what you'd want to do next after you upload the VHD,
there's actually two things left,
and these can be done in the Azure portal in our Azure subscription.
We'll want to create an image.
So we can search for image in the Azure portal and go to Images.
Then we can Create.
You create the image in your subscription in your resource group.
I'm going to call this server2019 in the East US.
It's a Windows.
I believe it's a gen 2 image.
I'm not doing this particular demo on server1 because,
as you saw, I haven't uploaded it yet.
I'm going to grab the, let me bring my Storage Explorer back,
and we'll go back to vhd.
I'm going to try this with the server2019.vhd that I
have here in my storage account, and here's where we can grab that file,
right here, Storage blob.
We can Browse, go into timstorage001, scroll down to the very bottom into vhd,
and we'll grab server2019.vhd.
Click Select.
You can choose whether it's solid state or mechanical storage.
Encryption. We can add data disks. We've got our taxonomic tags.
And then that's all there is to it.
Now there's a lot more to images in Azure. This image is just going
to be a region and subscription‑specific image.
You can create what's called a shared image gallery in your Azure
subscription to replicate images across multiple Azure regions.
This is helpful for businesses whose points of presence do span georegions
and you want nice high‑speed access to those custom images.
All right,
the deployment is complete, so the very last step
would be to create a virtual machine.
So let's browse to the Virtual machines blade, and
we'll do a Create, Virtual machine.
I'll place this in my az800‑rg resource group and call it
server2019 East US. Right here, this is what we're looking
for, Image. We'll go to See all images.
This brings us to the Azure Marketplace, but notice over here we have My Items,
My Images, and then there's server2019. So we would simply
select that image and then continue. Notice that we can
choose our sizes down here.
And if we click See all sizes, that'll bring us into this VM size
selector that allows us to model what we're looking for.
Now let me hit Add filter.
I'm going to investigate something out of curiosity.
No,
I was hoping there would be a filter to show only VMs that support gen
2 or only VMs that support nested virtualization, but that doesn't look
like to be an option in the filter, but you can always hit the dots for that kind of thing anyway.