fbpx Skip to content

How to create an Azure VM using ARM template

Azure virtual machines (VMs) are great when you need to quickly create new VMs that are based on the same specifications. Creating Azure VMs with templates helps you save time and money while also making sure your VMs are set up exactly how you want them to be. In this article, we’ll discuss how to use an Azure template to create new VMs in Azure and go over the considerations and steps involved in using templates in general. 

What is an ARM template?

An Azure Resource Manager template, also known as an ARM template, is a file that defines your virtual machine in code. The template is used to create and manage resources in Azure. Many Microsoft services such as Virtual Machines and Web Apps support or require you to use an ARM template. They can be used stand-alone or imported into Visual Studio for easy editing. Use community-contributed templates to deploy Azure resources through the Azure Resource Manager and get more done. Deploy, learn, fork, and contribute back.

Understanding ARM Template file :

So you’re not a coder? No worries! Let me break it down for you.

The ARM Template is a file that contains various key-value pairs in JSON format. It’s not that hard to understand its form, as you can see here:

{
“$schema””https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#”,
“contentVersion”: “1.0.0.0”,
“metadata”: {
“_generator”: {
“name”: “bicep”,
“version”: “0.4.613.9944”,
“templateHash”: “7822315097766237434”
}

  An ARM template consists of a JSON-based text file. It has the following sections:

  1. Schema, Content Version, and an API profile
  2. Parameters
  3. Variables
  4. Function
  5. Resources
  6. Outputs

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.

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

Variables: Variables are a powerful tool for making templates more dynamic, updateable, and easy to read. In other words, you can assign a short name to a specific value that can be referenced anywhere in the template. This becomes advantageous when you want to update all the values or references and only need to update one variable.

Functions: A template’s function is a set of steps and processes in order to achieve an outcome. It’s like a variable that defines the process followed when invoked by a template.

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

Output: Output is what you see when you look at the finished product of a template.

When to use an ARM Template:

Sometimes you have to do the same thing more than once. That’s where ARM Templates come in. You can deploy resources with a simple PowerShell script using an ARM Template.

Let’s get started!

Aim: As you know that you can create Azure VM using PowerShell and Azure portal however In this lab, we’ll try out deploying a VM with a quick start template and explore it’s monitoring features.

Pre-requisite:

  1.  Need an account on the Azure portal. Create one for free if you don’t have one.

Task 1: Visit the Quick Start Gallery and select a template.

  • Login to your Azure Portal. Now, open your favorite browser and search for Azure Quickstart Templates.
  • Search and select Deploy a simple Windows VM.
  • Click on the Deploy to the azure button. This will redirect you to your azure portal. You can enter your credentials to sign in.
  • Click on the Edit Template option in the Template section.

ARM template

  • Review all variables an parameters in the JSON file. Change the name of the virtual machine to myVMTemplate in virtual machine parameters and save changes.

How to create an Azure VM using ARM template

  • Create a new Resource Group and give it a name. Configure the other settings as shown in the image. Click on Review + create   (Give a unique username and password for the VM and set DNS Label Prefix to myvmtemplatexxxx where xxxx can replace any number or alphabets.)

How to create an Azure VM using ARM template

  • Monitor the deployment and then click Create.

Task 2: Verify and check VM Deployment.

    • From home, go to All Services and search Virtual Machines. Select and open your Virtual Machine.

Azure VM

    •  You can customize the time span according to your needs. In Overview pane, Select the Monitoring tab and scroll to check data.

Azure VM template

    • Review various types of charts to monitor virtual machine. You can click on any chart to add metrics or change the chart type other than as displayed.
    • Now from left sidebar click on Activity Log. Activity Log records all the operations such as creation or modification in VM every time. You can try adding filters and search for any specific operation.

How to create an Azure VM using ARM template

Final Thoughts:

In this blog, we talked about the basics of ARM Templates. These templates will help you create, update and deploy resources with just a few clicks from your computer; so you don’t need to be an expert programmer or developer to use them!

If you want to know even more about Azure Cloud and what it has to offer, don’t forget that our Microsoft Azure Solution Architect Certification course covers many other aspects.

Explore more blogs to have knowledge about cloud computing

6 Exciting AWS live projects – to boost your skills

4 Azure real time projects to learn

All you need before getting yourself Azure DevOps certifications (AZ-400)

Azure Web Apps – How to get started

Top 9 easy ways to secure AWS S3 buckets

No comment yet, add your voice below!


Add a Comment

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

Interview Preparation Questions

Category : Quiz
Open chat
1
Expert Guidance?
ThinkCloudly
Hello, how can we help you?