How to reduce Azure costs via automation

Proactive spending on the cloud saves money. Automation functions can play an important role in this.

Companies that use automation, for example to turn off development VMs overnight, will see a difference in their cloud bills. Those $30-$40 worth of test and development machines, storage resources, and other things add up over time.

With the automatic shutdown and start function, you can solve the problem of idle developing machines. Learn how Azure customers can leverage this automation to avoid unnecessary cloud spend.

Automatic shutdown for Azure VMs

Every virtual machine has an Azure-embedded automatic shutdown feature.

This is a good feature for a VM, but not ideal when there are dozens of machines to manage. A better approach would be Azure’s built-in policies for auto-start and auto-stop at certain times of the day.

Depending on requirements, automation means you don’t have to run homemade scripts to shut down machines when not in use. Also, the shutdowns can be applied to other machines as the infrastructure is added over time. With this automation, a company no longer incurs the expense of running a large development VM accidentally over the weekend.

Screenshot of the auto shutdown feature on the vm1 auto shutdown portal screen
Enable automatic shutdown feature (per VM in this case)

You need to differentiate lab infrastructure from production machines because using a shutdown script incorrectly can risk losing production. Using mandatory tags throughout infrastructure is one way to prevent the loss of critical production resources. An alternative way is to use management groups to separate development/test work from production. This ensures that actions are only taken at the appropriate scale and minimizes the risk of the production infrastructure being shut down.

You can also use Azure Monitor to act on a condition. When you set up an action group, you create a selection of programmatic responses to take an action when a certain threshold is met. It’s a good idea to set up alerts so you don’t change infrastructure unattended.

To make cost tracking easier, set up a daily automated cost export. You can do this via API calls, but an admin who wants simple, automated daily reporting should check this out New-AzCostManagementExport Cmdlet that outputs costs to an Excel-friendly CSV file. You can find the same automated functionality in the Azure portal.

Some cloud admins may prefer Azure’s Power BI application Cost Management, which provides deep insight into usage and spend. This tool creates a CSV file and stores it in a specified storage account, so there is minimal cost associated with Power BI.

Screenshot of the page
Automatically export your expense management data to an Azure blob storage

Data on what has been spent in the past can help a company gain better control over its future spending. These numbers can be the basis for alerts that let a team know when spending is approaching or hitting certain thresholds.

Don’t overdo these budget alerts to avoid alert fatigue. Where and how alerts are provided varies from company to company. For example, an organization may want reporting at the application level (such as tagging and resource groups) or at the management group. Tagging isn’t just for automation—it can also be useful for billing and notifications, if used and structured correctly.

How Azure Advisor can help

Azure Advisor offers Azure users recommendations in five areas, one of which is cost.

While Azure Advisor and Azure Monitor are in the same orbit of monitoring Azure environments, there are subtle differences. Azure Advisor provides guidance as a cloud environment scales and becomes increasingly customized. But it has a limited repertoire of topics on which to report and advise. It is designed for interactive use and offers the possibility to suggest correction paths.

Azure Monitor can collect logging data from almost anything in Azure. It can be configured to send an alert and its action groups can respond in specific ways. What it doesn’t do is offer a one-click fix. Instead, a cloud administrator must decide how to respond to a given situation and respond accordingly.

Leave a Reply

Your email address will not be published. Required fields are marked *