dev-machine

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

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
    
    # Wait for the VM to reach the ReadyRole State
    $vm = Get-AzureVM -Name $vm.Name -ServiceName $vm.ServiceName
    Write-Output $('VM state is '+ $vm.InstanceStatus)
 
    while( $vm.InstanceStatus -ne 'ReadyRole')
    {
        Start-Sleep -s 10
        $vm = Get-AzureVM -Name $vm.Name -ServiceName $vm.ServiceName

        Write-Output $('VM state is '+ $vm.InstanceStatus)
    }

    # Boot grace period of 60 seconds
    Start-Sleep -s 60
        
    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.

Trackbacks and Pingbacks:

  1. Dew Drop – March 30, 2015 (#1983) | Morning Dew - March 30, 2015

    […] A Dev and Test Adventure on #Azure (Alexandre Brisebois) […]

    Like

  2. Sometimes You Just Have to Scale Up! « Alexandre Brisebois ☁ - May 1, 2015

    […] my last blog post I shared about how I use a Microsoft Azure Virtual Machine as my development machine. It’s […]

    Like

  3. Creating a Visual Studio Enterprise 2015 RC Virtual Machine with ARM « Alexandre Brisebois ☁ - June 18, 2015

    […] few months ago I wrote about my Dev and Test adventure, where I used the Azure Portal to create my Virtual Machine. Since then, Microsoft has released […]

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s