CloudMicrosoft Azure

Azure ARM Template | Deploy Azure VM With Arm Template

Quickly Create Your Azure Virtual Machine With Azure ARM Template

Azure ARM template Azure Resource Manager

Azure Arm template is a management Service layer that helps you to create, manage, delete and update Azure resources.

Capabilities present in the Azure portal are also available via Azure CLI, Azure Powershell, Rest APIs & SDK

It helps to work with the resources in your solution as a group.

You can design a template for deployment which help for a different situation such as staging, testing, and production.

Azure Arm Template also helps to provide security, tagging, auditing, and managing resources after deployment.

Therefore, Azure Arm Template will make your deployment reliable faster, more secure, and more repeatable.

For Example, You will not have to create an Azure Virtual machine from the Azure portal and wait for its deployment.

With the help of Powershell and Azure CLI, you can use Arm Template which creates the Azure VM quickly.

Deploy vm with arm template

 

Benefits Of Azure Resource Manager (ARM)

  • Instead of handling resources individually you can manage, deploy and monitor all resources as a group.
  • You can repeatedly deploy the solution throughout the development lifecycle with confidence and consistency
  • Manage your infrastructure via Template instead of Scripts.
  • However, you can define the dependencies between resources to correctly deploy the resources.
  • As RBAC is  integrated into the management platform, you can apply access control to all the services in the Azure resource group
  • By applying tags to your resources you can logically organize all resources in your subscription.
  • Therefore, by checking the tags you can identify the billing by seeing the cost of resources having the same tag.
  • If we use the arm template, it assures us that, deployment will happen in the same way each time we use it.

 

How to create an Azure Virtual Machine from Azure Resource Manager

The template used in this article will deploy a single virtual machine running the Windows server operating system.

Creating an Azure Virtual machine with an Arm template consist of two steps.

First, we have to create an Azure resource group and then a virtual machine.

We are using a Powershell to create Our resource group so we will run the following cmdlet

$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"

$location = Read-Host -Prompt "Enter the location (i.e. centralus)"

$adminUsername = Read-Host -Prompt "Enter the administrator username"

$adminPassword = Read-Host -Prompt "Enter the administrator password" -AsSecureString

$dnsLabelPrefix = Read-Host -Prompt "Enter a unique DNS name for the public IP"

By running the above cmdlet, we will provide the Name of the Resource group, Location, Admin UserName, Password, and DNS label.

Once we set the above settings, we will use the JSON file from the Github on the location below

“https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.compute/vm-simple-windows/azuredeploy.json

So, now we will run the following cmdlet to use the JSON file to create an Azure simple VM.

New-AzResourceGroup -Name $resourceGroupName -Location "$location"

New-AzResourceGroupDeployment `

-ResourceGroupName $resourceGroupName `

-TemplateUri "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.compute/vm-simple-windows/azuredeploy.json" `

-adminUsername $adminUsername `

-adminPassword $adminPassword `

-dnsLabelPrefix $dnsLabelPrefix

(Get-AzVm -ResourceGroupName $resourceGroupName).name

 

Creating Azure VM With Local PowerShell using Azure Arm Template

If you do not want to use the Azure portal to create Azure VM.

You can use the local PowerShell from your computer to connect to the Azure account.

After connecting to the Microsoft Azure Account.

You can download and save the JSON template from Github.

Now you can try to deploy the Azure VM directly from your computer

Note: You have to install the Azure Module to your computer before you connect to the Azure Account.

The cmdlet to install Azure-Module to your PowerShell is

Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

Steps to Create Azure VM With local Powershell

First of all, connect to the Azure Account by running the following cmdlet

Connect-account -TenantId xxxxx

Now create a Resource Group in your Azure

Our case - New-AzResourceGroup -ResourceGroupName NewRG6 Location EaseUS

We have created a New Azure resource group by the name of NewRG6 and the location EastUS

Now we will run the following cmdlet to pick the configuration of the VM from the JSON file.

New-AZresourceGroupDeployment -ResourceGroupName NewRG6 -TemplateUri K:\AZ\deployvm.jason

Note: I have downloaded the JSON file from GitHub and saved it to my K drive.

Therefore, now it will prompt for the Admin UserName and Password.

Azure vm cmdlet to create vm using azure arm template

Once you provide that, it will create your Azure virtual machine in less than a minute.

In case of any confusion, Watch the video below for the step-by-step guide to creating Azure VM via PowerShell using arm Template.

How to create Azure Virtual Machine Using Powershell

For More, Azure Administration videos Feel free to check the youtube channel Techi Jack

Techi Jack

Techi Jack is an alternate internet name for Vikas Jakhmola, an IT professional with more than 12 years' experience. Currently, he is working as a freelancer. His experience includes setting up networks and servers for multiple organizations. He has been working with the server since 2003. TechiJack, or Vikas Jakhmola, shares his expertise and knowledge on his blog and in training courses.
Back to top button