Author – Rupesh Sonawane, Cloud Engineer
These days cost optimization is the primary goal when it comes to work in any cloud. Most of the workload in IT sector depends on Servers provided that these resources must be compliant and follow the cost optimization. In Azure, we run virtual machines hosting any applications or databases and many more.
As these Azure VMs are running, they use Azure credits. To reduce the amount of your invoice, you can shut down the Azure VMs during off-hours such as nights or weekends. Then, the VMs are started again to be available during working hours as per defined schedule.
This can be achieved using one of the features in Azure i.e., Start/Stop VMs during off-hours. This feature starts or stops machines on user defined schedule and optionally can send emails using action groups.
Use cases
- Schedule VMs to start and stop.
- Schedule VMs to start and stop in ascending order by using Azure Tags.
- Auto-stop VMs based on low CPU usage.
Prerequisites
- The runbooks for the Start/Stop VMs during off hours feature work with an Azure Run As account.
- Need to create Automation Account and Log Analytics Workspace.
- The Automation account and Log Analytics workspace need to be in the same subscription and supported region.
- The workspace needs to be already exist, as one cannot create a new workspace during deployment of this feature.
Deployment
- Click on Create a resource and Search for Start/Stop VMs during Off-hours.
- Click on Create.
- Click on Workspace. Create a Log Analytics Workspace in a subscription same as that of VMs or select existing workspace. In Automation account section it will select existing Automation Account.
- Click on Configure parameters and provide necessary information and scheduling for the VMs. Click on OK and Create. Scheduling can be change in automation account.
- To change schedules, go to Automation account and click on Schedules. Select a runbook for VM and change its schedule from there.
For additional reference, check the documentation.