Dynamic UI for Azure resources deployment using ARM Templates

Dynamic UI for Azure resources deployment using ARM Templates

While offering any solution, the developer needs to be aware of all the resources and their configurations. Also, suppose the number of resources used in that solution is high; a simple Azure Resource Manager (ARM) template can quickly become messy and confusing for the person trying to deploy resources using an ARM template. So, in this blog, we will see how we can make the ARM template more user-friendly and organized using a UI form. 

What is an ARM template? 

ARM templates are JSON (JavaScript Object Notation) files that users can use to deploy Azure resources with a single click. We can leverage them in cases where the end user’s technical knowledge about the Azure cloud is not enough or the user wants to see the capability of a solution. 

Why use an ARM template? 

Why should one use an ARM template for resource deployment? Following are some advantages of using ARM templates for resource deployment 

  • Declarative syntax 
  • Repeatable results 
  • Orchestration 
  • Modular files (You can break your templates into smaller, reusable components and link them together at the time of deployment) 
  • Extensibility (we can add PowerShell or Bash script in the ARM template) 
  • Built-in validation 
  • Tracked deployments 
  • CI/CD integration 

What are the components of the ARM template? 

Components of the ARM template include 

  • Parameters: Parameters allow you to pass different values to the ARM template for use during the deployment. 
  • Functions: Functions allow you to create complicated expressions that you don’t want to repeat throughout the template. 
  • Variables: Variables contain values that are used repeatedly throughout the template. 
  • Resources: The resources section defines the Azure resources to deploy with the template. Resources can be anything as small as a network security group to virtual machines, storage accounts, or Azure Functions. 
  • Outputs: The outputs section defines values and information returned from the deployment. Outputs are helpful for data that Azure dynamically generates during the deployment, like a public IP address. 

How to create UI for ARM template spec 

ARM template specs can be created using the ARM template and UI file. This blog will walk you through the steps to create a sample ARM template and UI file for it.  

Step 1: Creating an ARM template using Visual Studio Code

ARM templates can be created from Visual Studio code. 

  1. Installing Azure Resource manager tools extension in Visual Studio Code. 

Azure resource manager tool extension

2. Open a folder and create a new file named Deploy.json and type arm IntelliSense will suggest an arm template skeleton as shown in the image below.  

Creating new file in ARM tool

3. This will create a basic skeleton of the ARM template. To understand the format, refer to this link.

Schema of ARM template

4. We can now add resources that are to be deployed to the label of the resource. (Samples). Intellisense automatically suggests sample templates when typing the resource name, as shown in the image below. 

Adding resources to ARM template

5. You can add resources you want from IntelliSense or from samples. 

6. For demo purposes, we will be creating an ARM template to deploy the Ubuntu VM (Virtual Machine), SQL server, and IoT (Internet of Things) Hub. 

7. We can take inputs from a user which will be stored in parameters, for our case input parameters will be 

    • VM Name 
    • VM Location 
    • VM Size 
    • VM username and password 
    • OS version 
    • Iothub name 
    • SQL server name 
    • SQL username and password.

Adding input paramters to ARM

8. We can derive variables from parameters by formatting strings as shown in the image. 

Derive variables from parameters - ARM

9. Additionally, we can make the deployment of resources optional. In our case, we kept VM deployment optional by writing the condition property at the start of a resource. So now, by setting the parameter as true or false, the user can decide whether to deploy the VM resource or not. 

Adding a condition in ARM template

10. You can copy the sample JSON file from the GitHub link. 


Now if we try to deploy the ARM template  

a. Go to the Azure portal. 

b. Search for deploy a custom template and click on it. 

Deploy custom ARM template on Azure

c. Click on load the file and upload the deploy.json and click on save. 

Edit ARM template

d. You will see the UI below. If you observe this UI is not ideal for the customer, we can also observe that even if a user selects not to create VM fields related to virtual machine configuration are there.   

Custom deployment - ARM template

e. It will also be convenient if we have separate tabs so that the configuration does not confuse us, and it will be more organized. 

We can create a form that will give us features like dynamic parameter fields, separate tabs, stepwise configuration settings, etc. 

Step 2: Creating UI file for ARM template

f. Open Form View Sandbox and set package type to custom package. 

Form View Sandbox - ARM

g. Click on the Deployment template and select the ARM template file from which you want to create the UI form. In our case, we are using the same deploy.json file. It will generate a form as per your ARM template.

Generate a form for ARM template

h. You will see a basic skeleton of the form below, which will have schema and view, and the view will have steps under which elements will be there, which may be textbox, dropdown, etc. You can see examples on the left pane for references. 

i. For simplicity, we will be opening this JSON file in visual studio code. 

We will change the format and put some conditions in this form to make it more dynamic and organized. 

  • We will be dividing the form into two blades. First will have instance details SQL configuration and IoT hub name, and second will have all VM configurations. 

This can be done by adding a step and moving content related to VM in the 2nd step. Ultimately, we will change the path of VM parameters in the output. 

  • We will also make VM parameter visibility dependent on creating a new VM parameter field. 

j. First, let us create a new step called virtual machine configurations. 

Create VM configurations

k. In the elements field, we will move the VM-related elements from the basic step 

Move VM elements from basic step

l. We also need to change the path of parameter output as this parameter will be passed to the ARM template once a user submits the form. To change the path at end of the JSON file just change the paths Step(‘basic’) to step(‘vmConfig’) as shown in the image below for all VM-related fields which we moved to the VM step. 

Change paths for VM related fields

m. If we preview this form, we will be able to see the virtual machine blade as a separate one. 

Test form view for VM configuration

n. But still, we can see that even if we are making create VM as false still VM related fields are visible for that Visible property of an element we will put conditions like those shown in the image below in every element related to VM configuration. 

Add conditions to VM configurations

o. If we preview the UI now, we can see that when we create a new VM field as false, the fields related to VM configurations will be hidden. The final sample form file content can be copied from the link. 

Preview VM configuration

This way we can make the user experience richer and simpler. 

Step 3: Creating a template spec


  1. Now with these two files, we can create a template spec in the resource group so that we can deploy with a single click for that use command below. 

az ts create \ 

–name <template spec name> \ 

–version 1 \ 

–resource-group <resource group name> \ 

–location <location> \ 

–template-file <ARM template file path> \ 

–ui-form-definition <Uiform file path> 

2. After running this command, you will be able to see template spec resource in the resource group and by clicking on the deploy button a form will be started, and resource deployment is available with a single click.

Template spec resources

Common scenarios 

If the user wants to test any solution and does not want to learn how to deploy resources in the Azure cloud, then the user can use these types of templates. Even if someone wants to recreate the project in another Azure subscription, it will be easier with ARM template UI to configure and choose the resources the user wants to deploy. Developers can leverage this feature to make it easy for a user to deploy resources and utilize his time on more innovative tasks than providing support to the customer. 

Developers can use these types of UI forms to improve user experience internally as well as with clients when they are migrating their infrastructure from on-premises to the Azure cloud. If you want to learn more about this or are facing any challenges, feel free to contact us.