to be or not to be that's the question Shakespeare was asking when he was
thinking about life in the cloud we have a similar question stateful or stateless
it may sound strange but these two questions are really very closely
related in a stateful computing we have a system or data that will exist in
stateless it's temporary and then it goes away so which one is right for you
or more specifically for your workload when it comes to something like
containers stateless may be a very good option but then where is your persistent
data that stateful information has to be somewhere we're gonna answer that
question in terms of containers in our upcoming series so subscribe so you
don't miss that we're just putting the finishing touches on it but outside of
containers in VMs in general in the clouds should they be stateful or should
they be stateless well this again depends on your use case stateful
systems definitely have advantages for one I know that my data is there I don't
have to recreate it every time or worrying about where does it come from
but stateless has some advantages to speed I'm to deployment even in some
ways security and up until now we've been dealing with stateful VMs in our
WVD series but today we're turning the tables and we're gonna approach wvd in a
stateless manner with Azure ephemeral disk
I'm Dean Cefola and this is the Azure Academy Ephemeral disks are an feature
in the Azure managed disks and the word ephemeral means lasting for a very short
time okay so the system will come online with a disk that is unique and we'll
talk about how in just a second and then once this system is powered off that
disk goes away so anything that you're doing on the VM has got to be stored on
a separate data disk or on a shared network storage over in the azure Doc's
we can find the section on a ephemeral disk by scrolling down and going to
storage and then going to manage disk and in our table of contents over on the
left we'll scroll down a little bit and we can see the section on disk storage
if you are not yet using managed disks for everything in Azure then at this
point I gotta say you're doing it wrong everybody should be using managed disk
some of the features here for managed disks are encryption also
high-performance our managed disks are able to scale with much greater size and
performance than you could get with unmanaged discs another great use case
have managed this is backup and dr with the click of a button you can have your
VMs backed up and protected as well as have them replicating out to other
regions shared disk is a brand-new feature and we are planning a video on
this soon and finally the star of today's show ephemeral disk now
ephemeral disk can be used on marketplace images or your own custom
images ephemeral disk actually are using the local storage on each VMs host so
they function a lot like the Azure temporary disk and one of the nicest
things about them is they're free there is no cost related to using a ephemeral
disk at all and it's available in every region and storing your images in the
shared image gallery will allow you to scale to every region and also enable
version control and we did a video just recently on creating your own custom
images you can go check that out at the top if you miss that now there are some
caveats about a ephemeral disk even though they work from your images you
cannot capture an image from an ephemeral disk
you have to do all of that first rolling down just a little bit we see a
comparison between your traditional persistent disks and ephemeral disks you
can use persistent disk on every VM size there's only certain SKUs that support a
ephemeral disk at this time an ephemeral disk also only supports the operating
system disk now you can attach data disks for all of that persistent storage
but the stateless portion of the VM will only be the OS disk persistent VMs can
be stopped they can be turned off meaning that they are not running and
you are not paying for the compute you can reboot VMs with a ephemeral disk but
you cannot deallocate them once you do they reset a ephemeral disk do not
support being resized like you can with persistent disks resizing your VMs can
be done but when you do that the VM will effectively be reset there's a lot more
detail that you can read on this page as well as some frequently asked questions
but we're gonna jump right over to the azure portal and start working so I have
an example VM here that use using a ephemeral disk and do you notice
anything missing that's right there is no disk that means just like the
temporary disks that are assigned to each of your VMs the ephemeral disk
comes from the physical host that the VM is running on when you reset the VM you
deallocate it you reprovision it that temporary storage will go away because
it's tied to the physical host that you're running on a ephemeral disk
function the same way if the VM is running and rebooted you're fine but if
you then go and deallocate or reprovision or resize and you're gonna
end up on a different host and your VM will essentially reset back to the base
image and you got to start over so the way that we're gonna have to work with
these ephemeral disk systems is a custom image that has everything that we need
already baked in and a great use case for this is going to be Windows virtual
desktop so I've logged on to our stateless VM and you can see in the
background that I've got the Internet Explorer running and in the File
Explorer I've created a temp directory on the C Drive and I've downloaded some
programs one of them being the new edge browser well close the Internet Explorer
and just kick off the installer for and we were able to install the browser
on our system just fine now I'm gonna reboot the VM without deallocating it
we'll just do a normal restart and let's see what happens and when we log back in
the new edge browser is still here and we can access it but now watch what
happens I'll sign out of the VM and an azure I'll click on the VM now notice
that the stop button is grayed out and we cannot deallocate this VM we can
either delete it or we can re image it and if we re image it it'll reset back
to the foundational image that we built it from so instead what I'm gonna do is
do a resize and I'll resize this to a ds3 b2 and our size shows that our VM
has reset correctly if we log back in and the new edge browser is gone we're
back to the old IE and my C temp directory is gone the VM has been
completely reset to the base image alright so again the use case is as long
as you can keep your VM up and running and just take normal reboots then you
should be just fine and you can keep it operating but then once the VM D
allocates the system will reset back to the base image now that we understand
the concepts of using a ephemeral disk we're going to make ourselves a
stateless BM for wvd now I've already got an image for this from our last
video I'll search for images here's my image that's prepped and ready to go and
I built this without anything special for a ephemeral disk I'll just click on
it we'll go to create a new VM from it and we'll just call this stateless one
it's already got the image pre-selected we'll scroll down I've selected ds3_v2
as our size since that supports a ephemeral disk and I put in my
credentials we'll hit next we'll hit the drop down for the advanced here and
switch our ephemeral disk to yes and in this case I'm not going to add another
data disc like I had mentioned or other kinds of workloads because in wvd
everything the system needs to run including my applications are already
inside the image the user's data is going to be stored with FSlogix
therefore I don't need an extra data disc we'll
click next for the networking and I've set this to use my existing wvd network
I'll hit next for management and I've selected my storage account for boot
Diagnostics and when I scroll down the setting that I usually have on my VMs
for auto shutdown we will not be using since again we cannot stop this VM
without resetting it and this brings up a good point is that if you are using a
ephemeral disk for your systems they will be running 24/7 because if you D
allocate them they will effectively reset you'd have to rejoin the host pool
rejoin the domain now with that kind of caveat why would you want to use this
for WVD well a ephemeral disk running off of the
local physical host that it's attached to will have a much faster OS desk than
you would with remote storage it's just the laws of physics the other thing that
this can buy you is a faster rollover cycle in your fleet to increase your
security and patch levels much more frequently generally in the cloud we
turn off VMs we don't need to save money and you can still do that process with
these stateless VMs when you turn them on they will come right from your image
that means they'll always have your latest version of patches and software
and security fixes because everything is packed into your image and your data for
your users are stored in FSlogix on remote file storage the system is
effectively stateless but I've added some tags for this build and we can keep
track of our cost center that this is part of the wvd application this is my
lab environment and this is a stateless tiered VM so I'll click Next for the
review and before we hit create we'll click the download template for
automation link so if I start off on the parameters tab and scroll down just a
little bit here on line 26 the ephemeral disk type as a value of local let me
show you where that plugs into the template like the VM on the Left we'll
scroll down to the storage profile and you can see there's a property type here
called diff disk setting with an option and that is pulling from that same
parameter we just looked at so the option value here is
so the only two things that you need to make it an ephemeral disk is make sure
that the VM SKU that you're using is compatible and then put in that diff
disk setting with the option of local and in this case on line 99 and 100 you
can see that I'm using an image reference which is my custom image this
will work on marketplace images just as well all right so we'll create this VM
now with a stateless VM we can do all the reboots that we need to to make it
part of our domain and join it to our wvd host pool but we can't shut the VM
off if we do everything resets the only way to make underlying changes is to
change the image so if we wanted for example to install a new application we
have to do that in the image and then reprovision
our VMs so let's make it part of our host pool first thing we need to do is
join it to our domain I'll put in my domain creds and it has joined
successfully let's reboot we need to make this part of our host pool now so
I'll open up my web browser they'll want to go download the wvd agents and the
short link to get there is a KMS slash wvd docks and over on the left will go
under how-to and then we'll open create a host pool and session hosts then we'll
click this link for powershell and then over on the right we'll click the link
to register a virtual machine and here we have the WBT agent and the bootloader
I'll click the links for each of those to download them now we're going to need
a registration token for our host pool and inside the WVD web management
console at the top I'll click the plus to add a new session host and I'll copy
my reg key and go back to the VM and I'll do the WVD agent first well click
Next accept the license hit next delete the
words invalid token and paste our registration key and hit next and then
install then we'll click to run our bootloader and we'll just next accept X
then install now if you're wondering why could I not just do this with my custom
script extension you're absolutely thinking correctly yes you can and yes
you should I'm just showing you the process we're definitely going to
automate this from end to end so that we don't ever have to do something manual
again now that things are installed we're going to reboot
back in the web management console stateless one has been added into our
host pool and you can see our other two VMs are currently set with a allow new
sessions of no that means the only VM that we're going to access is going to
be our stateless VM and if I open my RDP app and I'll just go to run my task
manager and opening the details window we can see my FSlogix profile is
loading and from our task manager we'll go to file go to run a new task open the
command prompt and we'll type the hostname command and we are on stateless
one and if we go Who am I you can see we're logged in with our Adam warlock
account so we just made a stateless VM with a ephemeral disk part of our wvd
host pool now let's kick it up one more notch and do this with full automation
I've gone out to my github repo and we'll go into the WVD repository into
wvd templates and wvd new host i've got a new template here to provision a VM
with a ephemeral disk and we can scroll down a little bit
and I've added a new deploy to Azure button for this so I'll click that we'll
sign in with our credentials and it looks like the very same template though
if we scroll down a little bit we do see that the auto shutdown features are
missing and again and that's because a ephemeral disk BMS cannot be shutdown as
if they do they will revert back to their base image the beauty of doing it
this way with full automation is when we provision of VM it'll already be joined
to our domain join to our wvd host pool and have FSlogix set up and configured
now you can do this of course from your custom images just like we finished
building a moment ago this template because it is public I have configured a
little bit differently so if I go in the template to my virtual machine and I
scroll down just a little bit to the storage profile we've got that if disk
setting on line 157 with the option of local and then the image is referenced
on line 161 this is pulling from an azure marketplace image or either a
Windows Server 2019 with a small disk or the Windows 10 multi session image and
you can select that when you deploy it I'll show you that in a second you can
very easily change out this image reference sex
and put in it the image reference ID for your custom image you can use this in
either way okay I'll leave it here is the marketplace image and you can do
that other change if you want to I'll close this window and let me just input
my parameters real quick I'll provision this into my stateless resource group
just so we can keep a clear eye on which ones we're deploying in the end here
we'll get a VM that's named stateless - zero I've got my credentials in here for
my admin account as well as my domain name we're building one VM and here's
where you can choose Windows Server 2019 or Windows 10 multi session image from
our marketplace and I've got my v net information here as well as the share
for my FSlogix and my registration token so we'll scroll down check the box
that we agree and hit purchase who are stateless VM 0 has finished building and
it's been registered automatically as part of our host pool and I've set all
the other VMs to be in drain mode so the only one we can log onto is our brand
new one and we've got our client open again and we'll in the task manager and
I'll click the show details so yep we've got FSlogix and there's our task
manager we'll open our command prompt we are on stateless VM one so now we've
been able to fully automate this and it's up on my github page so have fun I
hope you've enjoyed looking at this very cool feature of ephemeral disk turning
your VMs into stateless systems of course this isn't what you'd use on
every single VM in your environment it does have specific use cases so plan
that out accordingly and if you thought that this video was good or you learned
something new go ahead and hit that thumbs up button and while you're down
there feel free to share this video with anybody else you think might find it
interesting and if you haven't done so already go ahead and click the subscribe
button join us here at the Azure Academy community where we are just trying to
help everybody learn all they can about Azure and if you have a comment about
this video or a question about just about anything in a sure if I don't know
I probably know someone who does go ahead and leave that for me in the
comment field down below and we'll get you an answer as soon as possible
we've got a lot more things in the works here at the Azure Academy
so check back frequently we do put out a new video roughly once a week and if
you're interested in checking out something else over here on the top
we've got our latest video as well as on the bottom a video that we picked out
especially for you and again I hope that you've enjoyed today's video and we will
see you in the next one happy learning