Azure services cost varies based on utilization and uptime and is one of the important factors for overall billing amount. In most of the scenarios, we use azure VM during office hours or some specific duration only but remain useless in off-hours.
And paying azure virtual cost during off-hours is simply unnecessary amount. In other words, we might not need to run the 24hours for users or services running in the VMs, however, the utilization can be only during office hours or daytime.
Therefore, we can optimize the resources and reduce the cost significantly by implementing auto-shutdown and auto-start in azure virtual machines. This means, we can add schedule for shutdown and start virtual machine automatically during off hours.
In this article, I will illustrate how to implement auto-start and auto-shutdown in azure virtual machine which will significantly cut the overall cost.
Auto-Start and Auto-shutdown virtual machine
This is one the feature of Azure which enables to start and stop virtual machine on user0defined schedules, provides insights through Azure Monitor Logs, and send optional emails by using action groups. This feature is available for both Azure Resource Manager and classic VMs for most scenarios.
For this article, I will Azure DevTest Lab with virtual machine.
First, Open azure portal with link Portal.azure.com and Select DevTest Lab or you can search it from search bar.
Note: You need to have subscription or can create trail one.
Then choose your lab. You can create new lab. Here I have already one lab with virtual machine window server with SQL server developer version. Choose lab, select configuration and policies as shown below:
After selecting configuration and policies, you will see following 3 options associated with start and stop schedules as portrayed.
Auto Shutdown policy
Set the level of control that lab users have over their individual VM shutdown schedules. Choose between granting users the freedom to set a schedule or instituting a mandatory schedule.
There are three choices: 1. User sets a schedule and can opt out, 2. User sets a schedule and cannot opt out and 3. User has no control over the schedule set by lab administrator.
By options, it is clear that we can either allow users to set schedule with or without opt out or only to administrator.
Auto shutdown
This option will allow you to set auto shutdown time and notifications. This policy applies auto-shutdown to virtual machines in the lab. Set enforcement policy for this schedule through the Auto shutdown policy blade.
You can enable with on and off option, then set schedule time for auto-shutdown (i.e. off-hours) which can be any off-hours or based on user defined, third option for time zone of the schedule, and finally, option to send notifications before shutdown with yes /no.
Auto start
This option for configuring auto start of azure virtual machines. Auto-start allows you to automatically start virtual machines in a lab at a scheduled time each day. The options are more flexible compare to shutdown policy.
Three option are same as shutdown policy: Allow auto-start with Yes and No, schedule start time and time zone. Another exclusive option is that you can choose days for auto start policy as illustrated below.
Note: This policy does not apply auto-start to any virtual machines in the lab. To apply auto-start policy to individual virtual machines, go to the virtual machine blade and enable auto-start.
Let me explain this note in more details, here we simply added policy for auto start to whole resources under this lab, however, we need to apply auto start individually to each virtual machine.
Now I will navigate one virtual machine under this resource lab and apply the auto start policy to the particular virtual machine.
We can simply apply the policy auto start to the virtual machine with option allow this Virtual machine to be scheduled for automatic start as shown above.
No comments:
Post a Comment