Contents
Add Data Disks to a VM
- Go to the VM -> Disks
- Click on “Create and attach new disk”
- 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. - 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.
- Go to the VM (the VM must be stopped to make these changes)
- Go to Networking -> attach NIC -> Create NIC
- 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 - 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.
- Go to the VM -> Size
- This will give you a list of the different sizes and costs
- 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