Cost Optimization on Azure

Cost is always a concern with customers when it comes to the cloud. I've had a number of conversations with customers lately around how they can take advantage of various offers and benefits on Azure to reduce their costs, and I thought I'd share some of them here as well. There are many things you can do to optimize cost, some of which have some caveats and some which may take more effort than others, but this should give you some ideas of things to consider if you'd like a lower Azure bill (and who doesn't love lower bills). Let's take a look through some of the options available, which type of resources they apply to, and how to leverage them in your environment. Because compute costs are typically the largest driver of costs, much of the focus here is on Azure Virtual Machines.

Reserved Instances

We recently announced the general availability of reserved instances on Azure, and this was great to see come to fruition. For VM workloads that are static and predictable in nature, this is a fantastic offer that can save upwards of 70% depending on the VM size. For workloads that are up and running 24x7x365 and are unlikely to change in VM size this certainly an option that should be looked at. Reserved instances are purchased in 1 or 3 year terms, with payment required for the full term up front. Once purchased, we match up the reservation to running instances, and decrement the hours from your reservation. Reservations can be purchased through the Azure Portal and since reserved instances are a compute discount, they are available for both Windows and Linux VMs. For more information take a look at the following documentation. /en-us/azure/virtual-machines/windows/prepay-reserved-vm-instances

Azure Hybrid Benefit

For customers who have made an investment in Windows Server licenses the Azure Hybrid Benefit gives customers usage rights for Virtual Machines on Azure. When applied to vitrual machines in Azure, you will not be charged for the Windows Server license and will instead be billed at the Linux rate. To be eligible for this benefit, current Windows licenses must be covered by Software Assurance. Each 2-processor license or each set of 16-core licenses are entitled to two instances of up to 8 cores, or one instance of up to 16 cores. The Azure Hybrid Benefit for Standard Edition licenses can only be used once either on-premises or in Azure. Datacenter Edition benefits allow for simultaneous usage both on-premises and in Azure. Most customers are typically licened by core, so you'll use that model for your calculation. If you have questions about what licenses you have, you can reach out to your license reseller or your Microsoft account team to get more information. Applying this benefit is easy, and can be done at deployment time for new VMs and can be enabled or disabled at any time on existing VMs.

We have also announced plans to provide similar capabilities for SQL Server licenses, but have not yet made this fully available. I mention this so that you be on the look out for this availability in the near future. /en-us/azure/virtual-machines/windows/hybrid-use-benefit-licensing

Enterprise Dev/Test or PAYG Dev/Test Subscription

The Enterprise Dev/Test and Pay-As-You-Go Dev/Test offers are a benefit you can take advanatage of to save costs on your non-production environments. This benefit gives you several discounts, most notably for Windows workloads, charging you the Linux rate for virtual machines. This also applies to SQL Server, and any other Microsoft software that is covered under Visual Studio subscription (formerly known as MSDN). There are a few requirements for this benefit, one being that it's only for non-production workloads, and another being that any users of these environments (excluding testers) must be covered under Visual Studio subscription. In short, for non-production workloads, this allows you save money on your Windows, SQL Server and other Microsoft Virtual Machine workloads.

Below are the full details of each offer. If you are a customer on an Enterprise Agreement, you'd leverage the Enterprise Dev/Test offer, and if you a customer without an Enterprise Agreement and are instead using PAYG accounts, you'd leverage the Pay-As-You-Go Dev/Test offer.

SQL Server Developer Edition

As of April 1, 2016, Microsoft has made SQL Server Developer Edition a free product for non-production use. This is yet another way you can save on Azure costs for your non-production environments. On the Azure Marketplace you can find SQL Server 2016 and SQL Server 2017 images for Developer Edition, which will eliminate the additional cost for SQL Server, and for previevious version you can provision a new Windows VM and download SQL Server Developer Edition from your Visual Studio Subscriber Downloads, provided you have a Visual Studio subscription. For full licensing infomration, take a look at the following links. Bottom line, for non-production workloads that use SQL Server you should look closely at taking advantage of this offer. One side note, there is no way to convert an existing SQL Server VM to another license type, you'll have to provision a new VM and migrate your databases to the new server.

BYOL SQL Server Licenses

