Azure, Technology

15. Manage Azure VM

Contents

Add Data Disks to a VM

  1. Go to the VM -> Disks
  2. Click on “Create and attach new disk”
  3. Set the options:
    – LUN (Logical Unit Number) used to identify a specific storage device
    – Disk Name: EG Data
    – Storage Type: this is the managed disk pricing tier
    – Size in GBs
    – Encryption: customer managed key or platform managed key. Platform managed is the default.
  4. Click on Save at the top

If you need to resize the disk you need to detach it first.

You can also attach an existing disk.

There are limits to how many disks you can attach to a VM depending on the tier the VM was created in . This can also be changed.

 

Using Powershell

From: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/attach-disk-ps

This example shows how to add an empty data disk to an existing virtual machine.

 

$rgName = 'myResourceGroup'

$vmName = 'myVM'

$location = 'East US'

$storageType = 'Premium_LRS'

$dataDiskName = $vmName + '_datadisk1'

$diskConfig = New-AzDiskConfig -SkuName $storageType -Location $location -CreateOption Empty -DiskSizeGB 128

$dataDisk1 = New-AzDisk -DiskName $dataDiskName -Disk $diskConfig -ResourceGroupName $rgName

$vm = Get-AzVM -Name $vmName -ResourceGroupName $rgName

$vm = Add-AzVMDataDisk -VM $vm -Name $dataDiskName -CreateOption Attach -ManagedDiskId $dataDisk1.Id -Lun 1

Update-AzVM -VM $vm -ResourceGroupName $rgName

 

Add NIC Interfaces to a VM

In this example we go through adding a second NIC to an already existing VM so it can access a different subnet.

  1. Go to the VM (the VM must be stopped to make these changes)
  2. Go to Networking -> attach NIC -> Create NIC
  3. Set the Options:
    – Name
    – Virtual Network ( the VNet containing the subnet you want to connect to).
    NOTE: the 2nd NIC has to be on the same VNet as the first NIC
    – Select the subnet
  4. Click on Create

Change a VM Size

The great thing about computing in the cloud is we scale the resources on the VM’s as we need them.

  1. Go to the VM -> Size
  2. This will give you a list of the different sizes and costs
  3. Select the new Size and click Select.

NOTE: this is a disruptive operation so it will cause a little bit of downtime

Redeploy a VM

If you are having issues with a VM you can redeploy it. This will wipe away the current VM and its resources, and create a new VM.

Using PowerShell

The command for this is:

Set-AzureRmVM -Redploy -ResourceGroupName" MyRG" -Name "MyVM"

Portal GUI

Go to the Resource Group -> VM -> Redeploy

Click on redeploy

Leave a Reply

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