Select Page

VSTS Hosted Agents – Outdated Azure PS cmdlets

I’m writing this short post because of a small issue that can occur when you’re using hosted agents in your Visual Studio Team Services instance. The problem is that the Azure PS version on the agents is quite old; v.1.3.2 OLD. Which means that if you’re like me and update all your modules on a daily basis you will surely have Azure PS version 2.0.x which has a lot of breaking changes between versions.

One of those breaking changes is the way you can create a Storage Account.

The V2 command version looks like this:

Looks pretty normal right? Here’s the V1 version of the cmdlet:

See the difference? No? In version 1 if you wanted to provision a spindle based or SSD based storage account, you had to type in the parameter -Type, parameter that was later changed in V2 with -SkuName.

So why I’m writing this blog post? Because if you use develop scripts on your local workstation and you have the latest version of the Azure PS cmdlets and then use that script in an Azure PowerShell task in VSTS, you will get a very very nice error saying that the SkuName parameter was not filled. Now go look at the cmdlet and figure it out. In my ignorance I forgot that the Visual Studio Team Service team that manages the hosted agent images didn’t update the PowerShell version / Azure PS version on the machines and that wasted 30 minutes of my time.

Please be aware that if you’re writing PowerShell scripts that are to be later used in VSTS tasks, TEST your scripts in a PowerShell 4 constrained instance. The agents are not using the latest and greatest version of WMF5 nor the latest and greatest Azure PowerShell cmdlets.

Sometimes working with the latest and greatest isn’t always a good thing 🙂

Using PowerShell DSC in Azure

Most of my DSC blog posts target on-premise or remotely accessed VMs which most of the times are in Azure. While everything is fine and dandy when you’re running PowerShell / PowerShell DSC on your local infrastructure, but when it comes to Azure, you might need to rethink your strategy a bit.

ARM Templates for creating custom image VMs in Azure

If you worked with Azure for a long time, you know that when you wanted to upload your own custom VM image to Azure, it was an easy thing. You prepared the VM, you sent it to Azure using PowerShell and after that you tagged it as an OS disk and that was it. Well that was the old way using the Azure Service Manager which I must say it was quite an easy procedure. With Azure Resource Manager, things changed quite a bit. You still have the possibility of uploading the VHDs to Azure but the deployment requires a little more work. You have to write code for that deployment to happen, be it in PowerShell or JSON. In this blog post I’m going to give you two ARM templates which you can use to deploy your freshly uploaded VHDs.

PowerShell Scripts to add / remove data disks on Azure VMs

First things first. Happy New Year!

So after I finished a long waking up cycle I remembered working on a project that involved migrating some SQL workloads to Azure and those workloads required a high amount of IOPS in order to perform optimally. Now after testing the storage system of the on-premise servers I found that they were capable of delivering about 2000 IOPS which is not much and that was with 15K RPM spindles configured in a RAID 5. Now achieving 2000 IOPS in Azure is very easy from a hardware perspective. On a Standard type of VM, one data disk can offer 500 IOPS so you would need four data disks and then configure a software RAID to stripe the data across all disks. This can be done on Windows using Storage Spaces or MDADM if the operating system is Linux.

Sample PowerShell Scripts for Starting and Stopping Azure ARM VMs in a Resource Group

I was recently working on a proof of concept in Azure for a client that needed a couple of VMs to test if Azure is a viable candidate for their on-premise workloads. The client only needed those VMs at certain hours on weekdays and that meant that I needed to implement a method to remove any unnecessary run-time costs and that’s where Azure Automation and PowerShell comes in 🙂

Pin It on Pinterest