Create a Windows Server 2012 R2 VM using ARM in Azure PowerShell

Hi Folks,

In this Blog Post we will learn how to create an Azure ARM Virtual Machine using Azure PowerShell.

For this, you will need an Azure Subscription and machine with Latest Azure PowerShell installed.



Run the following script in Azure Powershell:  //Replace MyName with YourName everywhere.



$locName = "Central US"

$rgName = "MyName-RG"

$vnetName = "MyName-VNET"


#Getting the Storage Account

$StorageAccount = Get-AzureRmStorageAccount -ResourceGroupName $rgName

$StorageName = $StorageAccount.StorageAccountName


#Getting the Virtual Network MyName-VNET

$vnet = Get-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $rgName


#Create a Public IP address

$ipname = "MyNameVM2-PIP"

$pip = New-AzureRmPublicIpAddress -Name $ipName -ResourceGroupName $rgName -Location $locName -AllocationMethod Dynamic


# Create A Network Interface

$nicName = "mynamevm2nic"

$nic = New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $locName -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id


#Get Credentails

$cred = Get-Credential -Message "Type the name and password of the local administrator account."


#Choose a VM name and Size

$vmName = "MyNameVM2"

$vm = New-AzureRmVMConfig -VMName $vmName -VMSize "Standard_A1"


$compName = "MyNameVM2"

$vm = Set-AzureRmVMOperatingSystem -VM $vm -Windows -ComputerName $compName -Credential $cred -ProvisionVMAgent -EnableAutoUpdate


$vm = Set-AzureRmVMSourceImage -VM $vm -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2012-R2-Datacenter -Version "latest"


$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id


$blobPath = "vhds/MyNameVM2osDisk.vhd"

$osDiskUri = $StorageAccount.PrimaryEndpoints.Blob.ToString() + $blobPath


$diskName = "windowsvmosdisk"

$vm = Set-AzureRmVMOSDisk -VM $vm -Name $diskName -VhdUri $osDiskUri -CreateOption fromImage


New-AzureRmVM –ResourceGroupName $rgName -Location $locName -VM $vm



When prompted, enter your Azure Credentials.




Enter MyName as the Username and  as password.




Wait for a couple of minutes for the VM to be configured.




To connect to your VM, Navigate to Azure portal. Click on Browse -> Virtual Machines




Click on the VM named MyNameVM2 then click on connect. 




Double Click the downloaded RDP file and then click on Connect.




Click on Use another account.




Enter MyNameVM2\MyName as username and  as password.




Click Yes.





Confirm your connection inside VM.





Azure Blob Storage: The PowerShell Way!

Hi folks!Great to see you again.This blog post is purely based on Azure Blob Storage: The PowerShell...

Read More >

Continuous Integration/ Continuous Deployment VSTS

Following the below steps you can build and deploy your ASP.NET  app to Azure from either Visua...

Read More >

How to Sync On-premise AD with Windows Azure AD using Azure AD Connect tool

 Azure AD is a service that provides identity and access management capabilities in the cloud. ...

Read More >

Creating a Point-to-Site Connectivity using Azure Resource Manager

Configure a Point-to-Site connectivity to a VNet using PowerShell (ARM Mode)Task 1: Create a Self-Si...

Read More >

How to Create an Azure Virtual Network by using a Deployment Template

Hello Folks!In this Blog post, we will try to learn how to create an Azure V-Net using an ARM templa...

Read More >

Locking VMs and Resources Groups with Azure Resource Manager using Azure PowerShell

Hello Folks!In this blog post we will be talking about locking down your Azure Resources with Azure ...

Read More >

Microsoft Azure: Implementing Internet Facing Load Balancers using Azure Resource Manager

Howdy Folks!I was exploring Network Load Balancer in Azure Resource Manager and found out that you c...

Read More >

Microsoft Azure Stack : Power of Azure in our datacentre

Why Azure Stack?Microsoft Azure Stack is a new hybrid cloud platform product that enables our organi...

Read More >

Microsoft Azure : Mobile Services - Xamarian.Android with .Net

NOTE: Microsoft Azure recommends Azure App Service Mobile Apps for all new mobile backend deployment...

Read More >

Microsoft Azure : The cloud for modern business

 Why Azure? Microsoft Azure: Cloud Computing Platform and Services Move faster Save Money ...

Read More >



multi vendor grocery app
8/26/2020 2:36:51 PM | Reply

Post a Comment

Try DevOpSmartBoard Ultimate complete Azure DevOps End-to end reporting tool

Sign Up

  • Recent
  • Popular
  • Tag
  • Key Metrics to Measure DevOps Success

    DevOps words means many things to many people and all the definitions might be partly right. DevOps is all about continuously seeking feedback, understanding challenges, and improving the way the soft...
  • Bulk Export Import Test Cases to Azure DevOps Test Plans using CSV file

    As a user of Azure DevOps Test Plans or TFS Test Management for manual testing, from a long time everyone including me had a wish, that copy of test cases from excel or csv file along with test steps ...
  • Azure DevOps Overview

    Now a days Azure DevOps is very famous with IT and Operations team along with developers, so what is Azure DevOps? It is a Software as a service (SaaS) platform from Microsoft that provides features r...
  • Volume Management in Kubernetes

    Since pods created in k8s are ephemeral, we are able to get the data as long as pods are alive, but if pods are terminated data stored in it completely lost and it cannot get back, for that we need to...
Monthly Archive

Contact Us
  • *
  • *