Bonjour, hi welcome in another video of cloud in five minutes I'm Frank Boucher
Microsoft Azure MVP based in Montreal in Canada and today we continue to talk
about the azure dev test lab I want to show you how to package it in the arm
template and deploying as you're creating your claimable VMs
okay so this is part 2 of a longer video so if you don't know about dev test lab
you should go check my first part of the video the link will be here and also
probably in the description so we know the arm template are fantastic to deploy
so it will be great to use it to deploy or deafness lab and create also our
claimable VMs in a deafness lab we have the claimable VMs and we have also the
formulas one thing is will be great to create the claimable VMs base on the
formulas however it's not possible directly from the arm template so this
is the only way I found it how we could do it so first we need to arm template
to define our as your dev test lab to do it you could start from scratch and
build it or you could just create it from the portal and then use the
automation script to extract the JSON file so you go in the portal you create
your as your leftist lab and then you click here in the automation script and
here you will have all your JSON files so you copy paste that in your favorite
text editor you already know for me it will be visual show code voila
so now what you need to do is clean it so following my five best practices and
if you don't know what I'm talking about go check that video I did not a long
time ago about all you could clean very easily your arm template with the magic
of Internet are we have one prepare for you so here it is okay so let me show
you what I did so of course I minimize the parameters and I leverage the
variables in the first resources we see we have our dev test lab and one thing
that is different than I had is this sub resources here when you export the
template this part was not there so you need to add it so in those resources you
will need to have a virtual network you will need to add a schedule so the
schedule is very useful if you want for it for example are your VMs to turn off
at 7 p.m. and then at notification channel so your user could receive an
email so that's the last sub resource inside our dev test lab then I had the
virtual network and all the other resources were are already present in
the exported template I just clean them now what we need to do is declare a
formula so here is my formula so formula is look very complex so I invite you to
go on the documentation and NC and a good way to start working on that is
create a simple formula directly from the portal and then look at it
unfortunately when you will do an export of the arm template that formula will
not be there so a good way to see it it's use the resource Explorer to get to
the resource Explorer you go to resources that assure calm and then you
pick your lab and you will see everything from it and then inside the
lab you look for the formula here it is you will see all your formula so I
create one here called simple dev box - and now I have all the properties that I
need to look for so you could copy paste that in your template let's have a look
this is my formula that I just create so I put a description owner it's a windows
I want to create a def box for a Windows user small dev box so I specify the
standard b-2s as a user I use it my administrator will be frank and the
password I use a parameter I use key volt for the
password I will show you that just in a few then we specify the network subnet
for the artifact I only use right now to get n vs code those are available in a
public repository but if you want to test your own source code those will
probably be in a private repository you just need to declare that private
repository add it to the arm template and then you will be able to reference
it and then a little bit more specification about the VM itself so
here I use the Windows 10 something like that and the network that's it so now
how could you reference a key volt value from an arm template a good way to do it
is to make a reference so here I'm I was receiving it from a parameter so I
should have put a secure string but I was just trying to trace so I put it
that way if I check in my parameter file I will see the admin password is here
and instead of putting the value or put reference and then key volt and then I
will put the full pack of my key volt and then secret name to retrieve my
password or my secret that way it's very secure so perfect we have our arm
template now what we need to do of course first we need to validate it be
sure before waiting for minutes about creating it just validate
once your validation pass it's now time to try it so now if we deploy that we
will have a nice slab with the formula but still no claimable so a way to
create claimable VMs is to use in Azure CLI Daz lab VM create that we'll be
creating a VM so we specify the lab we want to push it and then of course the
resource group the name of the machine and the formula we want to use note that
I don't need to pass any user or password because that's all
define inside my formula that's great but I would like to have a script that
run everything let me show you I already have one example for you because I want
to use Azure CLI I create a bash file so that bash file will receive three
parameters so the first one will be resource group name the resource group
location and the key volt name and then I specify the two part the template and
the parameter file here I create a token by the way I will put a link to that
file in inside the description if you need it and all the code will be ever
available there and then you know if it's required you could login and
specify a subscription here I will check if the resource group exists if yes I
will use it if not I will create it and then here what I do is I do the same
thing but for the key vault and then I will be populating the kibo putting the
password so using a key vault is a very good way to secure information so you
could use them without knowing the value of course for today it's overkill
because everybody should know the password since they will probably use it
to connect remotely to the VM but it was a great way to show you how to use key
volt then I execute a command we know well deployment then because in my I'm
template to be sure that my resources are having a unique name always add a
suffix so I don't know that suffix here I go retrieve those values and then I
create my lab so let's try that thing of course you could have run everything in
PowerShell but I like to do my strip in Azure CLI and bash so it could run also
on a Linux machine so - the name of my script and the three parameters so let's
run this and I will get back to you just after
Wow so everything is done the VM is available if we check have my formula
also that is available should see it voila
I have my auto shut down everything is there perfect
so in one click I generate my lab my formulas and then I create claimable VM
bays on those formula one click awesome so perfect that way you could reproduce
anytime a full lab with everything done very smartly and your VM will be
consistent I hope you liked this video and I hope it was useful to know more
about deafness lab you should check my other video to us here part one and to
learn more about the best practices and clean your arm template you should check
my other video just here thank you for watching