Author Archives: Chris

Azure Reservations vs Automated Power Down

Two of the biggest techniques for saving money on Azure Virtual Machines are Reservations and shutting down VMs when they are not in use. However, as they can’t be used together which one is best?

Azure Reservations allow you to rent those VMs for a much cheaper price, but there’s a commitment of 1 or 3 years. One alternative, automated power-down, involves automatically turning VMs on and off based on their usage requirements. For example a service might only need to be available in office hours or Monday-Friday so why leave the server powered on over night when no-one is using it?

Why can’t they be used together? Well, technically they can- but probably it won’t save you any money. An Azure Reservation commits you to paying a (reduced) price for a VM whether or not that VM is powered on, so if you power down that VM with a reservation you’re still paying (unless you have another un-reserved VM of the same size which is on).

This means there are situations when a reservation is cheaper, and situations when not buying reservations and running the power control automation is financially preferable.

Here’s an example. The pricing is from the Azure Pricing Calculator in January 2021 using the UK South region, and may not represent current rates in your chosen Region.


A Linux D2v3 VM is required Monday-Friday 9am-5pm all year round.
Uptime in the non-reserved scenario is 8 hours/day or 40 hours/week.
So if our VM costs £0.0865 per hour we are charged (£0.0865 x 40=) £3.46 per week, an average of £15.32 for a 31 day month.

If the VM was left on 24/7 on Pay-As-You-Go pricing that would be (£0.0865 x 24 x 7=) £14.532 per week or £54.356 per month.

Uptime in the reserved scenario is always 24 hours/day
With a 1 year reservation the VM has a 37% discount, so the cost is (£14.532 x 0.63=) £9.15 per week or £40 per month
With a 3 year reservation the VM has a 57% discount, so the cost is (£14.532 x 0.43=) £6.25 per week or £27.10 per month

To put that all in a table:

Hours Cost / month
24/7 Pay As You Go£63.14
24/7 Reserved Instance 1 year£40.00
24/7 Reserved Instance 3 year£27.10
Mon-Fri 9-5: 40 hours per week£15.32
Mon-Sun 8-6: 70 hours per week£26.82
Mon-Fri 24/5: 120 hours per week£45.97

If a server needs to be on over 70 hours a week then switching to a 3-year reserved instance that’s on 24/7 becomes cheaper to run. The 1-year reservation becomes the cheaper option at 105 hours per week (e.g. 5am-8pm 7 days a week).

Windows Licensing

I’ve used an Ubuntu Linux VM in the previous example, and for Windows VMs with Hybrid Benefits applied the pricing is the same. Without Hybrid Benefits, where you are paying for the Windows license with the VM the calculations are trickier because the license isn’t subject to the Reserved Instance discount. Using a figure of £50.00 per month our table now looks like this:

HoursCost / month
24/7 Pay As You Go£113.14
24/7 Reserved Instance 1 year£90.00
24/7 Reserved Instance 3 year£77.10
Mon-Fri 9-5: 40 hours per week£26.94
Mon-Sun 8-6: 70 hours per week£47.14
Mon-Fri 24/5: 120 hours per week£80.81

With the Windows license included, that tipping point changes to 115 hours if you’re using the 3-year, or 134 hours if you’re using the 1-year.

VM Sizes

At this juncture I should point out that these discounts vary between VM sizes and regions. Sticking in UK South the 1-year reservation is hits 55% for the DS2v2 instance, and 70% for the 3-year option. That D2v3 used in our example pricing which is discounted at 37%/57% in UK South is cut by 42%/63% in Switzerland North. Of course, all the base prices vary between instance size and region too- so it’s worth running the calculations on your real environment.


Of course there are other factors to take into account when using either method. Reserved Instances are tying you into a period of use on that family of VM so you should be right-sized before signing up and confident that the application is going to outlast the length of the agreement in this state, or if not you will be able to utilise a VM of that size elsewhere in your environment.

