Azure DevTest Labs

How to Use Azure DevTest Labs for Test Environments and Dev Machines

Barry Luijbregts Developer Tips, Tricks & Resources, Insights for Dev Managers Leave a Comment

DevTest Labs is one the best – and probably least – used features on Azure. It is similar to creating virtual machines on Azure but provides some specific features and advantages we will review.

No worries, no SPAM. Opt-out anytime.

Here are the following topics we are going to cover:

  • What is Azure DevTest Labs?
  • Test Environments
  • Dev Machines in the Cloud

What is Azure DevTest Labs?

Azure DevTest Labs is a service that Microsoft Azure provides. This service provides functionality for managing environments that contain Azure Virtual Machines. DevTest Labs does not cost any more than the cost of the virtual machines that you are using.

Azure DevTest Labs makes it easy to provide Virtual Machine Images that you can reuse within your team for development and testing.

It also enables you to manage costs by setting things like:

  • Maximum number of VMs per lab and per user
  • Allowed VM sizes
  • VM auto-startup and auto-shutdown times

Auto-startup and shutdown are really key features. Compared to just using virtual machines, the auto-shutdown helps you save a lot of money.

And it has loads of features that help you to quickly provision and de-provision your environment for development and test.

Here are some definitions that are used in the Azure DevTest service:

  • Base Images
    • VMs are based on images that can come from the Azure Marketplace or that you upload yourself (as VHD)
    • Windows Server – Quickly create test machines for 2008R2, 2012, or 2016
    • Windows with Visual Studio – for development
    • Databases – Images with SQL Server or Oracle
    • Linux – Ubuntu, CentOS, Redhat and others
    • Microsoft Products – Sharepoint, Dynamics, Biztalk
  • Artifacts
    • VMs can contain artifacts. These can be things that need to be installed, but also things that need to happen.
    • When you create a VM, you can indicate that you want to add artifacts, like install Git and Slack, or create a website shortcut or download a file.
    • Artifacts are stored as scripts in a Git repository. Per default, they come from the Public Repo from Microsoft.
    • You can add a Git repo as a source for artifacts and create your own, custom artifacts. You can use this to do things like automatically download the latest version of source code onto the VM.
  • Formulas
    • When you create a VM, you choose the properties of the VM like the base image, the name, the size (pricing tier), the disk type, etc. In Azure DevTest Labs, you can create formulas that allow you to create a VM quickly. A formula provides all of the properties pre-filled so that you can create a VM with just a few clicks.
  • Policies
    • Azure DevTest labs enable you to set policies for the lab to manage costs and minimize waste. You can set things like the number of VMs that each person can use, the allowed VM sizes, auto-shutdown and -startup times for VMs and more.

Artifacts are Awesome!

Artifacts can be added to VMs and can help you a lot. These are customizable elements that can be used to deploy your latest bits or your dev tools onto a VM. They can be things that need to be installed or things that need to happen. Per default, you can use the artifacts from Microsoft’s Public GitHub repository.

You can also create your own, custom artifacts. Do this by creating a JSON file in a certain format and have that point to a task (PowerShell, or other executable) that performs the action that you want. You need to store the JSON file in a Git repository that you attach to the DevTest Lab.

Why are artifacts so useful? Because they enable you to create a VM that is perfectly configured, without the need to manually install things and perform actions like getting the latest source code. You can immediately start developing when you turn on the VM.

You can also use chocolatey to script installing virtually anything!

DevTest Labs is All About Self-Service

Setting up a development and test environment can take lots of time. You’re restricted by the capabilities of IT operations and – as developers and testers – you’re not in control of the machines.

What you really want is self-service development and test environments. And you can by using Azure DevTest Labs!

The main reason for a developer to use DevTest labs is that it provides self-service. You can create the VMs that you need, provision and de-provision them and have everything ready to develop and perform tests on.

You can do all of this yourself. No more waiting on IT operations. A well-configured Azure DevTest lab has policies set up by the Lab Manager (maybe somebody from IT operations) and enables developers and testers to set up an environment in a very short time without worrying about costs or security.

This looks like a shortcut to work around IT operations. But it should be a new way of working for both IT operations and developers and testers.

