Define Customized Virtual Disk Name in Azure Windows Virtual Machine Deployment

There is no doubt that one of the most common Azure operations is to deploy Windows virtual machine. In most cases, deploying an Azure Windows Server is to utilize the Windows Server deploy wizard in Marketplace, which is also the easiest way in most scenarios.

However, by utilizing the deployment Wizard, we cannot choose the Virtual disk name. The virtual disk name will be automatically populated with an Azure predefined format.

This post to introduce one of the ways to allow user to define the virtual disk name by utilizing the “Azure Templates”. The method used in this post can also be used to define other Azure element name in virtual machines.

  • Step 1 : Search “Windows server” in Marketplace.
  • Step 2 : Run through the wizard with the desired configuration of OS/Disk/Network. In this example, we choose a Windows 2016 Datacentre edition with only one OS disk. In the last page of the wizard, click “Download a template for automation”.
  • Step 3 : In the Template page from last step, select “Add to library” and give the new template a name and description.
  • Step 4 : Select “Edit” in this new template and choose to edit “ARM Template”
  • Step 5 : In the ARM Template editor, navigate to “parameters”. Add a new parameter as below:

“OsDiskName”: { “type”: “string" },

  • Step 6 : In the ARM Template editor, navigate to “storageProfile”->”osDisk”. Add the below definition under “osDisk” as below:

“name”: “[parameters(‘OsDiskName’)]”

  • Step 7 : Save the changes in ARM Template editor and try to deploy the new template. You should see a parameter called “Os Disk Name” under settings. You can type your preferred virtual disk name in here.
  • Step 8 : To save your time for repeated deployment, you can add the default value in each parameter, you can reference below link

https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-parameters

Below is an example:

For now, an Azure Windows Template have been created and provide you the parameter to define virtual disk name in Windows virtual machine. As mentioned in the beginning, the method used in this post can also be used to define other Azure element name in virtual machines.

Leave a Reply

Your email address will not be published. Required fields are marked *