Chapter 23 Deploy Virtual Machines with CLI and PS

This Chapter covers following Lab Exercises

  • Create Windows Server 2016 VM using Azure CLI
  • Create Windows Server 2016 VM using Azure PowerShell

Exercise 185: Create Windows Server 2016 VM using Azure CLI

In this lab we will create Windows Server 2016 VM in Resource Group HKCLI and Subnet Web-Subnet in Virtual Network VNETCLI. HKCLI Resource Group was created in Chapter 181. Virtual Network VNETCLI was created in Exercise 183.

Get the URNAlias name of the image
az vm image list

Above command is not shown in below diagram as I scrolled to locate the Windows Server 2016 image. You can see urnAlias name is Win2016Datacenter

Screenshot_755

Get the name of VM Size
az vm list-sizes -location eastus2

Screenshot_756

For this lab I selected size Standard_D2_v2 (You need to scroll down to see it).

Create Virtual Machine using az vm command

az vm create --name VMCLI --vnet-name VNETCLI --subnet Web-Subnet -- resource-group HKCLI --image Win2016Datacenter --size Standard_D2_v2 - -admin-username AdminAccount --admin-password Aadmin@12345

Screenshot_757

Check the Virtual Machine created
az vm show --name VMCLI --resource-group HKCLI

Screenshot_758

Delete Virtual Machine
az vm delete --name VMCLI --resource-group HKCLI

Screenshot_759

Note 1: I checked up if VM is deleted or not by using az vm show command.

Note 2: Make sure to delete the VM otherwise it will incur charges.

Checking VM in Portal

Go VM VMCLI Dashboard>You can see it was created in Virtual Network VNETCLI. The size is Standard D2 v2.

Screenshot_760

Exercise 186: Create Windows Server 2016 VM using Azure PowerShell

In this lab we will create Windows Server 2016 VM in Resource Group HKPS and Virtual Network VNETPS. HKPS Resource Group was created in Exercise 182. Virtual Network VNETPS was created in Exercise 184.

Get the SKU, Offer & Publisher Name of the image
Get-AzureRmVMImageSku -Location EastUS2 -PublisherName MicrosoftWindowsServer -Offer WindowsServer

Screenshot_761

Get the name of VM Size
Get-AzureRmVMSize -Location EastUS2

Screenshot_762

Create Virtual Machine
New-AzureRmVm -ResourceGroupName HKPS -Name VMPS -Location EastUS2 -VirtualNetworkName VNETPS -SubnetName Web-Subnet - ImageName MicrosoftWindowsServer:WindowsServer:2016- Datacenter:Latest

Screenshot_763

Check the Virtual Machine created
Get-AzureRmVm -Name VMPS -ResourceGroupName HKPS

Screenshot_764

Delete Virtual Machine
Remove-AzureRmVm -Name VMPS -ResourceGroupName HKPS

Screenshot_765
UP

LIMITED OFFER: GET 30% Discount

This is ONE TIME OFFER

ExamSnap Discount Offer
Enter Your Email Address to Receive Your 30% Discount Code

A confirmation link will be sent to this email address to verify your login. *We value your privacy. We will not rent or sell your email address.

Download Free Demo of VCE Exam Simulator

Experience Avanset VCE Exam Simulator for yourself.

Simply submit your e-mail address below to get started with our interactive software demo of your free trial.

Free Demo Limits: In the demo version you will be able to access only first 5 questions from exam.