Using Azure DevTest Labs for Test Environments

DevTest Labs is perfect for test servers. The ability to set them up with auto-shutdown helps ensure that the costs don’t get out of control. You don’t have to pay much for servers when they are off so you can turn them on, use them for a while, and shut them right back off.

Stackify takes advantage of DevTest Labs for testing their APM server monitoring agents. They can quickly spin them up, install the latest agent and run some load testing. Knowing that auto-shutdown will turn them off relieves a lot of headaches on the cost side.

If you are using Azure for production, DevTest Labs can be very useful for various sorts of test servers, build servers, or other utilities. Having the VMs close to the rest of your Azure resources is ideal.

To aid with continuous delivery and automate things as much as possible, you can integrate Azure DevTest Labs in your favorite Build / Release tool.

For instance, in Visual Studio Team Services, you can use the DevTest Labs tasks in builds and releases.

Using these, you can easily create a custom VM for testing, containing your latest build, run some tests on it and delete the VM.

Provisioning VMs is pretty fast – not super fast. In my experience, it usually takes between 5 and 10 minutes before a VM is properly started. Keep that in mind when you create an automated test process.

Using Azure DevTest Labs for Dev Machines in the Cloud

Developing software is hard. The process is difficult and there are lots of things that you need to keep in mind. Some of those things are things that you’d rather not deal with, like

  • Making sure that every developer on the team has the same essential libraries and applications on their machine so that they can just work and everything works the same for everyone
  • Providing a fresh dev machine to new developers, so that he can hit the ground running
  • Making sure that everyone can work from everywhere
  • Provisioning development and test environments that have all the right configuration to run the application

I’ve often seen companies buy loads of very expensive development laptops and install images on them with Windows, Visual Studio and so on. This is often a very expensive solution and makes developers dependent on operations.

Example Pricing

A dual core VM on Azure with 4GB of RAM costs about $100 a month on Azure if you used it 24/7. $1,200 a year for a virtual desktop sounds expensive. But don’t forget, you won’t be using it 24/7 and DevTest Labs can automatically start up and shut down your VM to ensure that you don’t waste any money.

There are 168 hours in a week. If you used your VM for 50 hours a week for work, that is less than $400 a year. You could even have multiples and since you probably only use one at a time, the cost doesn’t go up very much. You only pay the storage costs when they are turned off.

Template Your Dev Tools

Often, you’d need a particular piece of software that’s not included in the image. Usually, developers are local admins on the machines and can install that themselves, but not everybody does, and not everybody installs the exact same version. That can cause trouble, so the right thing to do is to get the application embedded in the image. Often this takes time as it needs to go on the backlog of the IT operations organization.

Disposable Dev Machines in the Cloud

Using Azure DevTest Labs, you can easily create a range of VMs that you use just for software development. To me, this a very attractive idea: you can do whatever you want with the VM and just retire it when it gets ‘dirty’ (you know: when you messed around with it too much). And voila: you can have a fresh, new machine in 10 minutes or so.

VMs in the cloud can be very fast – you don’t have to worry about having a slow machine. You need to find the right VM size for you that is fast enough and has all the bits that you need. This will probably save you costs over using dedicated, fast and expensive dev machines. The VMs can be shut down at the end of the day, thereby stopping the VM from costing money (almost completely). You can’t save costs like that with actual hardware that you bought.

Moreover, when a new dev starts, you just spin up a new VM from a formula and 10 minutes later he can get cracking!

Conclusion

Azure DevTest Lab is very useful for developers and testers. IT operations can use it to enable a self-service environment where developers and testers can create their own environment quickly, with minimal restrictions, whilst being cost-effective. It can even be used to automate test processes.

This removes a lot of friction in the overall software development process. Look into it!

Let us know what you think in the comments!

About Barry Luijbregts

Barry is a software architect and developer and Pluralsight author with a passion for the cloud. He has worked for lots of companies throughout the last decade and is keen to share his knowledge with the community. He co-runs a usergroup focused on technology and soft-skills called .NET Zuid and currently teaches people about the benefits of the cloud. @AzureBarry AzureBarry.com
A peek into the Future of Dev. Get a head start.