Recently whilst looking at the Azure portal I came across a new section on the VM blade that I have not seen before, or I have and forgot about it. This section is called Automation. Under here you have the option to export the arm template for your virtual machine, but you also have this new Tasks section. Of course I clicked it to see what it was about and to my surprise it seems to be a place that has new automation tasks for Azure Virtual Machines that use Azure Logic Apps in the backend. Currently there are only 3 tasks here, Stop VM, Start VM and send monthly cost for resource. Unfortunately, there is no option to create your own, but hopefully that will come. In this article I am going to focus on the Stop and Start tasks. There was an old option using runbooks, but this new option seems to be a lot nicer. You can read about the old way at https://pixelrobots.co.uk/2018/07/start-stop-vms-during-off-hours-solution-in-azure/
Let’s get to it
So, in the Azure portal navigate to the virtual Machine you want to Stop and start. In here on the left-hand side scroll down till you find Automation and then click on Tasks.
Now, in here you will see a list of tasks if you have any created. To create one click on the Add button at the top. In this new blade you will be presented by the available tasks. To start, let’s create a stop task, so go ahead and click Power off a Virtual Machine.
Here you will need to create two Connections. Go ahead and click on Create next to Azure VM
In here click on the Sign in button and log in. Once done click on the next Create link. Again, sign in. Once done you should have two green ticks, now click Create at the bottom.
It’s now time to enter your schedules information. Just fill in this blade with something that suites you. You can even get a notification when the VM is shut down if you supply your email address. Once filled in click create.
Once it has finished being created you will be back to the Tasks blade and should see something like in the image below.
Now just repeat the above steps but select Start Virtual Machine. You have now created the two tasks to Stop and Start your virtual machine. This new method is a lot better than the old way and hopefully the automation tasks get expanded and perhaps one day a sort of marketplace of tasks will be available.
Thanks for reading. If you have any questions or comments please reach out.