- Azure FinOps Essentials
- Posts
- Azure FinOps Essentials
Azure FinOps Essentials
Eliminating Unattached Resources for Cost Efficiency
Welcome to the first edition of Azure FinOps Essentials! 🎉
I'm excited to have you on board as we embark on this journey to master cost efficiency on Azure. Each week, you'll receive actionable tips to help you optimize your Azure environment and keep your cloud costs under control.
In this first edition, I focus on eliminating unattached resources to reduce unnecessary expenses. Dive in and start saving today!
Cheers,
Michiel
Introduction
Optimizing your Azure environment starts with identifying and eliminating wasteful resources. Reducing unnecessary costs can significantly improve your overall cloud efficiency. This week, let's dive into practical steps to find and eliminate those costly resources.
So what are wasteful resources? This can be a virtual machine not being used, a web application with too many instances, a gateway with no backends, a license for something you are not using, backups that run too often, logging that is not needed, disks that are not attached. There are many more examples. Azure charges for services provisioned, even if they’re not used. When cloud services are not used or are underutilized, cloud waste occurs.
We can divide cloud waste into a couple of different categories:
Incorrectly sized resources
Idle or unattached resources
Not using the correct payment option
Incorrect resource configuration.
According to the FinOps Foundation, reducing waste was the highest key priority for FinOps practitioners across all spending tiers. This may be influenced by macroeconomic trends, with businesses looking for ways to reduce spending without reducing the value they are getting from their cloud investments.
I won’t go into all the mentioned categories in this edition, but we will cover them in next editions in more detail for sure. Let's look at unattached resources this time.
Identifying and Eliminating Unattached Resources
Unattached Resources
Unattached resources are components that are part of or used by other resources. A common example is a disk that is used by a virtual machine. Typically, a VM in Azure includes the machine (the actual CPU/memory), at least one disk, and a network interface. Although a disk can be reused by attaching it to another machine, it is usually linked to a specific VM. If you remove the VM, you need to remove all associated resources as well; otherwise, the disks will become unattached. This is a useful security feature, but it can lead to unnecessary costs.
We often think we pay only for what we use, but in reality, we pay for what we provision. Therefore, unattached resources like disks or network interfaces continue to incur costs. The cost of a disk depends on its size and settings. Even if the cost seems small, it can add up significantly when this issue occurs at scale.
Finding Unattached Managed Disks
To find unattached managed disks, you can use the Azure CLI with the following command:
az disk list --query '[?managedBy==`null`]'
If a disk is attached, the managedBy
field will show the name of the instance it is attached to. Unattached disks will have a null
value in this field.
Finding Unattached Network Interfaces
To find unattached network interfaces, use this command:
az network nic list --query "[?(virtualMachine==null)]"
While unattached network interfaces do not incur direct costs, they do reserve network address space, which can affect your network planning and efficiency.
Finding Unattached IP Addresses
Public IP addresses also have a small cost associated with them. To check for any unattached IP addresses, use the following Azure CLI command:
az network public-ip list --query "[?(ipConfiguration==null)]"
Unattached IP addresses will appear with a null
value in the ipConfiguration
field.
Automating Cleanup
To streamline the cleanup process, you can specify an output parameter and use scripting to loop through the found results and remove the resources:
az disk list --query '[?managedBy==`null`].id' -o tsv | xargs -I {} az disk delete --ids {} --yes
az network nic list --query "[?(virtualMachine==null)].id" -o tsv | xargs -I {} az network nic delete --ids {}
az network public-ip list --query "[?(ipConfiguration==null)].id" -o tsv | xargs -I {} az network public-ip delete --ids {}
Empty App Service Plans
Another form of unattached resource is an empty app service plan. You pay for the underlying infrastructure even if no apps are running on it. Regularly audit your app service plans to ensure they are actively in use, so have web applications running.
By identifying and eliminating unattached resources, you can reduce unnecessary expenses and improve the overall efficiency of your Azure environment.
Thanks for reading this weeks edition. Share with your colleagues and make sure to subscribe in order to receive more weekly tips. See you next time!
P.S. I have another newsletter about GitHub, Azure and dotnet news. Subscribe as well to keep informed:
We scour 100+ sources daily
Read by CEOs, scientists, business owners and more
3.5 million subscribers
Reply