Create User Specified ARM Template
  • 09 Jan 2025
  • 4 Minutes to read
  • Contributors
  • Dark
    Light

Create User Specified ARM Template

  • Dark
    Light

Article summary

Overview

This document provides end-to-end guidance on creating an ARM template to deploy Virtual machine according to user specifications.

In this document you will be going through with the below topics:

Link to be replaced

ARM template outlines

The ARM Template is a file that contains various key-value pairs in JSON format. It has the following sections:

Schema

The schema specifies the location of the JSON file and the version of the template language you want to use. This schema depends on your deployment purpose. You do not have to make any changes in the schema section.

Parameters

The parameters in a template define its configuration. They are used during run-time or deployment. Parameters include names, types, values, description and properties.

In this file you will define the type of the paramter and it's values are configured in the Parameter file.

You do not have to make any changes in the Paramters section unless you want to have specific applications/utilities/programs available in the VM (Applicable only to Windows VM). With the ARM template provided below, you have the flexibility to selectively install softwares or utilities in the virtual machine, making them readily available to users when the lab environment loads. To achieve this, download the ARM template file and update the defaultValue for the required parameters(of softwares/utilities you need in the VM) to 'yes', which will use the Windows Custom Script Extension script to setup the needed configurations in the backend. To learn more, refer Microsoft Documentation - Azure Custom Script Extension for Windows.

For instance, to install Python in the VM, update the defaultValue of InstallPython parameter to yes.

You can use the below ARM template to customize Windows VM:

 https://cloudlabsai.blob.core.windows.net/templates/deploy-05.json

You can use the below ARM template to customize Linux VM:

  https://cloudlabsai.blob.core.windows.net/templates/deploy-08.json

Variables

In the variables section, you construct values that can be used throughout your template. Variables often simplify your template by reducing complex expressions.

Below are the few variables which you can update according to the requirement:

  • AzureSubscriptionID : You don't need to update the value. This will automatically fetch the Subscription ID

  • AzureTenantID : You don't need to update the value. This will automatically fetch the Tenant ID

  • location: You don't need to update the value here. This will automatically fetch the region you provided in CloudLabs Template.

  • rgName: You don't need to update the value. This will automatically consider the RG name you have mentioned in CloudLabs Template.

  • networkInterfaceName: If you want to specify the any particular name for Network Interface, you can update it here.

  • networkSecurityGroupName: If you want to specify the any particular name for Network Security, you can update it here.

  • publicIpAddressDNSName: If you want to specify the any particular name for DNS, you can update it here. Make sure you are generating a unique name for DNS.

  • publicIpAddressName: If you want to specify the any particular name for Public IP, you can update it here.

  • subnetName: Leave it as default.

  • subnetRef : Leave it as default.

  • virtualMachineSize : In the existing the document we are deploying the VM with size Standard_DS2_v2. If you want to deploy VM with any specific size, you can update it here.

  • virtualNetworkName : Leave it as default.

  • vmName: If you want to update the name of the VM, you can update the value but make sure you are concatinating the DID as Suffix. It is recommended to leave the VM name as default.

  • cloudlabsCommon: Leave it as default.

Resources

The Resources section contains details of the resources you want to deploy, and will vary depending on what type of service it is.

You can update the configuration of resources according to the requirement. Few examples are mentioned below:

  • In the existing template we are using Windows server 2016 Datacenter as image reference and disk type as Premium_LRS. If you want to deploy a VM with different image and disk type, you can update it in this resources section accordingly.

You can even utilize the below provided most used image reference details by replacing it in the existing template.

1. Windows Server 2019 Datacenter version

   "imageReference": {
      "publisher": "MicrosoftWindowsServer",
      "offer": "WindowsServer",
      "sku": "2019-Datacenter",
      "version": "latest"
   },

2. Windows 10 Pro 22H2 version

   "imageReference": {
      "publisher": "MicrosoftWindowsDesktop",
      "offer": "Windows-10",
      "sku": "win10-22h2-pro-g2",
      "version": "latest"
   },

  • In case you would like to use custom image stored in your Azure Compute Gallery, then provide the image ID for the imageReference property in this sample template for Windows VM or sample template for Linux VM. For more information on custom images, refer Creating the VM Images and Managing the VM Images.

  • Under Virtual Network resource, the address prefix for Vnet and subnet are configured as 10.0.0.0/16 and 10.0.0.0/24 respectively. If you want to deploy the Vnet in different address ranges, you can update it here.

  • Under Network Security Group resource, we are enabling RDP port from Security rules. If you want to enable other security rules like SSH, HTTPS, you can modify the security rules accordingly.

Outputs

Output is what you see when you look at the finished product of a template. The output values of VM username, password and DNS are required to configure RDP over HTTP feature, which allows to access the VM through the browser. Therefore, Keep the Outputs section as default.

Once you have made all the necessary changes, upload the file to Azure Blob Storage where the file must be publicly accessible through the URL.

Provide the file URL to the ARM Template URL property in the CloudLabs Template.