Optimizing Azure Costs
Microsoft Azure provides a variety of cloud services in a variety of cloud service models: IaaS, PaaS, and SaaS. When businesses migrate to the cloud, they must choose which model is best suited to their needs and is the most cost-effective. This course is designed to assist Cloud Architects in identifying their current Azure expenditures and providing greater awareness of the costs associated with each deployment model as well as each aspect of an Azure deployment.
Optimizing Azure costs begins with knowing your current Azure expenditures. This course introduces you to the tools built into the Azure Portal that can help you understand the total overall expenditures in Azure as well as break down those costs by area: Compute, Network, Storage, Identity, and App/Cloud Services.
The remainder of the course drills down on specific costs associated with each area of Azure identifies the costs associated with each service and provides very clear and concise methods for reducing Azure expenditures. Many of the cost savings methods will require minimal changes to your Azure deployment and will take just minutes to implement while other cost savings methods may take a shift in your Azure strategy, such as moving from Iaas to PaaS. By the end of this course, you will have gained a thorough understanding of how charges are incurred, how to reduce or even avoid some of the charges, and you will have learned how to significantly reduce overall Azure expenditures and get the most out of what is spent in your Azure deployment.
- Identify current Azure expenditures
- Optimize compute costs
- Optimize network costs
- Optimize storage costs
- Optimize identity costs
- Optimize App Service and Cloud Service costs
- Azure architects who are exploring options for reducing their Azure spending
- People preparing for Microsoft’s AZ-304 exam
- Good understanding of Azure administration and management
Related Training Content
For more content related to MS Azure, visit our Content Training Library.
If your Azure deployment consists of IAAS virtual machines there are several ways to manage and even reduce the costs associated with Azure virtual machines. Azure virtual machines use three primary resources, CPU cores, memory and storage for the virtual hard drives. CPU cores and memory costs are managed by choosing the appropriate virtual machine size. Well it might seem appropriate to choose a virtual machine size that provides sufficient capacity throughout a range of workload demands up to and including peak usage. This strategy requires Azure virtual machines with CPU and memory resources that are held in reserve and not being continuously consumed. In other words, unused resources. A better option is to choose a virtual machine size that provides CPU core and memory utilization needed for average demand. And use virtual machine scale sets to add capacity on demand by starting up an additional virtual machine. Virtual machine scale sets allow you to create and manage a group of identical load balanced virtual machines. You can define the number of instances or virtual machines in a scale set and configure the scale set to automatically increase or decrease the number of running virtual machines in the scale set based on demand or even on a schedule. Scale sets provide high availability, ensuring that the services and applications hosted on the scale set are responsive and always available. Another feature of virtual machine scale sets is the low-priority setting. By configuring a scale set as low-priority you can take advantage of Azure's unutilized capacity and realize a significant cost savings. When Azure needs the capacity, Azure will evict low-priority virtual machines.
Low-priority virtual machines aren't suited for all application though, they are best suited for workloads that can tolerate interruptions such as large compute workloads, development and testing and batch processing jobs. Azure will allocate virtual machines if there is capacity available. Bear in mind that low-priority virtual machines do not qualify for Microsoft's service level agreement. You can set the eviction policy for the scale set to either deallocate or delete. Deallocate moves your evicted virtual machine to the stopped-deallocated state making it easy to redeploy the evicted instance. Deallocated virtual machines do count against your scale set instance quota and you will incur storage costs for the underlying disks. With the deleted eviction policy the virtual machine is deleted and of course does not count against your instance quota and no charges incurred for storage since any disk associated with the virtual machine is deleted. It is recommended that you only use the auto-scale feature of scale sets with the eviction policy set to delete to avoid the costs of the associated disks and hitting your scale set instance quota limit. When using virtual machine scale sets you can manage the auto-scale parameter by setting the minimum and the maximum number of instances as well as the scale out and scale in a threshold. To achieve cost savings with scale sets ensure that you configured the scale in parameters appropriately.
The default setting of 25% for the CPU threshold is a good starting point. The higher the CPU value, the sooner the scale set will reduce the number of running virtual machines. Too high a value may place too great of a load on the remaining allocated virtual machines in that scale set. However, do some experimentation with the setting to determine the right balance between cost savings and performance. Choosing the right disk options for IAAS virtual machines can also result in cost savings. There are three performance tiers for disk storage; standard HDD, standard SSD and premium SSD. Standard hard disks are backed by standard mechanical hard drives and they are the most cost-effective storage. Standard SSD disks combine the features of premium SSD and standard HDDs to provide a cost-effective storage solution best suited for web servers where high IOPS are not required. Premium SSDs are backed by solid state disks and deliver the highest performance of the three performance tiers. Premium disks are available with any virtual machine size that includes the S in the series name.
These disks are better suited for high OPS workloads. Virtual machine disks can be either managed or unmanaged. Unmanaged disks are the classic type of disk that have been used by virtual machines and are created by using the classic deployment model. To utilize unmanaged disks you would need to create a storage account and specify that account when creating the virtual machine. With unmanaged disks you'll likely need to create multiple storage accounts and distribute your unmanaged disks between them to avoid exceeding the scalability target of the storage account. The scalability target depends upon the type of storage account which we'll be covering later. Managed disks are virtual disks where the storage account creation and management is handled automatically in the background for you. When creating a virtual machine choose the resource manager deployment model to used managed disks. There is no cost benefit to using unmanaged disks, therefore it is highly recommended that you use managed disks for any new virtual machines and convert any virtual machines using unmanaged disks to managed disks. In fact, you may actually realize a cost savings by using managed disks. When using unmanaged standard disks, HDD, it is important to enable the TRIM function. TRIM discards unused blocks on the disks. By enabling TRIM you will only be billed for storage that you are actually using. This is particularly important when large files are stored on an unmanaged HDD and then later deleted. To check the TRIM settings, open a command prompt on the Windows virtual machine and enter the first fsutil command as shown. If the commands returns zero, the TRIM setting is enabled.
If it returns one, run the second fsutil command shown here. Save money using IAAS virtual machines by deallocating any virtual machines that are not needed. This will be most applicable in development and testing environments. But it can also apply to the production environment in some cases. It is important to note the difference between the stopped and the stopped deallocated virtual machine states. A virtual machine can be stopped by connecting by your remote desktop protocol and by stopping it in Windows. However, the resources, CPU and memory, are still allocated to that virtual machine. To deallocate a virtual machine you must initiate the stop down from the Azure portal by clicking stop in that virtual machines blade. Verify that the status of the virtual machine is listed as stopped deallocated. An excellent tool for identifying unutilized virtual machines is the Azure Advisor.
This tool is built into the Azure portal. Access the Azure Advisor from the Azure portal by choosing Advisor from the navigation menu. From the Advisor blade, select cost. The cost blade shows you the estimated cost of continuing to run virtual machines, allowing you to choose to shut it down or even resize it. Additionally, Advisor will review your virtual machine usage over the past 30 days and determine if you could save money by using Azure Reserved VM Instances which I'll explain next. Another great way to reduce IAAS virtual machine costs is by using Azure Reserved VM Instances. Azure allows you to purchase and use virtual machines using their pay-as-you-go method. This method is suitable for short-term virtual machine deployments and for development and testing environments. However, for your production long-term deployments, Reserved VM Instances allow you to prepay for your virtual machines, up front, for one or three year periods. The cost savings can be significant. A one year purchase saves about 18% on your compute costs. While a three year purchase can save as much as 32%. To use this benefit, create a new Reserved VM Instance from the Azure portal. You will need to have a current pay-as-you-go Microsoft Azure Enterprise subscription to create Reserved VM Instances.
To create a Reserved VM Instance, from the virtual machine blade in the Azure portal, click Reservations. If you have an existing software assurance on-premises licenses for Windows or SQL Server, you can save even more on your computer costs by using those licenses on your Azure virtual machines. Each 2-processor license or each set of 16-core licenses can be used for two Azure virtual machines with up to eight cores or one instance with 16 cores. Note that standard edition licenses can only be used once either on-premise or in Azure. Data center edition benefits allow for simultaneous usage both on-premises and in Azure. Lastly, consider using Azure Platform as a service offering instead of infrastructure as a service. With Platform as a service, your services are hosted on hardware and operating systems that are completely managed by Microsoft. Deploying to Platform as a Service is relatively easy, scalable and requires less management effort. Take into consideration however whether or not you really need access to the operating system. Since with Azure App Service and Cloud Service Plans, the operating system is not exposed to the tenant.
Most of the common applications such as databases and web services are available for deployment using Azure's PAAS offerings. You will learn how to optimize Azure PAAS costs later in the course. In addition to using Azure App Services, you can realize cost savings by leveraging Azure Functions. Azure Functions allow you to run pieces of code, known as functions, without having to provision any compute resources yourself. Using Functions can perform a variety of tasks including processing data, or orders, perform file maintenance or just about anything that needs to run on demand. Functions can be triggered by a range of events like HTTP requests, Cosmos database modifications or to messages as they arrive to a storage cue, just to name a few. The advantage of Azure Functions over hosting your own code on a virtual machine is that you don't have to deploy, manage and pay for IAAS virtual machines to host your functions, if you choose the consumption plan. With the Consumption Plan, instances of the Function host are added and removed based on the number of incoming events. Billing is based on per-second resource usage and executions, therefore, you only pay when your Functions are running.
Jeff is a technical trainer and developer residing in Arizona, USA. He has been a Microsoft Certified Trainer for the past 18 years, providing in-house development and training on Microsoft server operating systems, PowerShell, SQL Server and Azure. When he’s not developing and delivering courses on Azure, he’s photographing galaxies, nebulae and star formations from his computer-automated observatory in Chino Valley, Arizona using a 14” Schmidt Cassegrain telescope.