A Dev and Test Adventure on #Azure


dev-machine[1]

Back in 2013 I wrote about creating a Dev & Test environments in minutes. This post was all about the benefits and the flexibility of creating environments that support our development efforts.

Since then, I noticed that Microsoft regularly creates Virtual Machine templates for MSDN Subscribers that allow them to test software through their MSDN Benefits. Luckily, they have provided us with templates that are pre-configured with various flavors of Visual Studio.

visual-studio-vms[1]

As a developer, I am called to work on various projects, and I have many versions of Visual Studio installed. Over the past few months, I started working with multiple physical machines that I must maintain. By now, you can imagine that every tool that I decide to use, adds more maintenance. Updates, patches and betas take up a lot of my time away from actual work. To help me focus on producing value for the business, I use a good number of third party tools, with a limited number of licenses. This creates a challenge for me, because I have to pick and chose where I install these tools.

Recently, I decided to give myself a break. Using my MSDN Benefits, I provisioned a Virtual Machine with Visual Studio 2015 preview. Then I started to build out my brand-new developer machine. As a developer who’s been around azure for quite a while, I’m surprised that it took me this long to make this transition. I can now work from any physical computer. I can install all my tools, and I am no longer limited to 8GB of RAM.

I feel like a kid in a candy shop! I can scale my Virtual Machine to meet my needs and pay only for what I use. A few minutes before my work session, I use the following PowerShell script to start my Virtual Machine. Once, it’s ready, the Remote Desktop file is downloaded and launched.

$vm = Get-AzureVm -ServiceName 'my-dev-vm-name'
 
if($vm.InstanceStatus -ne 'ReadyRole')
{
    Start-AzureVM -ServiceName $vm.ServiceName -Name $vm.Name -Verbose
 
    Get-AzureRemoteDesktopFile -ServiceName $vm.ServiceName -Name $vm.Name -Launch
 
}else
{
    Write-Output 'Already ReadyRole'
    Get-AzureRemoteDesktopFile -ServiceName $vm.ServiceName -Name $vm.Name -Launch
}

Taking this a few steps further, you could create an app that would allow you to start the Virtual Machine from the bus using your Smart Watch.

Then when the time comes to call it quits, I use the following PowerShell script to shut down and deallocate my Virtual Machine. This is when I stop paying for compute.

$vm = Get-AzureVm -ServiceName 'my-dev-vm-name'
 
if($vm.InstanceStatus -eq 'StoppedDeallocated')
{
   Write-Output 'Already StoppedDeallocated'
 
}else
{
    Stop-AzureVM -ServiceName $vm.ServiceName -Name $vm.Name -Force -Verbose
}

This feature could also be added to the mobile app that I alluded to above, so that you could shutdown the Virtual Machine from your commute home.

Being in a hurry, I sometimes forget to shutdown the Virtual Machine, so I use Azure Automation to Stop Azure Virtual Machines on a Schedule. Usually, I scheduled the runbook to run at 19h00. This gives me a short grace period after 17h30 and helps me go offline for the night.

Comments (5)

  1. Frank Boucher says:

    Nice post, very useful.

  2. SteveC says:

    Excellent post

  3. Fergal says:

    This is quite cool. What kind of monthly cost do you incur for that VM?

  4. Alexandre Brisebois says:

    The monthly cost really depends on my projects. I regularly resize the VM hence the cost varies from month to month.

Skip to main content