{"id":457,"date":"2020-01-02T19:04:04","date_gmt":"2020-01-02T19:04:04","guid":{"rendered":"http:\/\/jackofalltradesmasterofsome.com\/blog\/?p=457"},"modified":"2020-01-02T19:04:41","modified_gmt":"2020-01-02T19:04:41","slug":"auto-spin-up-and-down-azure-virtual-machines-vm","status":"publish","type":"post","link":"https:\/\/jackofalltradesmasterofsome.com\/blog\/2020\/01\/02\/auto-spin-up-and-down-azure-virtual-machines-vm\/","title":{"rendered":"Auto Spin up and Down Azure Virtual Machines (VM)"},"content":{"rendered":"\n<p>One of the best perks of moving your infrastructure to the cloud is the ability to only pay for the resources you use. When using Virtual Machines that usage can be even further limited to servers that stay on only when you need them (business hours or nightly data runs) and then shut down to minimize costs. Here is a quick guide on how to Auto Spin up and Down Azure Virtual Machines (VM).<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Configuration of Automation Accounts<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>From the Azure Portal, navigate to \u201cAutomation Accounts\u201d<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"360\" height=\"105\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image.png\" alt=\"\" class=\"wp-image-459\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image.png 360w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-300x88.png 300w\" sizes=\"auto, (max-width: 360px) 100vw, 360px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Click \u201cAdd\u201d to create a new account and fill in the basic information. Any name, subscription resource group and location will do but keeping these inline with where your VM is located will make it easier. Keep \u201cCreate Azure Run As Account\u201d Selected as \u201cYes\u201d and select \u201cCreate\u201d to create.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"141\" height=\"389\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-1.png\" alt=\"\" class=\"wp-image-460\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-1.png 141w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-1-109x300.png 109w\" sizes=\"auto, (max-width: 141px) 100vw, 141px\" \/><\/figure>\n\n\n\n<p>From your new Automation account, select \u201cRunbooks\u201d<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"135\" height=\"414\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-2.png\" alt=\"\" class=\"wp-image-461\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-2.png 135w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-2-98x300.png 98w\" sizes=\"auto, (max-width: 135px) 100vw, 135px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>We will now \u201cBrowse Gallery\u201d and from the gallery section, select \u201cStart Azure V2 VMs\u201d followed by \u201cImport\u201d on the next screen<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"623\" height=\"150\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-3.png\" alt=\"\" class=\"wp-image-462\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-3.png 623w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-3-300x72.png 300w\" sizes=\"auto, (max-width: 623px) 100vw, 623px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"450\" height=\"169\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-4.png\" alt=\"\" class=\"wp-image-463\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-4.png 450w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-4-300x113.png 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><figcaption><br><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"242\" height=\"155\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-5.png\" alt=\"\" class=\"wp-image-464\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Do the same exercise with \u201cStop Azure V2 Machine\u201d. Both will now be available in the runbook\u2019s menu. <\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"530\" height=\"152\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-6.png\" alt=\"\" class=\"wp-image-465\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-6.png 530w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-6-300x86.png 300w\" sizes=\"auto, (max-width: 530px) 100vw, 530px\" \/><\/figure>\n\n\n\n<p>From the main runbook screen, you can now click on \u201cEdit\u201d and \u201cpublish\u201d<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"392\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-7.png\" alt=\"\" class=\"wp-image-466\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-7.png 624w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-7-300x188.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"308\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-8.png\" alt=\"\" class=\"wp-image-467\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-8.png 624w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-8-300x148.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Scheduling the Jobs<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Click on \u201cStartAzureV2Vm\u201d to go to details. From the menu on the right select \u201cSchedules\u201d followed by add schedules.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"332\" height=\"421\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-9.png\" alt=\"\" class=\"wp-image-468\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-9.png 332w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-9-237x300.png 237w\" sizes=\"auto, (max-width: 332px) 100vw, 332px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Select \u201cLink a schedule to your runbook\u201d and select \u201cCreate a new schedule\u201d. Give the schedule a name, description and a start date. Select \u201cRecurring\u201d for recurrence so that it runs daily. Leave \u201cSet expiration\u201d to \u201cNo\u201d<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"391\" height=\"304\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-10.png\" alt=\"\" class=\"wp-image-469\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-10.png 391w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-10-300x233.png 300w\" sizes=\"auto, (max-width: 391px) 100vw, 391px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Select \u201cParameters and run settings\u201d and \u201cConfigure parameters and run settings\u201d. In the details, use the name of the resource group name your VM is located in and the exact VM name of your virtual machine. Select ok to save and close the windows. <\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"391\" height=\"304\" src=\"http:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-11.png\" alt=\"\" class=\"wp-image-470\" srcset=\"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-11.png 391w, https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-content\/uploads\/2020\/01\/image-11-300x233.png 300w\" sizes=\"auto, (max-width: 391px) 100vw, 391px\" \/><\/figure>\n\n\n\n<p>You may require to edit and publish the runbook again but if not you can manually run the job to test or wait until the schedule is ready. Repeat the same exercise for the Shutdown VM job giving it a time later then the activation schedule previously created to  Auto Spin up and Down Azure Virtual Machines (VM). <\/p>\n\n\n\n<p>For more information, please see the official documentation from Microsoft.<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/automation\/automation-runbook-types\">https:\/\/docs.microsoft.com\/en-us\/azure\/automation\/automation-runbook-types<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the best perks of moving your infrastructure to the cloud is the ability to only pay for the resources you use. When using Virtual Machines that usage can be even further limited to servers that stay on only when you need them (business hours or nightly data runs) and then shut down to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":135,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,28,27,5,11],"tags":[44,95],"class_list":["post-457","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","category-azure","category-big-data","category-consulting","category-data-warehouse","tag-azure","tag-virtual-machine"],"_links":{"self":[{"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/posts\/457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/comments?post=457"}],"version-history":[{"count":5,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/posts\/457\/revisions"}],"predecessor-version":[{"id":475,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/posts\/457\/revisions\/475"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/media\/135"}],"wp:attachment":[{"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/media?parent=457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/categories?post=457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jackofalltradesmasterofsome.com\/blog\/wp-json\/wp\/v2\/tags?post=457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}