On the flip-side there is a certain amount of overhead setting up and maintaining scheduled startup/ shutdown of Virtual Machines, and any experienced IT person will be placing bets on how long it takes for a customer to report that they couldn’t log on to that VM at 11pm on Sunday!

Remember, you can use the Azure Pricing Calculator to work out specific scenarios.

Cross-vCenter migration of vSphere Encrypted VMs

During a recent consolidation prospect I was faced with the challenge of migrated encrypted VMs from one vCenter to another.

For the non-encrypted VMs this is not a problem- the excellent Cross vCenter vMotion tool worked very well live migrating from vSphere 6.0/6.7 environments to the new 6.7 (this is now built in to the latest vSphere). However VMs using vSphere encryption for encryption at rest can’t use this method. Continue reading

Depicting chemicals with Azure Functions

A guide to quickly setup an Azure function to draw chemical structures from SMILES strings.

This uses the docker image provided by the CDK project to generate image files of a molecular structure based on a SMILES string. Not only is this potentially useful as a component in a larger application, but it also demonstrates using a docker image within an Azure Function. Running this as a function allows it to be run from just pennies a day, but could also be quickly scaled for more demanding solutions.

PowerShell deployment

This should work from a local PowerShell session after using

to authenticate, or from Azure Cloud Shell.

The script builds out an Azure Function within a new App Service Plan- plus an associated Storage Account and Application Insights. The Azure function pulls the Docker Image from the Docker Hub.

#Script to deploy SMILES depiction function

#Set these variables
$appName=           "cdkdepict01"               #Short Name for Application used in Naming Convention
$tags=              @{"tag-service"="SMILES"}   #Tags to apply to the Resource Group and Resources.
$subscriptionName=  "Pay-As-You-Go"             #The Subscription to deploy to
$location=          "Central US"                #The Azure Region to deploy to.

#Determine the resource names using a naming convention
$resourceGroupName=     $AppName+"-rsg"
$functionName=          $AppName+"-fun"
$appServicePlanName =   $AppName+"-asp"
$storageAccountName =   $AppName+"sto"

#Switch to the correct subscription
    $context = Set-AzContext -SubscriptionName $subscriptionName

"-- Creating Resource Group "+$resourceGroupName +" in " + $location
    $resourceGroup = New-AzResourceGroup -Location $location -Name $resourceGroupName -tag $Tags

"-- Creating App Service Plan "+$appServicePlanName
    $appServicePlan = New-AzAppServicePlan -Location $location -Tag $tags -ResourceGroupName $resourceGroupName `
                        -Name $appServicePlanName -Tier "Basic" -WorkerSize "Small" -NumberofWorkers 1 -Linux

"-- Creating Storage Account "+$storageAccountName
    $storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName `
                        -SkuName "Standard_LRS" -Location $location -Kind Storage -Tag $tags

"-- Creating Function "+$functionName+" from Docker Hub image"
    $newFunction = New-AzFunctionApp -Name $functionName -ResourceGroupName $resourceGroupName -DockerImageName "simolecule/cdkdepict" `
                        -PlanName $appServicePlanName -StorageAccountName $storageAccountName -Tag $tags

"-- Finished"

Once executed the resulting web page, with examples, should be available at
(replace appname with the value used in the script.)

Windows 10- microphone is playing back through speakers

A surprise one from your friendly neighbourhood IT Support this afternoon. A laptop running Windows 10 has started playing back all the sound picked up by the Microphone- my voice was being echoed back (with a slight delay) even when no applications were running.

The solution here is found in a setting in the Windows sound controls- the following steps will resolve the issue.

  1. Open “Control Panel” from the Start menu
  2. Click on “Sound”
  3. On the “Sound” dialogue, select the “Recording” tab
  4. Select your active microphone from the list
  5. Click on the “Properties” button
  6. On the “Microphone Properties” dialogue, select the “Listen” tab
  7. Un-tick the box labelled “Listen to this device”
  8. Click “OK” on the “Microphone Properties” and “Sound” dialogues.