Azure Smalldisk Windows images

Nov 30, 2017. | By: Owen Davies

The default OS disk size for a Windows Virtual Machine depoyed into Azure is 127GB, if you don’t plan to have a lot installed on the OS disk then this could be massive compared to what you really need.

What’s the difference in pricing?

Managed Disks come in 2 flavours, Standard and Premium. Premium is Solid State Drives, and Standard are Hard Disk Drives.

Standard
Disk Size128GB32GB
Price per month£4.39£1.15
Premium
Disk Size128GB32GB
Price per month£14.70£3.94

This may not sound like a huge saving, and if you’re a large company then sure, it’s not a massive saving. But remember, disks are charged all the time, you pay for the storage even if your Virtual Machine is powered down and deallocated.

If you have a lot of Virtual Machines deployed to Azure but deallocated like me, this can save a fair amount.

How to find the new smalldisk images?

Currently in my scripts I was using the standard Windows Server images. I needed to find out what the image names were called to enter into the ARM template.

We firstly need to get the name of the Image Publisher:

This command gets all the image publishers available in Azure:

Get-AzureRMVMImagePublisher -Location "West Europe" | Select PublisherName

From this list we want to use MicrosoftWindowsServer

Next we need to get the ImageOffer by passing in the Image Publisher MicrosoftWindowsServer

Get-AzureRMVMImageOffer -Location "West Europe" -Publisher "MicrosoftWindowsServer" | Select Offer

This outputs a smaller list, we want WindowsServer

Use the following Powershell to get the list of Windows Server Images available in your region, we are passing in both the ImagePublisher and the ImageOffer that we just got from the previous two commands.

Get-AzureRMVMImageSku -Location "West Europe" -Publisher "MicrosoftWindowsServer" -Offer "WindowsServer" | Select Skus

For the West Europe region it returned the following:

Skus

2008-R2-SP1 2008-R2-SP1-smalldisk 2012-Datacenter 2012-Datacenter-smalldisk 2012-R2-Datacenter 2012-R2-Datacenter-smalldisk 2016-Datacenter 2016-Datacenter-Server-Core 2016-Datacenter-Server-Core-smalldisk 2016-Datacenter-smalldisk 2016-Datacenter-with-Containers 2016-Datacenter-with-RDSH 2016-Nano-Server

-smalldisk is what we’re after

Changes to ARM Template

We can now change the imageReference section within our Virtual Machine Resource to include our newly discovered Image sku

 "imageReference": {
            "publisher": "MicrosoftWindowsServer",
            "offer": "WindowsServer",
            "sku": "2012-R2-Datacenter-smalldisk",
            "version": "latest"
          }

The full Resource will look like this:

{
      "name": "[concat(parameters('vmName'))]",
      "type": "Microsoft.Compute/virtualMachines",
      "location": "[resourceGroup().location]",
      "apiVersion": "2017-03-30",
      "dependsOn": [
        "[concat('Microsoft.Network/networkInterfaces/',parameters('vmName'),'-nic0')]"
      ],
      "properties": {
        "hardwareProfile": {
          "vmSize": "Basic_A1"
        },

        "osProfile": {
          "computerName": "[parameters('vmName')]",
          "adminUsername": "YOURUSERNAME",
          "adminPassword": "Your_PASSWORD12345678"
        },
        "storageProfile": {
          "imageReference": {
            "publisher": "MicrosoftWindowsServer",
            "offer": "WindowsServer",
            "sku": "2012-R2-Datacenter-smalldisk",
            "version": "latest"
          },
          "osDisk": {
            "osType": "Windows",
            "name": "[concat(parameters('vmName'),'-','osdisk')]",
            "createOption": "FromImage",
            "caching": "ReadWrite"
          }
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[concat(resourceId('Microsoft.Network/networkInterfaces',concat(parameters('vmName'))),'-nic0')]"
            }
          ]
        }
      }
    }

Conclusion

We’ve now updated our Virtual Machine Resource in our ARM Template to utilise the smalldisk image offered by Microsoft. This will give our newly created VMs a disk of just 32GB which should be enough for many peoples needs. You can always extend this disk at a later date. But it’s much more difficult to shrink a disk without creating a new smaller disk and then copying everything over and deleting the original.

We’ve also figured out how to query the Azure API with PowerShell to discover all of the image publishers and the images that are availabe.

If you’re using premium disks you’re also now making a saving over £10 per month per Virtual Machine. Happy days.

Comments

About

Founded in 2009, Odity is a software consultancy based in the United Kingdom.

Social Links

Our Bunker

United Kingdom.