IT teams can configure an Azure deployment in a variety of ways. The total cost on an Azure cloud computing bill depends on the specific configurations and services they choose.
That said, there are some general strategies to reduce Azure costs. For example, an organization can tap into different payment plans, use native Azure cost management tools and rely on resource tags.
Here are six Azure cost optimization best practices, several of which can apply to any Azure resource type.
1. Explore payment options
Azure provides several payment options for VMs, including:
- On-demand or pay-as-you-go. This option lets you launch VMs instantly, whenever they're needed. While pricing per hour of runtime is the most expensive option, it's flexible and convenient. Organizations can run their instances as long as they want, without interruption. This option does not require any upfront planning, as VMs launch on demand.
- Reserved. With this option, you reserve VM instances for one- or three-year periods. Reserved instance pricing provides discounts as high as 72% compared to on-demand pricing, according to Microsoft.
- Spot. This purchasing option lets users buy spare Azure compute capacity for a discounted price of up to 90% compared to on-demand pricing. The catch is that Microsoft can terminate a Spot instance at any time, based on capacity demands. This option is suited best for workloads that can tolerate pauses, such as batch data processing.
While on-demand instances are a common choice for organizations, consider whether Reserved or Spot instances can save money, while still meeting workload requirements.
2. Take advantage of Azure cost management tools
Azure provides several tools to predict and optimize cloud spending. These tools include:
- Azure Pricing Calculator. Before you deploy workloads on Azure, use the pricing calculator to anticipate how much they'll cost. Experiment with different service types or configurations within the calculator to find cost-saving opportunities.
- Azure cost analysis. Once workloads run in Azure, use the cost analysis feature in the Azure portal to understand how much each workload will cost. This tool also forecasts future spending based on current configurations.
- Azure budgets. To enforce organizational goals related to cloud spending, configure budgets in the Azure portal. Budgets allow you to set spending thresholds for Azure users and groups. The service will generate alerts when the thresholds are passed.
- Azure Advisor. Azure Advisor provides cost-optimization recommendations. These recommendations focus on reducing costs for VM instances. As a result, it's not useful for optimizing spend on other resource types, such as databases.
- Azure Resource Manager. This tool enforces management rules over Azure resources, such as who can create them and how they are tagged. Although Resource Manager is not a cost-optimization tool, per se, it can reduce costs by preventing shadow IT. It also helps admins identify workloads that are running when no longer needed.
3. Move workloads to containers
If an application currently runs on VMs, migrating it to containers may save money in cloud hosting costs. This is because, compared to VMs, containers waste fewer resources on virtualization overhead; you can fit more containers onto a single host.
For example, imagine that you currently have a dozen WordPress servers. Each server runs on a different Azure VM. By deploying the servers as containers using Azure Kubernetes Service (AKS), you could consolidate into three or four VMs and spread the WordPress instances between them.
Because AKS pricing per host server is the same as standard Azure VM pricing, you could reduce your hosting costs by as much as 75%. AKS charges an additional fee of $0.10 per hour if you choose an uptime guarantee, but this is optional.
4. Go serverless
Serverless computing, which is available through the Azure Functions service, is another way to reduce costs. Software deployed as serverless functions runs on demand, based on user-defined triggers. You pay only when the software runs. Serverless computing is best suited for compute-intensive workloads that run intermittently.
An example of a workload that is likely to cost less as a serverless function is an application that resizes images when users upload them to a website. Image resizing requires a lot of CPU, but only needs to be performed periodically in this scenario. As a serverless function, the service would run only when necessary.
This would be more cost-effective than hosting the service on a VM with high CPU resources. In this case, you'd pay for the VM to run constantly, even when unneeded.
5. Tag Azure resources
Another Azure cost optimization best practice is to establish a resource tagging policy. Tools like Azure Resource Manager enforce this practice.
Tags are labels that identify cloud resources. For example, they can identify which user created a resource, or to which organizational cost center a resource belongs. Admins can list and search tags on demand. This is a good way to keep track of which resources are running, and to find workloads that could be shut down to save money.
As an example of how tags can optimize Azure costs, imagine you have several VMs for development and testing. You define a tag as stage:dev and apply it to these VMs. Later, when a companywide holiday approaches, you could search for resources with this tag and turn them off before the holiday break.
In this way, you avoid paying for VMs that you don't need while your company's operations are suspended. Without a centralized tagging policy, there wouldn't be an efficient way to identify these types of resources.
6. Choose the right region
Cloud regions are sets of data centers within a specific geographic area. The region you choose determines where, physically, your workloads are hosted.
Azure pricing often varies by regions -- with the North American regions typically being the cheapest -- so selecting a certain region could save money. For example, at the time of publication, the pay-as-you-go price of a B1s VM instance is $8.6140/month in the U.K. South region, compared to $7.5920 in U.S. East. By choosing the latter region, you'd save around 11% for the same Azure resource type.
However, the farther a region is from end users, the higher the risk of performance problems. These problems arise due to issues like high network latency and packet loss. For that reason, avoid choosing a low-cost Azure region if it means workloads will be hosted thousands of miles away from end users.