{"id":642,"date":"2021-07-04T19:51:43","date_gmt":"2021-07-04T19:51:43","guid":{"rendered":"https:\/\/www.spktechfit.com\/?p=642"},"modified":"2021-07-04T19:51:43","modified_gmt":"2021-07-04T19:51:43","slug":"13-azure-virtual-machines","status":"publish","type":"post","link":"https:\/\/www.spktechfit.com\/?p=642","title":{"rendered":"13. Azure Virtual Machines"},"content":{"rendered":"<h1>Create a Virtual Machine<\/h1>\n<h2>Creating a VM through Azure Portal<\/h2>\n<p>In this example we will create a Windows 2016 Server.<\/p>\n<p>From the Azure Portal:<\/p>\n<ol>\n<li>Click on Create a Resource<\/li>\n<li>Select Windows Server 2016 Datacentre<\/li>\n<li>Set the basic options: Subscription, Resource Group, VM Name, Region (price varies slightly)<br \/>\nAzure Spot Instance: this is for low priority resources only. You will get this cheap but if a higher paying customer comes a long you will get booted off. Kind of like standby by tickets for a flight\u2026<\/li>\n<li>Set the VM size<\/li>\n<li>Inbound Port Rules: Set the ports you want. EG: http, ssh, RDP<\/li>\n<li>Select the disk type and encryption<\/li>\n<li>Data disks are additional disks to the System drive<\/li>\n<li>Network settings &#8211; Leave them as default (see separate section on networking)<\/li>\n<li>Auto shutdown: this has handy for testing devices. You set it to auto shutdown so it isn&#8217;t running constantly and running up costs<\/li>\n<li>Once you have set the basic settings click on &#8220;Create&#8221;<\/li>\n<\/ol>\n<p>This will create the VM and the resources that go along with it such as:<\/p>\n<ul>\n<li>Disk<\/li>\n<li>Network card<\/li>\n<li>Network security group<\/li>\n<li>Public ip address<\/li>\n<\/ul>\n<h2>Create a VM in PowerShell<\/h2>\n<p>#Create a Windows 2016 VM that uses virtual network &#8220;myVnet&#8221;<\/p>\n<pre>New-AzVm `\r\n -ResourceGroupName \"vm-networks\" `\r\n -Name \"dataProcStage1\" `\r\n -VirtualNetworkName \"myVnet\" `\r\n -SubnetName \"default\" `\r\n -image \"Win2016Datacenter\" `\r\n -Size \"Standard_DS2_v2\"\r\n -OpenPorts 80,3389,443,22<\/pre>\n<p>It will prompt you for admin credentials on creation<\/p>\n<h1>Connecting to a VM<\/h1>\n<ol>\n<li>Go the new VM in Azure portal<\/li>\n<li>Click on Connect<\/li>\n<li>Select RDP<\/li>\n<li>Enter the credentials you set when creating the VM<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h1>VM Availability<\/h1>\n<h2>SLA for VMs<\/h2>\n<p>Even with no availability options set for a VM, the guaranteed up time of your VMs is as follows:<\/p>\n<ul>\n<li>For any Single Instance Virtual Machine usin<b><i>g Premium SSD or Ultra Disk<\/i><\/b> for all Operating System Disks and Data Disks, we guarantee you will have Virtual Machine <b><i>Connectivity of at least 99.9%.<\/i><\/b><\/li>\n<li>For any Single Instance Virtual Machine using <b><i>Standard SSD Managed Disks<\/i><\/b> for Operating System Disk and Data Disks, we guarantee you will have <b><i>Virtual Machine Connectivity of at least 99.5%.<\/i><\/b><\/li>\n<li>For any Single Instance Virtual Machine using <b><i>Standard HDD Managed Disk<\/i><\/b>s for Operating System Disks and Data Disks, we guarantee you will have <b><i>Virtual Machine Connectivity of at least 95%.<\/i><\/b><\/li>\n<\/ul>\n<p>From: <a href=\"https:\/\/azure.microsoft.com\/en-us\/support\/legal\/sla\/virtual-machines\/v1_9\/\">https:\/\/azure.microsoft.com\/en-us\/support\/legal\/sla\/virtual-machines\/v1_9\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>Availability Options<\/h2>\n<p>You can set the availability options for a VM when you are creating it, it cannot be set after the VM is created.<\/p>\n<h3>Options:<\/h3>\n<ol>\n<li><b>Availability Set:<\/b> This is where you have 2 or more VMs in a set to provide high availability. There is a Load Balancer in the availability set that distributes traffic between the VMs. These VMs in an Availability Set have a higher guaranteed uptime at 99.95%. You don\u2019t pay for the Availability set, but you do pay for the extra VMs in the set.<\/li>\n<li><b>Availability Zones:<\/b>\u00a0 An Availability Zone is a physically separate zone, within an Azure region. There are three Availability Zones per supported Azure region. Each Availability Zone has a distinct power source, network, and cooling. By designing your solutions to use replicated VMs in zones, you can protect your apps and data from the loss of a data centre. If one zone is compromised, then replicated apps and data are instantly available in another zone. These have a guaranteed uptime of 99.99%<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h1>VM Monitoring<\/h1>\n<h2>Basic Monitoring<\/h2>\n<p>If you go to the VM and then click on &#8220;Overview&#8221; you will get some basic monitoring like CPU, Network, Disk bytes and disk operations<\/p>\n<h2>Detailed Monitoring &amp; Diagnostics<\/h2>\n<p><b><i>See section 6.1 as this covers very similar information<\/i><\/b><\/p>\n<p>For more detailed monitoring and diagnostics go to the VM -&gt; Monitoring -&gt; Diagnostic Settings<\/p>\n<p>To use this you must first set it up. This is done by clicking on &#8220;Enable Guest Level Monitoring&#8221;. What this does:<\/p>\n<ul>\n<li>Installs an agent on the VM<\/li>\n<li>Reboots the VM<\/li>\n<\/ul>\n<p>This agent then pulls diagnostic data from the VM and puts it in a Storage Account. You can then query it and send it to other applications.<\/p>\n<h3>Settings<\/h3>\n<ul>\n<li><b>Performance Counters:<\/b> here you can set the sample rate in seconds and the units to use (EG: percent)<\/li>\n<li><b>Log:<\/b> this is similar to the Windows Event viewer. You can select which logs and levels to collect.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h1>VM Custom Script Extension<\/h1>\n<p>When you create a VM through the portal there is an option called &#8220;Extensions&#8221; which allows you to run a script after the VM has been setup. This allows you to do things like:<\/p>\n<ul>\n<li>Install applications<\/li>\n<li>Copy files to the VM<\/li>\n<li>Open ports<\/li>\n<\/ul>\n<h2>Extensions<\/h2>\n<p>You can manage the Extensions on a current VM by going to VM -&gt; Extensions. Here you can see the current extensions installed and also have the option to add new extensions.<\/p>\n<h1><\/h1>\n<h1>Azure Bastion Service<\/h1>\n<p>Bastion is a method of connecting to a VM. You connect to the Bastion server in order to connect to your VMs. This allows you to turn off public RDP &amp; SSH access on your VMs which makes them more secure. The Bastion service does not need a public IP.<\/p>\n<p>Setting up Bastion:<\/p>\n<ul>\n<li>Create VM with the Bastion service (do this through the VM section)<\/li>\n<li>Create a separate subnet for Bastion services<\/li>\n<\/ul>\n<p>Once created, click on <b>connect <\/b>\u00a0and it logs in using an remote session through the web browser.<\/p>\n<p>&nbsp;<\/p>\n<h1>Virtual Machine Scale Sets<\/h1>\n<p>One of the great things about cloud computing is being able to scale your machines as you need. A virtual machine scale set allows you to do this easily.<\/p>\n<h2>Virtual Machine Scale Sets<\/h2>\n<p>Basically this is 2 or more VMs running behind a load balancer. It is provided as a service in a single package. You can find this in the Market Place<\/p>\n<p>This service charges you for the VM&#8217;s used, there is no extra charge for the scaling service.<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-machine-scale-sets\/overview\">https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-machine-scale-sets\/overview<\/a>:<\/p>\n<p><i>&#8220;Azure virtual machine scale sets let you create and manage a group of load balanced VMs. The number of VM instances can automatically increase or decrease in response to demand or a defined schedule. Scale sets provide high availability to your applications, and allow you to centrally manage, configure, and update a large number of VMs. With virtual machine scale sets, you can build large-scale services for areas such as compute, big data, and container workloads.&#8221;<\/i><\/p>\n<p>By default there is a limit of 100 instances per scale set.<\/p>\n<p><b>Creating a Virtual Machine Scale Set:<\/b><\/p>\n<ul>\n<li>From the &#8220;Virtual Machine Scale Set&#8221; page, click on &#8220;Create&#8221;<\/li>\n<\/ul>\n<ul>\n<li>A lot of the options here are similar to creating a VM (name, Resource Group, region, Image, size etc..)<\/li>\n<\/ul>\n<ul>\n<li>Scaling: on this tab you get to select the &#8220;initial instance count&#8221; (number of VMs) in the set. You can set the &#8220;Scaling Policy&#8221; to manual, or Custom. Custom allows you to set parameters around when a VM is added or removed. You can set this using thresholds of CPU usage. EG: If CPU usage it at 75% for 2 mins, add extra VM. If it drops below 30% for 2 mins remove a VM.<\/li>\n<\/ul>\n<ul>\n<li>Health Tab: here you can set up monitoring for an application such as HTTP on port 80.<br \/>\n&#8211; Automatic repair policy: this option can recreate a VM instance that is deemed &#8220;Unhealthy&#8221; from the monitoring options you have selected.<\/li>\n<\/ul>\n<ul>\n<li>Advanced Tab: By default there is a limit of 100 instances per scale set but you can increase that on this page. You also have options about spreading this among different zones and data centres.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h1>Stop and Start a VM with Powershell<\/h1>\n<pre>Stop-AzVM -resourceGroupName \"myRG\" -name \"MyVM\"\r\n\r\nStart-AzVM -resourceGroupName \"myRG\" -name \"MyVM\"<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Create a Virtual Machine Creating a VM through Azure Portal In this example we will create a Windows 2016 Server. From the Azure Portal: Click on Create a Resource Select Windows Server 2016 Datacentre Set the basic options: Subscription, Resource Group, VM Name, Region (price varies slightly) Azure Spot Instance: this is for low priority [&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\/642"}],"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=642"}],"version-history":[{"count":2,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions"}],"predecessor-version":[{"id":644,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions\/644"}],"wp:attachment":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}