Interesting Azure ARM "Make it So" behaviour

I had a template that deployed a premium managed disk and a virtual machine. I defined the disk like:

{ "comments": "Managed Disk.", "type": "Microsoft.Compute/disks", "name": "[variables('diskName')]", "apiVersion": "2016-04-30-preview", "location": "[parameters('location')]", "tags": { "displayName": "Data Disk 1 - Presented as LUN 0" }, "properties": { "accountType": "Premium_LRS", "creationData": { "createOption": "Empty" }, "diskSizeGB": 1024 }, "dependsOn": [] },

Then in the same template, I had a virtual machine with the storage section that looked like:

"dataDisks": [ { "lun": 0, "createOption": "Attach", "caching": "ReadWrite", "managedDisk": { "storageAccountType": "Premium_LRS", "id": "[resourceId('Microsoft.Compute/disks', variables('diskName'))]" }, "diskSizeGB": 2048 } ]

the thing to note is that I made a mistake with the storage profile and said that the disk I had already deployed as a separate resource was 2048 GB instead of 1024 GB.

What happened was that the first deployment:

  • Deployed the disk as 1024 GB
  • Resized the disk to 2048 GB when the VM was deployed

When I tried to redeploy the template I got this error message:

Disks or snapshot cannot be resized down.

It took a bit of head scratching to understand where the problem was but eventually, I realised that the size on the vm storage profile was incorrect.

So the Azure “MAKE IT SO” worked perfectly and once I knew that the storage profile on the VM had the option “diskSizeGB” the help for which says “The initial disk size in GB for blank data disks, and the new desired size for resizing existing OS and data disks” everything was a breeze .