{"id":1377,"date":"2022-06-13T21:50:49","date_gmt":"2022-06-13T20:50:49","guid":{"rendered":"https:\/\/cyber.scot\/?p=1377"},"modified":"2022-06-13T21:54:07","modified_gmt":"2022-06-13T20:54:07","slug":"2022-05-20-auto-start-azure-vms-on-a-schedule-using-azure-devops-pipelines","status":"publish","type":"post","link":"https:\/\/cyber.scot\/2022\/05\/20\/auto-start-azure-vms-on-a-schedule-using-azure-devops-pipelines\/","title":{"rendered":"Auto start Azure VMs on a Schedule using Azure DevOps Pipelines"},"content":{"rendered":"\n<p><strong>Prerequisites:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Azure Subscription<\/li><li>Azure Resource Group<\/li><li>DevOps Orginisation<\/li><li>Azure Service Principal<\/li><li>Virtual Machine<\/li><\/ul>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>Setting up Service Principal<\/strong><\/li><\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">1. Open Azure Active Directory\n2. Open App Registrations\n\n<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"330\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/1.png\" alt=\"\" class=\"wp-image-1378\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/1-300x97.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/1-768x248.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/1-350x113.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/1-920x296.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/1-730x235.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/1-600x193.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Enter a name and click Register<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"525\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-1-1024x525-1.png\" alt=\"\" class=\"wp-image-1379\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-1-1024x525-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-1-1024x525-1-300x154.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-1-1024x525-1-768x394.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-1-1024x525-1-350x179.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-1-1024x525-1-920x472.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-1-1024x525-1-730x374.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-1-1024x525-1-600x308.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Click Certificates &amp; Secrets then New client secret.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"532\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-2-1024x532-1.png\" alt=\"\" class=\"wp-image-1380\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-2-1024x532-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-2-1024x532-1-300x156.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-2-1024x532-1-768x399.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-2-1024x532-1-350x182.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-2-1024x532-1-920x478.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-2-1024x532-1-730x379.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-2-1024x532-1-600x312.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Enter a Description and select how long the secret will be valid for.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"507\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-3-1024x507-1.png\" alt=\"\" class=\"wp-image-1381\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-3-1024x507-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-3-1024x507-1-300x149.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-3-1024x507-1-768x380.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-3-1024x507-1-350x173.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-3-1024x507-1-920x456.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-3-1024x507-1-730x361.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-3-1024x507-1-600x297.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Copy the secret value as we will need this later.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"514\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-4-1024x514-1.png\" alt=\"\" class=\"wp-image-1382\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-4-1024x514-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-4-1024x514-1-300x151.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-4-1024x514-1-768x386.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-4-1024x514-1-350x176.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-4-1024x514-1-920x462.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-4-1024x514-1-730x366.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-4-1024x514-1-600x301.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now we will add the Service Principal to be able to access the Subscription.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"922\" height=\"445\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-8.png\" alt=\"\" class=\"wp-image-1383\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-8.png 922w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-8-300x145.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-8-768x371.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-8-350x169.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-8-920x444.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-8-730x352.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-8-600x290.png 600w\" sizes=\"auto, (max-width: 922px) 100vw, 922px\" \/><\/figure>\n\n\n\n<p>Select Contributor or Virtual Machine Operator then search for the Service Principal name.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"352\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-9-1024x352-1.png\" alt=\"\" class=\"wp-image-1384\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-9-1024x352-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-9-1024x352-1-300x103.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-9-1024x352-1-768x264.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-9-1024x352-1-350x120.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-9-1024x352-1-920x316.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-9-1024x352-1-730x251.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-9-1024x352-1-600x206.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You will now see the Service Principal\u2019s permissions.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"385\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-10-1024x385-1.png\" alt=\"\" class=\"wp-image-1385\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-10-1024x385-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-10-1024x385-1-300x113.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-10-1024x385-1-768x289.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-10-1024x385-1-350x132.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-10-1024x385-1-920x346.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-10-1024x385-1-730x274.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-10-1024x385-1-600x226.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">DevOps Setup<\/h2>\n\n\n\n<p>Within the DevOps project, select Project Settings then open Service Connections.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"624\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-5-1024x624-2.png\" alt=\"\" class=\"wp-image-1389\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-5-1024x624-2.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-5-1024x624-2-300x183.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-5-1024x624-2-768x468.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-5-1024x624-2-350x213.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-5-1024x624-2-821x500.png 821w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-5-1024x624-2-656x400.png 656w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-5-1024x624-2-600x366.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Select Azure Resource Manager<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"507\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-6-1024x507-1.png\" alt=\"\" class=\"wp-image-1390\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-6-1024x507-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-6-1024x507-1-300x149.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-6-1024x507-1-768x380.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-6-1024x507-1-350x173.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-6-1024x507-1-920x456.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-6-1024x507-1-730x361.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-6-1024x507-1-600x297.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Select Service Principal (Manual). You can choose Service Principal (Automatic) but it will auto create a Service Principal that wont match our naming standards.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"403\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-7-1024x403-1.png\" alt=\"\" class=\"wp-image-1391\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-7-1024x403-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-7-1024x403-1-300x118.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-7-1024x403-1-768x302.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-7-1024x403-1-350x138.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-7-1024x403-1-920x362.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-7-1024x403-1-730x287.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-7-1024x403-1-600x236.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now fill out the details, these details can be found from the Subscription Overview\/Service Principal Overview and we will also need the value saved earlier from the Service Principal Secret.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Subscription ID - Found from Subscription Overview.\nSubscription Name - Name of Subscription.\nService Principal ID - Application (Client) ID found in the Service Principal Overview.\nService Principal Key - The value from the secret we created earlier.\nTenant ID - Can be found in the home screen of Azure AD or found in the Service Principal Overview.\n\n<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"456\" height=\"857\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-11.png\" alt=\"\" class=\"wp-image-1392\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-11.png 456w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-11-160x300.png 160w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-11-139x262.png 139w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-11-266x500.png 266w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-11-213x400.png 213w\" sizes=\"auto, (max-width: 456px) 100vw, 456px\" \/><\/figure>\n\n\n\n<p>Click Verify and it should be successful, if not you can scroll up and it will show you the error reason.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"459\" height=\"380\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-12.png\" alt=\"\" class=\"wp-image-1393\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-12.png 459w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-12-300x248.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-12-316x262.png 316w\" sizes=\"auto, (max-width: 459px) 100vw, 459px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">DevOps Pipelines<\/h2>\n\n\n\n<p>Select Pipelines &gt; Create Pipeline then select Use the classic editor.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"378\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-13-1024x378-1.png\" alt=\"\" class=\"wp-image-1394\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-13-1024x378-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-13-1024x378-1-300x111.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-13-1024x378-1-768x284.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-13-1024x378-1-350x129.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-13-1024x378-1-920x340.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-13-1024x378-1-730x269.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-13-1024x378-1-600x221.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Select a Repository to store the pipeline.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"352\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-14-900x352-1.png\" alt=\"\" class=\"wp-image-1395\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-14-900x352-1.png 900w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-14-900x352-1-300x117.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-14-900x352-1-768x300.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-14-900x352-1-350x137.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-14-900x352-1-730x286.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-14-900x352-1-600x235.png 600w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/figure>\n\n\n\n<p>Click Empty Job<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"405\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-15-1024x405-1.png\" alt=\"\" class=\"wp-image-1396\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-15-1024x405-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-15-1024x405-1-300x119.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-15-1024x405-1-768x304.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-15-1024x405-1-350x138.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-15-1024x405-1-920x364.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-15-1024x405-1-730x289.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-15-1024x405-1-600x237.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Select the + next to Agent Job 1 then search for Azure CLI then click Add<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"386\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-16-1024x386-1.png\" alt=\"\" class=\"wp-image-1397\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-16-1024x386-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-16-1024x386-1-300x113.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-16-1024x386-1-768x290.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-16-1024x386-1-350x132.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-16-1024x386-1-920x347.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-16-1024x386-1-730x275.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-16-1024x386-1-600x226.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Under the connection you should see the Service Connection we just set up<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"298\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-17-1024x298-1.png\" alt=\"\" class=\"wp-image-1398\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-17-1024x298-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-17-1024x298-1-300x87.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-17-1024x298-1-768x224.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-17-1024x298-1-350x102.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-17-1024x298-1-920x268.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-17-1024x298-1-730x212.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-17-1024x298-1-600x175.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Fill out the details as shown in the image and select Shell then Inline Script. Use the script below and modify the Resource Group name and the individual VM names. In the script below we start the Database VM first then wait for 360 seconds before starting the other VMs. You can add as many VMs as you need and you can have multiple sleep commands set if needed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">set -xe\n\naz vm start --resource-group rg-cyberscot-vm --name dbscyberscotdev01 &amp;&amp;  \\\n\nsleep 360s &amp;&amp; \\\n\naz vm start --resource-group rg-cyberscot-vm --name vmcyberscotdev01 &amp;&amp;  \\\naz vm start --resource-group rg-cyberscot-vm --name vmcyberscotdev02\n\n<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"493\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-18-1024x493-1.png\" alt=\"\" class=\"wp-image-1399\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-18-1024x493-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-18-1024x493-1-300x144.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-18-1024x493-1-768x370.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-18-1024x493-1-350x169.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-18-1024x493-1-920x443.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-18-1024x493-1-730x351.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-18-1024x493-1-600x289.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We now set the schedule that the VMs should start at. (Example is every weekday at 1am)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"330\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-19-1024x330-2.png\" alt=\"\" class=\"wp-image-1401\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-19-1024x330-2.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-19-1024x330-2-300x97.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-19-1024x330-2-768x248.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-19-1024x330-2-350x113.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-19-1024x330-2-920x296.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-19-1024x330-2-730x235.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-19-1024x330-2-600x193.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Ensure that \u2018Only schedule builds if the source or pipeline has changed\u2019 is unselected.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"610\" height=\"258\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-20-1.png\" alt=\"\" class=\"wp-image-1404\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-20-1.png 610w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-20-1-300x127.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-20-1-350x148.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-20-1-600x254.png 600w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/figure>\n\n\n\n<p>Select the Agent Specification, Give the pipeline a suitable name then save.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"280\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-22-1024x280-1.png\" alt=\"\" class=\"wp-image-1405\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-22-1024x280-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-22-1024x280-1-300x82.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-22-1024x280-1-768x210.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-22-1024x280-1-350x96.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-22-1024x280-1-920x252.png 920w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-22-1024x280-1-730x200.png 730w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-22-1024x280-1-600x164.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The pipeline will now run on the selected schedule and start the VMs.<\/p>\n\n\n\n<p>You can now combine Azures Auto-Shutdown feature with your Auto-Start pipeline for seamless start\/stop of VMs to reduce costs!<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"580\" src=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-23-1024x580-1.png\" alt=\"\" class=\"wp-image-1406\" srcset=\"https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-23-1024x580-1.png 1024w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-23-1024x580-1-300x170.png 300w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-23-1024x580-1-768x435.png 768w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-23-1024x580-1-350x198.png 350w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-23-1024x580-1-883x500.png 883w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-23-1024x580-1-706x400.png 706w, https:\/\/cyber.scot\/wp-content\/uploads\/2022\/06\/image-23-1024x580-1-600x340.png 600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Prerequisites: Azure Subscription Azure Resource Group DevOps Orginisation Azure Service Principal Virtual Machine Setting up Service Principal 1. Open Azure Active Directory 2. Open App Registrations Enter a name and click Register Click Certificates &amp; Secrets then New client secret. Enter a Description and select how long the secret will be valid for. Copy the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1408,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1377","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/cyber.scot\/index.php\/wp-json\/wp\/v2\/posts\/1377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cyber.scot\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cyber.scot\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cyber.scot\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cyber.scot\/index.php\/wp-json\/wp\/v2\/comments?post=1377"}],"version-history":[{"count":3,"href":"https:\/\/cyber.scot\/index.php\/wp-json\/wp\/v2\/posts\/1377\/revisions"}],"predecessor-version":[{"id":1410,"href":"https:\/\/cyber.scot\/index.php\/wp-json\/wp\/v2\/posts\/1377\/revisions\/1410"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cyber.scot\/index.php\/wp-json\/wp\/v2\/media\/1408"}],"wp:attachment":[{"href":"https:\/\/cyber.scot\/index.php\/wp-json\/wp\/v2\/media?parent=1377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cyber.scot\/index.php\/wp-json\/wp\/v2\/categories?post=1377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cyber.scot\/index.php\/wp-json\/wp\/v2\/tags?post=1377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}