{"id":81,"date":"2018-10-29T19:10:14","date_gmt":"2018-10-29T18:10:14","guid":{"rendered":"http:\/\/pro.timphaus.de\/?p=81"},"modified":"2019-12-17T17:56:50","modified_gmt":"2019-12-17T16:56:50","slug":"scheduled-start-start-azure-machine","status":"publish","type":"post","link":"https:\/\/dynamiacs.com\/?p=81","title":{"rendered":"Scheduled Start\/Start Azure Machine"},"content":{"rendered":"\n<p>I think\neveryone has the same problem: the Azure Virtual machines runs overnight where\nnobody is working on it and the costs are growing. <\/p>\n\n\n\n<p>To reduce\nthe cost for virtual machines in Azure Microsoft Flow can be used to schedule\nthe start\/stop processes of each Virtual Machine or complete resource groups in\nAzure.<\/p>\n\n\n\n<p>For this\nthere are two setups needed to be setup: Azure Automation Account and the\nFlows.<\/p>\n\n\n\n<p><strong>Azure Automation Accounts<\/strong><\/p>\n\n\n\n<p>First\nsteps are done in Azure. In Azure the service &#8220;Automation Accounts&#8221;\ncan be used for start\/stop processes. <\/p>\n\n\n\n<p>The\nservice can easily be found by the search function in the top pane.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"711\" height=\"310\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_10.png\" alt=\"\" class=\"wp-image-84\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_10.png 711w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_10-300x131.png 300w\" sizes=\"auto, (max-width: 711px) 100vw, 711px\" \/><\/figure>\n\n\n\n<p>In the\nAutomation Accounts a new Account will be created by choosing &#8220;+\nADD&#8221;. It is necessary to choose the Subscription in which the virtual\nmachines are located. If there are virtual machines in different subscriptions\nfor each subscription an Automation Account is needed.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"281\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_11.png\" alt=\"\" class=\"wp-image-85\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_11.png 710w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_11-300x119.png 300w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/figure>\n\n\n\n<p>In the\nnext window the name of the Account and the used Subscription and resource\ngroup is defined. The Location should be in the location as the subscription is\nand for &#8220;create azure run as account&#8221; should be Yes.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"370\" height=\"1024\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_12-370x1024.png\" alt=\"\" class=\"wp-image-86\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_12-370x1024.png 370w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_12.png 536w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/figure>\n\n\n\n<p>After the\naccount is created there the runbooks for start\/stop processes has to be\ndefined. In the Account the runbooks can be find in the details.:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"695\" height=\"1024\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_13-695x1024.png\" alt=\"\" class=\"wp-image-87\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_13-695x1024.png 695w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_13-204x300.png 204w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_13-768x1131.png 768w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_13.png 989w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/figure>\n\n\n\n<p>For this\nprocess the needed templates can be found in the gallery:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"360\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_14-1024x360.png\" alt=\"\" class=\"wp-image-88\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_14-1024x360.png 1024w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_14-300x106.png 300w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_14-768x270.png 768w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_14.png 1472w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In the\ngallery there are the needed runbooks available: The &#8220;Stop Azure V2\nVMs&#8221; and the &#8220;Start Azure V2 VMs&#8221;. Both of them are needed as a\nrunbook in the Automation Account.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"473\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_15-1024x473.png\" alt=\"\" class=\"wp-image-89\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_15-1024x473.png 1024w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_15-300x139.png 300w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_15-768x355.png 768w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_15.png 1490w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The\nFollowing steps are similar to the Stop and the Start Runbook.<\/p>\n\n\n\n<p>After\nselecting the runbook template this template need to be imported into the\nAutomation Account.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1019\" height=\"1024\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_16-1019x1024.png\" alt=\"\" class=\"wp-image-90\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_16-1019x1024.png 1019w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_16-150x150.png 150w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_16-300x300.png 300w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_16-768x772.png 768w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_16.png 1481w\" sizes=\"auto, (max-width: 1019px) 100vw, 1019px\" \/><\/figure>\n\n\n\n<p>In the\nnext window the name of the runbook and a description is defined.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"378\" height=\"1024\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_17-378x1024.png\" alt=\"\" class=\"wp-image-91\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_17-378x1024.png 378w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_17-111x300.png 111w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_17.png 553w\" sizes=\"auto, (max-width: 378px) 100vw, 378px\" \/><\/figure>\n\n\n\n<p>The\nimported runbook need to be published to be available. For this the imported\nrunbook has to be edit:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"289\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_18-1024x289.png\" alt=\"\" class=\"wp-image-92\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_18-1024x289.png 1024w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_18-300x85.png 300w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_18-768x216.png 768w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_18.png 1813w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In the\nedit screen the button &#8220;publish&#8221; will publish the runbook to be\nactivated.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"474\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_19-1024x474.png\" alt=\"\" class=\"wp-image-93\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_19-1024x474.png 1024w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_19-300x139.png 300w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_19-768x355.png 768w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_19.png 1638w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>These\nsteps are the setup which has to be done before setup the flows. This setup has\nto be done only one time because all of the future VMs in the subscription can\nbe used with this setup.<\/p>\n\n\n\n<p><strong>Microsoft Flow<\/strong><\/p>\n\n\n\n<p>After\nthis is finished the setup in Microsoft Flow can be done. For this business\ncase you have to setup only 2 steps for stop and 2 steps for start. These steps\nare 95% similar. Only the runbook name and the recurrence hour are different.<\/p>\n\n\n\n<p>Here an\noverview of the created flow which is now described how to setup.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"618\" height=\"814\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_03.png\" alt=\"\" class=\"wp-image-94\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_03.png 618w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_03-228x300.png 228w\" sizes=\"auto, (max-width: 618px) 100vw, 618px\" \/><\/figure>\n\n\n\n<p>Now the\nsteps for stop a machine are described.<\/p>\n\n\n\n<p>The first\nstep is the trigger for the recurrence so that Flow knows when to run.<\/p>\n\n\n\n<p>To setup\nthis step there is a connector called &#8220;Schedule&#8221; and within this\nconnector there is a trigger called &#8220;recurrence&#8221;.<\/p>\n\n\n\n<p>In the\ntrigger there is the setup for the time and when the flow has to run. Here in\nthis example the trigger runs once a day at 08:36 in the time zone UTC+01:00.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"763\" height=\"480\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_01.png\" alt=\"\" class=\"wp-image-96\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_01.png 763w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_01-300x189.png 300w\" sizes=\"auto, (max-width: 763px) 100vw, 763px\" \/><\/figure>\n\n\n\n<p>There are\nalso options available to use another frequency. If you choose weekly at the\nfrequency you can choose on which weekdays the flow should run.<\/p>\n\n\n\n<p>At the\nbottom there is a short preview of your setup is shown. <\/p>\n\n\n\n<p>The next\nstep in this flow is the action to do something. Here the action is an action\nfrom the connector called &#8220;Azure Automation&#8221;. The action to do is the\n&#8220;create Job&#8221; action. This action allows flow to create automated job\nin azure. This job is defined through the selected runbook. To setup this the\nnew Action called Azure Automation is created within the flow.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"764\" height=\"506\" src=\"http:\/\/pro.timphaus.de\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_02.png\" alt=\"\" class=\"wp-image-97\" srcset=\"https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_02.png 764w, https:\/\/dynamiacs.com\/wp-content\/uploads\/2019\/02\/recurrence_start_azure_vm_02-300x199.png 300w\" sizes=\"auto, (max-width: 764px) 100vw, 764px\" \/><\/figure>\n\n\n\n<p>In this\nsetup the used credentials to allow flow to connect to azure are&nbsp; selected. The mentioned azure subscription is\nselected. Then the resource group and the account of the needed Automation\nAction can be selected. The needed runbook for the stop process is selected and\nin the fields &#8220;VM Name&#8221; and &#8220;ResourceGroupName&#8221; the\ninformation from the virtual machine which is to processed by this flow has to\nentered.<\/p>\n\n\n\n<p>The same\nsetup but with another runbook has to be done for the start process.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I think everyone has the same problem: the Azure Virtual machines runs overnight where nobody is working on it and the costs are growing. To reduce the cost for virtual machines in Azure Microsoft Flow can be used to schedule the start\/stop processes of each Virtual Machine or complete resource groups in Azure. For this&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[8],"tags":[31,30,32],"class_list":["post-81","post","type-post","status-publish","format-standard","hentry","category-blog","tag-azure-automation","tag-scheduled","tag-virtual-machine"],"taxonomy_info":{"category":[{"value":8,"label":"Blog"}],"post_tag":[{"value":31,"label":"Azure Automation"},{"value":30,"label":"Scheduled"},{"value":32,"label":"Virtual Machine"}]},"featured_image_src_large":false,"author_info":{"display_name":"Jan","author_link":"https:\/\/dynamiacs.com\/?author=2"},"comment_info":0,"category_info":[{"term_id":8,"name":"Blog","slug":"blog","term_group":0,"term_taxonomy_id":8,"taxonomy":"category","description":"","parent":0,"count":38,"filter":"raw","cat_ID":8,"category_count":38,"category_description":"","cat_name":"Blog","category_nicename":"blog","category_parent":0}],"tag_info":[{"term_id":31,"name":"Azure Automation","slug":"azure-automation","term_group":0,"term_taxonomy_id":31,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":30,"name":"Scheduled","slug":"scheduled","term_group":0,"term_taxonomy_id":30,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":32,"name":"Virtual Machine","slug":"virtual-machine","term_group":0,"term_taxonomy_id":32,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"}],"_links":{"self":[{"href":"https:\/\/dynamiacs.com\/index.php?rest_route=\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dynamiacs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dynamiacs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dynamiacs.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dynamiacs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=81"}],"version-history":[{"count":2,"href":"https:\/\/dynamiacs.com\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions"}],"predecessor-version":[{"id":273,"href":"https:\/\/dynamiacs.com\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions\/273"}],"wp:attachment":[{"href":"https:\/\/dynamiacs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dynamiacs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dynamiacs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}