Saturday, March 18, 2017

ARM Template Updates for Managed Disks

Recently, Azure announced managed disks.  The whole premise behind these disks is that you no longer have to manage disk from a couple of different points of view.  The first is the IOPS limits on storage accounts.  Traditionally, you get 20,000 IOPS from a standard storage account, which of course, can only handle so many VM disks.  As you get to larger deployments this can become a hassle, so much so that many people were starting to deploy a single storage account per VM.  The second is around the availability of the storage.  In the old system, you were not in control of the stamp that your disks were placed on.  While you could place the VMs in an availability set, this did not guarantee that the storage was also placed on separate stamps, still leaving deployments with a single point of failure.

You can read more about managed disks here.

Managed disks fixes all of these issues, and I just wanted to chat a little bit about ARM template changes required to make managed disks work.

Firstly, from an availability standpoint, managed disks can only be used with managed availability sets.


In order to set this, you need to point at one of the newer schema for compute.   I've found that 2016-04-30-preview is the one to target.  (Github).  In examples on the internet, particularly from https://social.technet.microsoft.com/Forums/Azure/en-US/c07c2f1c-d70d-4182-a918-0309897e2163/arm-template-example-managed-disks?forum=windowsazuredata it mentioned that you needed to add a SKU parameter with the value of "Aligned".  I've found this not to be true.  Here is my version:

    {
      "comments": "Availability set for the cluster servers",
      "type": "Microsoft.Compute/availabilitySets",
      "apiVersion": "2016-04-30-preview",
      "name": "[parameters('availabilitySetName')]",
      "tags": {
        "displayName": "Cluster AS"
      },
      "location": "[resourceGroup().location]",
      "properties": {
        "platformFaultDomainCount": "2",
        "platformUpdateDomainCount": "5",
        "managed": true
      }
    },
You'll notice above that the "managed" property under properties seems to be what needs to be set.  This is also detailed in the schema.

As managed disks now exist in a region and are either Standard or Premium, you do not need to specify a storage account or create one ahead of time.  I've found different templates on the internet where sometimes the ID is specified and sometimes just the type of storage is specified.  I've yet to play around with it enough to understand the differences in the approach.

Here is what I've done for OS disks.

          "osDisk": {
            "name": "[concat(parameters('serverNamePrefix'),'0',copyindex(1),'-OS')]",
            "createOption": "FromImage",
            "caching": "ReadWrite",
            "managedDisk": {
              "storageAccountType": "Standard_LRS"
            },
            "diskSizeGB": 64
          },

And for data disks:

          "dataDisks": [
            {
              "lun": 0,
              "name": "[concat(parameters('serverNamePrefix'),'0',copyindex(1),'-Disk1')]",
              "createOption": "Empty",
              "managedDisk": {
                "storageAccountType": "Standard_LRS"
              },
              "caching": "None",
              "diskSizeGB": 32
            }
          ],
Remember that now,  size matters, so try and keep those values in mind.  We are currently in promo pricing at 50%, but we all know that won't last!

Enjoy.



No comments:

Post a Comment