Azure VM cost whenever it is up and running. There are times when you are not using the VMs and can be taken down to reduce the cost. This step can be automated and eventually optimize Azure cost buy shutting down during non- working time and weekends . There are many ways to accomplish this task. In this post we will be using Automation account to optimize Azure cost.
Step 1 – Create an Automation account
As a first step , create an automation account if not already present. If creating new account, give any name and specify a resource group and location. It will take some time to create the account. Refer the screenshots below.
Search for Automation account under services
Step 2: Once automation account created, select the account.
Step 3: Create or select Runbook
By default an account comes with 5 runbook. We will create our own
Select Runbook. Create a new Runbook using template from gallery. Click on “Browse Gallery” and select “Stop azure v2 VMs”. Click on the import button to import the template. Give a new name when asked for it.
You can make changes to default values if required. At this moment we are not making any changes and publish it as is.
Step 4: Schedule Run
Schedule option will be enabled once you publish the Runbook. To schedule click on the schedule button as shown below. And then click on “Link a schedule to a Runbook”.
Step 5: Resource group and VM names
Next step is to provide the resource group name and VM names. To do this click on “Configure parameters and run settings”.
If you leave the VM name empty, All servers in the VM group will be affected. The above example will shutdown all the server of VM group “…..” at 7:30 PM.
Similarly you can create schedule for VM startup and provide recurring details as required.
Thus by using Automation account and Runbook you can optimize Azure cost.