It’s easy to create cloud resources, and it’s just as easy to spend hundreds if not thousands of dollars on said resources. So it’s good to know that there are many tools to help you manage your costs.

Many services in Azure have a flat rate, but there are also charges that occur on a per-use basis. Let’s take Azure SQL, for example. Azure SQL’s general purpose (Gen 4) price for a 2-core and 14 GB memory server is $0.5044 per hour. However, what doesn’t show up in the Gen 4 price chart is that each time you create a new database, you’ll be charged depending on the pricing tier for that database.

Luckily, Microsoft Azure has built-in features that allow for managing costs and funds spent. In this blog post, you’ll learn how to set a company up for success by having the cloud infrastructure you need, without going over budget.

Understanding the Azure Billing Model

Azure has a unique billing model that allows for different options depending on your organization.

Pay-As-You-Go

The pay-as-you-go model means you only pay for what you use without commitment. This, like most Azure services, allows for an hourly rate per usage. For example, let’s say you are using an A7 eight-core Azure virtual machine that costs $1.32 per hour, and you need the virtual machine for four hours.

This will add up to the following:

The virtual machine itself will come out to $5.28.

The standard hard disk drive will come out to $1.536

You may be wondering why you have to pay extra for the standard hard disk drive. By default, the virtual machine does not come with any additional components or features. Anything that is added to the virtual machine, including the operating system if it’s Windows, is an added cost.

The pay-as-you-go model is great if you need a development environment for a few hours or a few days. But as you can imagine, these costs can get out of hand. For instance, it’s very easy to create a virtual machine in Azure and then forget it’s on. Taking a look again at the above example, that dollar amount is only for four hours. If that same virtual machine was running for an entire month, the cost would go up to $963.60!

Always keep an eye on the bill even if you know you’re doing everything right because there’s always a chance that you may be charged too much or too little. There have even been cases where a customer is charged too much due to a bug in Azure that requires a bit of adjusting and a refund to the customer.

Reserved Instances

If you’re running multiple workloads and expect to stay with Azure, there are some options that can reduce your costs, such as reserved compute.

Reserved computing resources allow you to buy dedicated virtual machines, saving upwards of 72% (see here) compared to the pay-as-you-go model. Reserved instances are great if you know you’ll be staying with Azure because you have to reserve for an extended period of time.

Currently, there are two reserve options:

One-year reserve

Three-year reserve

Taking the same virtual machine example from the Pay-As-You-Go section above, the one-year reserve plan would save you roughly $27.00 dollars per month, while the three-year reserve plan would save you roughly $48.00 per month. By looking at the numbers, this doesn’t seem like a big difference, but this is just for one virtual machine. Imagine if you had 50 or 100 virtual machines. In those cases, reserved instances would be saving you thousands of dollars.

With the one-year and three-year reserved plans, there are two ways of paying:

For enterprise agreement (EA) customers, the Azure Monetary Commitment is used to purchase the reserved instances.

If the organization does not have an Azure Monetary Commitment, the organization will have to pay for the full one-year or three-year commitment upfront.

Many organizations wonder, “How can I stop my Azure bill from skyrocketing?” The answer to this question is not so easy with the Pay-As-You-Go model because by the time an organization reaches the Azure cap allowed, the company is well over budget. Implementing reserved instances removes the “what if?” from the organization’s financials.

Azure Government

If you are a government entity, Azure provides a separate plan to meet all security and compliance needs. Government pricing will differ between agencies, but it’s typically much lower than the standard organization’s pricing. In fact, Azure Government users get a 90-day free trial with a $500.00 credit, while the standard organization gets a 30-day free trial with only a $200.00 credit.

Cost Management

To understand how much you may spend per month, or year, take a look at the Azure Pricing Calculator. The calculator allows you to specify hours per resource, giving you an estimate of what your total cost will be.

Even with an Azure Government contract, there are still ways for an Azure bill to skyrocket. So here are the top five Azure best practices that can help you cut costs by, in some cases, as much as 30%.

Consider the type of virtual machine you are using . For a D-series machine, ensure that the application or workload running actually needs that much power. If not, perhaps think about scaling down to a B-series.

Check resource groups for unused disks . Many times, virtual machine disks can be changed and upgraded or the virtual machine is removed, but the storage disk is not.

Check how many databases are running in Azure SQL and confirm they are needed . Azure charges for each database that is created within Azure SQL, even test databases. So make sure that the databases running are essential.

Monitoring Usage and Spending

Monitoring the usage of cloud resources is crucial. It’s very common to spin up an unnecessary amount of compute or storage and end up using only 10-15%. You can easily downsize these resources. The application or server will not be negatively impacted, and your organization will save a lot.

In many cases, engineers will use defaults when creating resources, for example, a virtual machine. The issue is that resources like virtual machines have very large default sizes that are not needed most of the time for a standard workload.

When a friend of mine and his team started implementing Azure Resource Manager templates, they started with the QuickStart templates found on GitHub. The team didn’t know much about Azure Resource Manager or the syntax, but they knew that management wanted them to move faster with virtual machine deployments, specifically for development and testing environments for the application that was being deployed. The developers were getting antsy about having the ability to test their application at any given time.

Before even having the chance to learn Azure Resource Manager syntax, management just wanted the team to implement the virtual machine automation, so they went ahead with the defaults. However, what management hadn’t expected–and certainly didn’t want–was a bill from Azure at the end of the month for $11,000.

Budgeting

Budgeting plays a huge role when considering usage of resources. Each organization must have a quarterly budget that gives an approximate spending limit. Most departments do this manually, leaving room for failure. To ensure this is done in an automated fashion, there are several predefined automation practices in place.

Below is a screenshot of an ARM template from the quickstart templates found here.

The key feature in the ARM template below is the time period for startDate and endDate. This allows you to specify your budget frequencies.