Virtual Machines provide flexibility to install and configure anything, anytime; and use it as you want. Besides all these features, VMs are costly so developers or managers of VMs need to make it cost effective. For this, Azure provides Automation Scripting to start and stop a VM automatically so that it will be cost effective apart from being flexible.
Let’s take a look at Azure Automation Scripting how you can start and stop your VM automatically in Azure. Let’s get started.
- Login to Azure portal and at the bottom, go to "More Services".
And, search for "Automation Account".
Here, you will have to provide -
- Account Name
- Select subscription
- Select or create resource group
- Select location
- If it’s your first automation account, select "Yes" at "Create Azure Run as Account".
After Automation Account is created, go to Runbooks in process automation.
Now, browse the gallery and look for "Start Azure V2 VMs" and "Stop Azure V2 VMs".
I’ve selected "Start Azure V2 VMs". Now, import it.
Give it a name you want. I used the default name. Don’t forget to press OK.
After it is created, it will lead you to Runbooks and now in order to use it, you need to publish it so that you can use it now go to "Edit".
Now, press "Publish".
After the Runbook is published, it is ready to schedule. Besides edit, press "Schedule".
In "Schedule" section, just schedule your VM’s start time and click "Create".
Now, click on "Start" and give ResourceGroup name and VM’s name in parameters.
Now, the Runbook is ready. It will start the VM automatically at your given time.