Whether it is an Enterprise Subscription or a Personal Pay-as-you-Go Subscription with Azure, the Subscriptions do have costs associated for Resource usage.
In the Subscriptions, VM’s also carry a runtime Cost which is something that can be controlled.
When a VM is Created, there are some Meters created that are associated with Running the VM, like CPU usage and Memory Usage.
The above Meters can be paused or stopped for the time when the VM is not Running at all. So in effect it is going to save Costs associated with these Meters.
How to achieve this? There are 2 ways to achieve this Auto-Shutdown: –
- Auto-Shutdown – Azure Portal allows to setup Auto-shutdown in the VM properties blade as below. Remember there is no Auto-Startup functionality as per Microsoft.
- Custom Managed Availability – Since there is no functionality to have Auto-Startup, so we need to set this up through a Custom Solution. Though, there are various ways to do it but I am going to propose a very simple solution: –
- Setup Tags for the VMs as per availability desired with 24×7 and On-Demand being extreme end cases. Owners or Contributors will have full control of these Tags.
- Then Azure Logic App or Function App can used the Availability Tag to ensure VM Availability at given point in time. A recurring schedule of 15 mins allows us to have a “Recurring CheckPoint”
- according to the TAGs setup by its Owners or Contributors in the Subscription / Management Groups
|24×7||This type of VMs will not be in the list of VMS to be automatically started or Stopped|
|Weekdays||The VM will be shutdown during the weekend and if found running, it would be automatically shutdown by the Logic Apps|
|Working hours||This will allow the VMs to be available only during specified time window. There is an advanced setup that can be done with addition of timezone Tag, but if there is no requirement to go that route, then the default UTC timezone can also be used. All the VMs in Azure default to UTC timezone.|
|On-Demand||This allows the VMS to be available only when required and the VMS can be shut down at the end of Day. This flow needs to have some intelligence built-in so that the Logic App can understand the TimeZone / Location in which the VM is running.|
Tags can be setup either during Creation of a VM or after creating it as well.
If there is a Governance requirement, the Azure Policies can be applied to the Subscriptions to make sure that Tag name always accepts a predefined list of Values.
See you next time !