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.

 

Benefits Of Azure Resource Manager (ARM)

 

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.

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

Exit mobile version