Scripting Azure VM image builds


I started looking into a way to script the Azure VM image build process.

In the Azure documentation there are instructions on building new virtual machines with various configurations for demonstration purposes using the Azure CLI.

  • One of them shows creating a VM using DSC (Desired State Configuration) which is perhaps a process that is compatible with Mozilla’s OpenCloudConfig.

There are also instructions on building a custom image that we may be able to use as a base image and deploy new ones from it. That way we don’t have to install Visual Studio and the other tools every time.

I also found that there is a REST API that can be used to interact with the virtual machines.

Would love to hear thoughts about this.


This is really useful information, thanks a lot for finding all these links! :smile: :+1:

  • DesiredStateConfiguration / OpenCloudConfig look like they could allow us to fully script/automate the set-up of a Firefox/Servo development environment from a base Windows 10 VM, just like our Dockerfiles (we’ve previously configured Windows 10 VMs by hand to produce our first custom images)
  • We’ll definitely want to implement a Janitor client for Azure’s REST API. I hope the API will allow us to:
    • Run our DesiredStateConfiguration/OpenCloudConfig scripts on a base Windows 10 VM (but I didn’t see any examples of using DSC in the REST API page?)
    • Generalize the freshly-configured VM and turn it into a custom image (I see API handlers with the words “generalize” and “save an image”, hopefully they do what I want them to do)
    • Deploy new VMs on-demand for Janitor users, based on our latest custom images (just like we spawn on-demand containers from our latest Docker images)

The custom image tutorial is what we used to produce our fist custom VM image (from a manually-configured Windows 10 VM), but we’ve had a few problems along the way:

  • The initial set-up/configuration of the Windows 10 VM for Firefox/Servo development was done manually (but we might be able to automate that with DSC/OCC)
  • The admin user that generalizes the VM has their folder wiped out (supposedly to remove any secret credentials, and allow new VMs based on that image to have different admin user configurations). We’ve worked around this by setting up a secondary developer user in the VM, that hopefully won’t get wiped out during the image creation process.
  • The CLI instructions in the tutorial to produce a new VM from the custom image are extremely specific (hard-coded names, IP ranges, etc). We need more “general” ways to produce VMs, ideally leaving as much of the network/system configuration to default as possible. This is where your VM creation examples come into play (so thanks again! I’ll try to read through these and learn how to produce better VMs, ideally using the REST API).

I guess our next steps here will be:

  • Start writing a DesiredStateConfiguration or OpenCloudConfig script for Firefox and Servo development environments based on Windows 10
  • Implement an Azure REST API client for Janitor to automate custom image builds and VM deployments

Thanks again for the very useful info! :slight_smile:

EDIT: I updated with a few more cards.


I am starting to explore the use of Ansible, I noticed it should work for Windows as well. Do you think it would be worth our time to see if we could use this technology to build our Azure VMs?