Getty Images

How to reduce Azure costs via automation

One way for Azure customers to reduce their spending is to be sure VMs deployed in the cloud aren't running when they aren't needed. Automation can help.

Being proactive about cloud spending saves money. Automation features can play an important role in this effort.

Organizations that use automation to power off development VMs overnight, for example, will see a difference in their cloud bills. Those $30 to $40 test and development machines, storage resources and other items add up over time.

With the auto shutdown and startup feature, you can solve the problem of unused development machines. Learn how Azure customers can take advantage of this automation to prevent unnecessary cloud spending.

Auto shutdown for Azure VMs

With any virtual machine, there is an auto shutdown feature embedded in Azure.

This is a good feature for one VM, but it is not ideal when there are several dozen machines to be managed. A better approach would be Azure's built-in policies for auto start and auto stop at specified times of the day.

Depending on requirements, automation means you won't have to run homemade scripts to shut off machines when they aren't being used. Plus, the shutdowns can be applied to other machines as infrastructure is added over time. With this automation in place, a business will no longer incur the costs of a large development VM that was accidentally left running over the weekend.

Screenshot of the auto shutdown capability on the vm1 auto-shutdown portal screen
Enable auto shutdown capability (per VM in this instance)

You'll need to differentiate lab infrastructure from production machines, since incorrect use of any shutdown script risks a production outage. The use of mandatory tags across all infrastructure is one way to prevent the loss of key production assets. An alternative way is to use management groups to separate dev/test work from production. This ensures actions happen only at the appropriate scope, and it minimizes the risk of turning off production infrastructure.

You can also use Azure Monitor to react to a condition. When you set up an action group, you create a selection of programmatic responses to perform an action when a certain threshold is hit. Setting alerts so you don't change the infrastructure without supervision is a good idea.

To help track costs, set up a daily automated cost export. You can do this via API calls, but an admin that wants simple, automated daily reporting should look at the New-AzCostManagementExport cmdlet, which outputs costs into an Excel-friendly CSV file. The same automated functionality can be found in the Azure portal.

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

Screenshot of the New export details page
Automatically export your cost management data to an Azure Blob Storage

Data on what has been spent in the past can help an organization gain greater control over its future spending. These numbers can be the basis for alarms that will let a team know when spending approaches or reaches particular thresholds.

To avoid alert fatigue, don't overdo these budget alarms. Where and how to deploy alerts will be different 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 is not just for automation -- it can be useful for billing and alerting, when used and built appropriately.

How Azure Advisor can help

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

While Azure Advisor and Azure Monitor move in the same orbit of monitoring Azure environments, subtle differences exist. Azure Advisor provides guidance as a cloud environment scales and becomes increasingly customized. But it has a limited repertoire of items on which it can report and advise. It is designed for interactive usage with the ability to suggest remediation paths.

Azure Monitor can ingest logging data from just about anything in Azure. It can be configured to send an alert, and its action groups can respond in specified ways. What it doesn't do is offer one-click remediation. Instead, a cloud admin must decide how to react to a particular situation and react accordingly.

Dig Deeper on Cloud infrastructure design and management

Data Center