windows virtual desktop scaling is generally available
and that means that you can use azure automation
and logic apps that will help you take control of windows virtual desktop
I'm Dean Cefola and this is The Azure Academy if you want to master the Azure
cloud you can start right now by clicking the subscribe button and the
notification bell so you don't miss anything
it's been an exciting week around windows virtual desktop lots of
announcements and things to talk about and they're all in the video description
down below so be sure that you go down and check out all those links
and make sure that you stay tuned right up until the end today because there's
some hidden tips and tricks that this new
solution offers that i'm going to share with you so let's get into it windows
virtual desktop and enterprise scale documentation is up on the azure
architecture center not only is this for very large scale
environments but all the best practices are here
for any size environment so definitely go and check that out
and in case you missed it on azure friday's latest episode christian
brinkoff was featured giving a great overview
of everything in windows virtual desktop so definitely go
and check that out and this leads us right into scaling automation
here's the overall architecture of wvd and the scaling automation
is right in the middle in those things that you control however
what if we could make it better as a way for wvd to better manage your vms with
scaling or deploying systems image management any feedback that you have
around that give me some comments down below i'd love to hear it and pass it on
to the product group so the tldr here is that we're going to run a process
very similar to our last video on scaling automation
and the link for this doc will be in the video description so you're definitely
going to want to check that out because that's where you're going to find all of
the code that you're going to need which is basically going to build us an azure
automation account and an azure logic app that we're going
to use to build this solution and here we are in one of my host pools you can
see i've got 11 hosts but 10 of them are unavailable so if we go
to our session host yes indeed we can see only one of our
hosts is currently running and that's because i have
the scaling automation solution already deployed and it is managing the power on
power off schedule of all of my virtual machines
and this is what the tool looks like in one of my resource groups a azure
automation account combined with an azure logic app
and a log analytics workspace so if i go into the logic
app and we go to the logic app designer on the left
we can see how often this runs which is every 15 minutes by default and this
will vary in your environment based on how
many systems you have in your host pool and how you configure that kind of
depends on how you have the rest of the lot gap configured
see the use arm api is set true and that also
implies that it can be set to false which means that this version of the
scaling automation supports the spring and fall
releases of wvd one code set now for both solutions so the number here
for the session threshold per cpu is the maximum number
of user sessions first cpu that will determine
whether or not new session hosts should be started
during peak hours you need to set this based on
the user density numbers that you're trying to hit and maintain
minimum number of rdsh this is how many session hosts i want running
at all times in my case one which is why when we looked at the host pool you saw
one session host was running i'm gonna change this to
four and hit save that way it should spin up three new hosts
so the message logoff title and message body are pretty interesting
because this is where we should have some other solutions to help us
and here we are in the group policy management console on one of my domain
controllers and there are four group policies that i use to help manage
users in the environment so when the scaling
automation goes to do its work hopefully it's not interrupting anyone
at the very bottom we have a screen saver policy
and this is forcing the screen saver after so many
minutes in case the user goes idle i want that screen
locked to protect their session and our data this is a policy
that limit the amount of time a remote app session can be
active we have an idle session limit think about like lunchtime or you forgot
to log off and your session has become idle well
after so many minutes or hours however you want to configure it you can
have that session go from idle to disconnected then after the session has
been disconnected for a certain amount of time i'm going to
log off the user and i coordinate these policies with my scaling automation
everyone should generally be logged out of the environment and that brings us
back to the logic app so we have a message title and body
so if a user has not yet logged off you would see something
like this telling the user that their session is about to be logged off and
that they should please save and close everything so if you have
10 host pools you need 10 logic apps to manage them but they can
go all back to the same azure automation account
now the automation account itself is going to be running a run book
and inside the run book you can see this is all powershell code
and we have covered a video on that recently as well and that's the origin
for this solution originally so you may want to go check that out so you can
learn more let me show you how to get this deployed
and all of this code can be found directly in the documentation which is
linked in the video description and these first commands here are going
to download the two powershell scripts that we're going to run
that'll set up our automation account and logic app and this is going to
create a c temp directory and download the code
from github onto your machine so i'll run those now the
first thing that we need to do in order to run it is we need to log in
i'll run the Login-AzAccount and i'll enter my credentials
now the one important thing to understand for how this script runs by
default you should run a command called Get-AzContext and i'll just pipe that to select *
so we can see all of the details and when you log in you can see you join
an azure ad tenant and a subscription so if these
are not the correct tenant and subscription that you need to
deploy your solution then you will have to
specify in the parameters we're about to look at which ones
you need so that you get everything deployed in the right place and this
code is also straight out of the documentation for
getting these things deployed and we've got some parameters here and i've
specified these values just so you could see what
it would look like but notice that most of these are actually set as
optional you do have to provide a location which is the azure region
you want to deploy in but the other items that you can see here will be
pulled directly out of your azure context for
your tenant and subscription and unless otherwise specified the
resource group that will be deployed is one called WVD auto scale resource
group and the automation account will be the WVD auto scale automation and then
as i mentioned earlier optionally the log analytics workspace so that you
can keep monitoring this solution is definitely something i'd recommend
i've removed the optional parameters we're just going to specify to use the
arm api and deploy in east us and we'll just
execute that code and i'll just move this over
so we get a little more room the first thing of course it would do
would be to set up the resource group and then build the azure automation
so our automation account is finished and we've downloaded all five
of our modules that we need now as a feature improvement
we've added that webhook as a variable inside the automation account so we can
just go right in here and grab that so we don't have to worry about losing it
like we did in the last version then we're going to need to create for
ourselves a run as account and you'll find this
further down in the blade you just select run as accounts
and then click in the center here to create a run as account
be sure that you do not create a classic account that won't work for this
solution and you just have to hit create at the bottom
back in our automation account we're going to go to our run book
and open the wvd auto scale run book go to the web hooks
and we'll open that up and then go to the parameters and run
setting and then we'll just paste the web hook that we copied out of our
variable and we'll hit ok for that and hit save
so the next part of our code in powershell is to build the logic
app and this is going to be different from how you've done this in the past
but we're going to gather the parameters and then input them into the command
kind of like we did before and i'll just move the screen over so we
can get a little more room i'm going to run this entire section
of input variables and notice now we've got a selection box that shows up
presenting us with our choices we'll go into my fta wvd
lab subscription then the box will show up with our next choice which is our
resource group and we'll be taking the wvd auto scale resource group because
that's where we provisioned our automation account
i'll be protecting the remote host pool and now it's going to ask us
for some inputs and i'll just be taking the defaults for most of these
because i did not associate the automation account with a
workspace because this is just for a test i'm going to leave this blank and
just hit enter and same thing for the primary key
and it's also reminding us what the defaults are so i'll set this for 15
minutes my time zone is -4 and it does have to
be in this kind of format the the end of my day is going to be
1800 hours or 6 p.m for my max number of user sessions we'll
set that to 4 and i want also 4 vms running and if
your numbers are going to be different certainly put those in
so for the tag i'm going to use the word disaster because i have a tag in my
environment that's for all of my dr related machines that i don't want the
scaling solution to take care of and this way it'll
exclude them even if they're part of this host pool
and here's a nice feature improvement that's been added remember i said about
the message that you could send when you want users
to log off if they haven't done so already you can actually set this to
zero now and if you do any vms that have
users still on them will not be powered off during
this process i'll set that to zero as well we still
have to create a message so let me do that
and then we see another pop-up for selecting the correct automation account
and for selecting our run as account and then it's going to
detect from that automation account what variable we had stored for the webhook
and inject it so now that we've set all of
our parameters correctly we can take this parameters block
along with our command and just execute that code and now it's going and
deploying our logic app and since there was nothing like modules
that we had to download and install and register
this is done in just a few seconds and in the logic app designer right back
where we started it's already injected our hook uri and
all of the parameter values that you just supplied through powershell and if
you remember back to the beginning of today's episode when we started
we had 11 session hosts in our pooled post pool
and 10 of them were offline now we have seven that are offline
because the scaling automation that i changed in the beginning to set the
minimum number of systems i want online to be
four at all times completed running and those vms have powered on
so provide us some feedback in the comment section down below
as to how you would like to see this tool improved as well as any other
features that you can suggest would be good to add and if you have
hung in with me here right up until the end then
you get the secret sauce of what's going on into this solution
is that it has now better error handling and checking and does things in parallel
processing so that means that it will run for shorter amounts of time and be
able to do more at once the more efficient it can be
the more money you will save so thanks for joining us today and i hope that
you've learned something new and had a good time
please do click that thumbs up and let me know and if you're looking for
something else to help you keep learning about azure over here on the
top right we've got our latest video and another one that we've
selected just for you at the bottom so you can go ahead and click those
thanks for spending some time with the Azure Academy today and we will catch
you in the next video happy learning