{"id":647,"date":"2021-07-04T20:02:27","date_gmt":"2021-07-04T20:02:27","guid":{"rendered":"https:\/\/www.spktechfit.com\/?p=647"},"modified":"2021-07-04T20:02:27","modified_gmt":"2021-07-04T20:02:27","slug":"15-manage-azure-vm","status":"publish","type":"post","link":"https:\/\/www.spktechfit.com\/?p=647","title":{"rendered":"15. Manage Azure VM"},"content":{"rendered":"<p style=\"margin: 0in; font-family: Calibri; font-size: 10.0pt; color: #767676;\">\n<h1 style=\"margin: 0in; font-family: Calibri; font-size: 16.0pt; color: #1e4e79;\">Add Data Disks to a VM<\/h1>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<ol style=\"margin-left: .375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\" type=\"1\">\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\" value=\"1\"><span style=\"font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\">Go to the VM -&gt; Disks<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Click on &#8220;Create and attach new disk&#8221;<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Set the options:<br \/>\n&#8211; LUN (Logical Unit Number) used to identify a specific storage device<br \/>\n&#8211; Disk Name: EG Data<br \/>\n&#8211; Storage Type: this is the managed disk pricing tier<br \/>\n&#8211; Size in GBs<br \/>\n&#8211; Encryption: customer managed key or platform managed key. Platform managed is the default.<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Click on Save at the top<\/span><\/li>\n<\/ol>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">If you need to resize the disk you need to detach it first.<\/p>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">You can also attach an existing disk.<\/p>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">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.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<h2 style=\"margin: 0in; font-family: Calibri; font-size: 14.0pt; color: #2e75b5;\">Using Powershell<\/h2>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">From: <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-machines\/windows\/attach-disk-ps\">https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-machines\/windows\/attach-disk-ps<\/a><\/p>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">This example shows how to add an empty data disk to an existing virtual machine.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<pre style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">$rgName = 'myResourceGroup'\r\n\r\n$vmName = 'myVM'\r\n\r\n$location = 'East US'\r\n\r\n$storageType = 'Premium_LRS'\r\n\r\n$dataDiskName = $vmName + '_datadisk1'\r\n\r\n$diskConfig = New-AzDiskConfig -SkuName $storageType -Location $location -CreateOption Empty -DiskSizeGB 128\r\n\r\n$dataDisk1 = New-AzDisk -DiskName $dataDiskName -Disk $diskConfig -ResourceGroupName $rgName\r\n\r\n$vm = Get-AzVM -Name $vmName -ResourceGroupName $rgName\r\n\r\n$vm = Add-AzVMDataDisk -VM $vm -Name $dataDiskName -CreateOption Attach -ManagedDiskId $dataDisk1.Id -Lun 1\r\n\r\nUpdate-AzVM -VM $vm -ResourceGroupName $rgName<\/pre>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<h1 style=\"margin: 0in; font-family: Calibri; font-size: 16.0pt; color: #1e4e79;\"><\/h1>\n<p>&nbsp;<\/p>\n<h1 style=\"margin: 0in; font-family: Calibri; font-size: 16.0pt; color: #1e4e79;\">Add NIC Interfaces to a VM<\/h1>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">In this example we go through adding a second NIC to an already existing VM so it can access a different subnet.<\/p>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<ol style=\"margin-left: .375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\" type=\"1\">\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\" value=\"1\"><span style=\"font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\">Go to the VM (the VM must be stopped to make these changes)<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Go to Networking -&gt; attach NIC -&gt; Create NIC<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Set the Options:<br \/>\n&#8211; Name<br \/>\n&#8211; Virtual Network ( the VNet containing the subnet you want to connect to). <\/span><span style=\"font-weight: bold; font-family: Calibri; font-size: 11.0pt;\">NOTE: the 2nd NIC has to be on the same VNet as the first NIC<br \/>\n<\/span><span style=\"font-family: Calibri; font-size: 11.0pt;\">&#8211; Select the subnet<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Click on Create<\/span><\/li>\n<\/ol>\n<p style=\"margin: 0in; margin-left: .375in; font-family: Calibri; font-size: 11.0pt;\">\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<h1><\/h1>\n<h1 style=\"margin: 0in; font-family: Calibri; font-size: 16.0pt; color: #1e4e79;\">Change a VM Size<\/h1>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">The great thing about computing in the cloud is we scale the resources on the VM&#8217;s as we need them.<\/p>\n<ol style=\"margin-left: .375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\" type=\"1\">\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\" value=\"1\"><span style=\"font-family: Calibri; font-size: 11.0pt; font-weight: normal; font-style: normal;\">Go to the VM -&gt; Size<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">This will give you a list of the different sizes and costs<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span style=\"font-family: Calibri; font-size: 11.0pt;\">Select the new Size and click Select. <\/span><\/li>\n<\/ol>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\"><span style=\"font-weight: bold;\">NOTE: this is a disruptive operation so it will cause a little bit of downtime<\/span><\/p>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<h1><\/h1>\n<h1 style=\"margin: 0in; font-family: Calibri; font-size: 16.0pt; color: #1e4e79;\">Redeploy a VM<\/h1>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">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.<\/p>\n<h2><\/h2>\n<h2 style=\"margin: 0in; font-family: Calibri; font-size: 14.0pt; color: #2e75b5;\">\nUsing PowerShell<\/h2>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">The command for this is:<\/p>\n<pre style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">Set-AzureRmVM -Redploy -ResourceGroupName\" <span style=\"font-style: italic;\">MyRG\" <\/span>-Name \"MyVM\"<\/pre>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">\n<h2><\/h2>\n<h2 style=\"margin: 0in; font-family: Calibri; font-size: 14.0pt; color: #2e75b5;\">Portal GUI<\/h2>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">Go to the Resource Group -&gt; VM -&gt; Redeploy<\/p>\n<p style=\"margin: 0in; font-family: Calibri; font-size: 11.0pt;\">Click on redeploy<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Add Data Disks to a VM Go to the VM -&gt; Disks Click on &#8220;Create and attach new disk&#8221; Set the options: &#8211; LUN (Logical Unit Number) used to identify a specific storage device &#8211; Disk Name: EG Data &#8211; Storage Type: this is the managed disk pricing tier &#8211; Size in GBs &#8211; Encryption: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[13,3],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/647"}],"collection":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=647"}],"version-history":[{"count":3,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/647\/revisions"}],"predecessor-version":[{"id":650,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/647\/revisions\/650"}],"wp:attachment":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}