Select Page

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 🙂

Deploy multiple Azure VMs in a Load Balanced set

In the last couple of weeks I have been working with a client that needed to deploy a two-tier web application that would act as a web store and they predicted that on the launch day about 1500-3000 users would hit the store. Now with that amount of client connections hitting one server would have been a complete failure so we needed to set up multiple web servers and configure Azure’s load balancer to balance the incoming traffic to multiple VMs. Now with the theory in place we just needed to find out how many frontend VMs were needed and after analyzing the facts we settled on the magic number of 10 front facing VMs with one beefy VM on the backend.

After having all the details now comes the hard part. How do I NOT deploy that many VMs manually? I chose not to go with the Azure Resource Manager for this project because I’m not yet convinced that ARM is ready for production deployments so ARM templates were off the plate. Now I didn’t have anything that came even remotely close to help me deploy the much needed VMs so I started PowerShell ISE and wrote a simple script that would create the VMs, create the needed endpoints and add a data disk, set the provisioned IP as static and so on. After an two hours or so I finished the script and ran it to see what happens and the result was OK but the script wasn’t modular enough and it served only one specific deployment and that didn’t help me at all in the long run. So after deploying and configuring all the VMs I started working on turning the script into a function that would help me cover more that one scenario.

PowerTip – Get a nicely formatted endpoint list for your Azure VMs

I was working on an Azure deployment recently and I needed a very quick way to get all the endpoints and local IP from the Azure VMs, rather than clicking threw the portal and copying the endpoints one by one so I opened up the PowerShell ISE, struggled a bit with the Azure cmdlets and presto, got a nice one liner that gives me all the information I need.

Pin It on Pinterest