A formula in Azure DevTest Labs is a list of default property values that can be used to create a virtual machine. You can use the default values or change them, but it gives you a baseline from which to start. You can create a formula from either a base machine image in Azure, or based off an existing virtual machine in your lab.
I’m going to start off by creating one from a base image in Azure.
In my Lab blade, select Configuration | Formulas (reusable bases)
Click the +Add button to create a new formula
In the Choose a base blade, select Windows Server 2012 R2 Datacenter.
First thing I found is that I can’t set the password directly. I have to use a “secret store”. Let’s go figure that out
Back on my Lab blade, there is a My secret Store link. The secret store allows you to create name/value pairs, to store values such as passwords. Here you can see I’ve added a password name/value pair.
If I go back to creating my formula, I can now select from my secret store to set the password.
And just because I can, I’m going to add VS Code as artifact to install. Finally, I click Create to create the formula.
To create a VM using the formula, go to My virtual machines on the lab blade. click the +Virtual Machine button.
This time, on the Choose a base blade, in addition to the base images added earlier, I also see my formula.
I can select it, and all I have to do is give it a name and start the creation process.
Once the VM is created, I can connect to the machine and I have VS Code installed
Let’s see how I can turn this existing VM into a new formula. First, I’m going to make a change. Such as adding a new folder to the desktop called My Change.
Back on the VM Blade, I can select Create formula (reusable base)
Give formula a name and click OK
Now if I go to create a new VM in my lab, I see this new formula as an option.
I create the VM and connect to it, but I don’t see my folder there. Interesting. Maybe it was because I had the other machine running. I’m going to shut it down and try again.
Ah, no. it is just based on the SETTINGS of the VM. Helps if you read the documentation. So when you create a formula from a VM, it is based off just the settings. It doesn’t actually copy the VHD of the VM.
But, let’s see what happens if I add another artifact to the VM. I’m going to choose Chrome and install it into the VM. This applies the Chrome Artifact to the VM. I can log into the machine and verify Chrome was installed.
if I go back to the formula that was created previously. It still only shows one artifact installed. What happens if I create a new formula?
MyNewFormula still only has one artifact selected. Interesting. So it really only does use the original settings of the VM. I guess I could create a custom VHD image from the VM and them create a formula from that if I wanted.