If you are a customer on an Enterprise Agreement and already have an investment in SQL Server licenses and they have freed up as part of moving resources to Azure, you can provision BYOL images off the Azure Marketplace, giving you the ability to take advantage of these unused licenses and reduce your Azure VM cost. You've always been able to do this by provisioning a Windows VM and manually installing SQL Server, but this simplifies the creation process by leveraging Microsoft certified images. Take a look at the following blog post from the initial announcement, and you'll find these marketplace images available for you today to take advantage of.

Azure Cost Management (Cloudyn)

Last year Microsoft purchased Cloudyn and has since rebranded it Azure Cost Management. This is a free service that will anaylyze your Azure workloads and provide recommendations, such as right-sizing VMs and purchasing reserved instances. There's a whole host of features that give you the ability to evaluate, report and budget your Azure costs, so it's a great tool to take a look at to get an idea of where your money is going. For Azure services there is no charge for the service itself, and there is a paid tier if you need support and integration with other cloud providers. Definitely get this set up and leverage it to analyze your spend. Take a look at the following documentation for more details. /en-us/azure/cost-management/overview

Azure Advisor

Along with Azure Cost Management, Azure Advisor is another service to take a look at to identify areas of inefficiency. Azure Advisor evaluates your environment and provides recommendations on high availability, security, performance and cost. It's a good idea to pay attention to the recommendations as a whole, but specific to cost it will make recommendations around resizing or shutting down unused VMs, identifying where you might be able to take advantage of Azure SQL Elastic Pools, and unutilized ExpressRoute circuits that may be costing you money. Azure Cost Management will give you more details on your compute, but it's still a good practice to check Advisor regularly for all the recommendations it provides. /en-us/azure/advisor/advisor-overview

Right-Size/Shut Down/Deallocate VMs

One of the things that Cost Management and Advisor may recommend is right-sizing or shutting down VMs. Changing VM size is easy on Azure, and if you have VMs that typically sit idle, this is a great way you can reduce your costs. Shutting down unused systems is important as well, as often times VMs are created for a test environment or a project that maybe never took off, but nobody went back and cleaned up the environment afterwards. Identifying these systems is important, as they drive up your bill unnecessarily. It's also important to take a look at the usage patterns of your systems. If you have systems that are primarily used during business hours (or another regular time period) you should evaluate if you can shut them down when they are not being used. I've had customers succefully use Azure Automation to run scripts that will stop/start VMs on a schedule. Below are a couple examples of this (both of which are avialble in Azure Automatin), you can use these scripts or modify them as appropriate. Bottom line, it's important to evauluate the size, usage and usage patterns of your VMs to ensure they are as cost effective as possible.

Use Visual Studio Subscrption (MSDN) Keys

If you have a Visual Studio subscription (formerly known as MSDN) you do have the ability to use the license keys on Azure Virtual Machines. There are some limitations to this, they can't be used on production systems, other users of these systems must also be covered under the appropriate VS license, and you can't use this benefit for the Windows Server or Windows client VM licenses, but for things like SQL Server this could be another way to reduce your VM costs. You could provision a BYOL image, enter a key from your VS subscription and eliminate the costs for SQL Server for that VM. Take a look through the following documentation for the specific requirements and limitations. (the last FAQ has details on this licensing) (page 14 specifically has more details)

Migrate to PaaS Services

Lastly, as you move workloads to the cloud, a natural evolution is to start with IaaS services and them move them to PaaS as appropriate, and in an iterative process. PaaS services typically provide a substantial savings in both resource and operational costs. The challenge is that, depending on the type of service, varying levels of effort will be required to move to these servcies from both a time and resource perspective. You may be able to easily move a SQL Server databse to Azure SQL DB, but it may take substantially more effort to move your multi-tier application to a container or serverless based architecture. It's a good practice to continuously evaluate the architecture of your applications to determine if there are efficiences to be gained through PaaS services. Azure makes it easy to test these out with little risk, giving you the ability to try out new architecture patterns relatively easily. That said, it's typically a longer journey and may not be of immediate help if you're looking for quick wins from a cost savings perspective. The Azure Architecture Center is a great place to get ideas for transforming your application, as well as best practices across a wide array of architectures and Azure services.


Wrap Up

Customers are always looking at how they can shave costs across their IT environments, and as I've detailed here, there's numerous ways you can drive lower costs throughout your Azure environments. There is no one-size-fits-all solution, so you'll need to evaluate your environments and leverage the capabilities that fit. Some are going to provide more benefit than others, and there may be some work to realign resources to take advantage of these, but they're definitely worth looking into further.