Tuesday, April 11, 2017

Azure Cost Optimizations: Azure Storage

Depending on the makeup of your Azure consumption, Azure storage can sometimes make up a small percentage of your total Azure costs.  That being said, it is really easy to waste money in Azure storage if you do not manage it properly.  The purpose of this post it to chat about a couple things to look for to help optimize your azure storage costs.

1) Look for un-leased VHD files

When you used to delete VMs from the classic portal, Azure would kindly remind you (and make it easy) to delete the associated VHDs from storage.  This is not so much the case with all the new models that are in play, and you need to be looking at your storage accounts to remove un-leased VHD files.  As an aside, VHD files are leased for an infinite time period as long as the VM that they are attached to exists ( It does not matter the "state" that the VM is in).  Un-leased VHD files are a good indication of snapshots of existing VMs or of previous deleted VMs were the files were left in place.

You can use the get-azurestorageblob command to get a list of blobs that match your search criteria.  Once you have that, the ICloudBlob.Properties.LeaseState property can be used to determine the lease state.  It would report "Available" if the file was not leased.

2) Review the type of storage accounts deployed

It can be pretty easy to accidentally deploy the wrong type of storage for the need.  You can check the azure storage pricing list to see the differences with the blob types.  One of the most prevalent mistakes is deploying GRS or higher for VM VHD storage.

You can obtain a list of storage accounts by using the get-azurermstorageaccount or the get-azurestorageaccount depending on if you are using ARM or ASM.

In ARM, you are looking for the Sku.Name property to be not-equal to StandardLRS.  In ASM, you are looking for the AccountType property to be not-equal to Standard_LRS.

3) Review the size of your containers

It can be easy to leave storage "hanging around".  Remember that you pay for each and every block that has been stored.  One way to narrow down where to look is to grab the size of containers and look at the ones with the most storage in them.  Delete what you don't need and keep what you do.

Luckily, someone at Microsoft created a script to help us look at the cost of the blobs.  A note from personal experience, this can take a long time to run.

In conclusion, Azure storage can contribute to the waste in your Azure consumption.  The steps above can help you keep track of those costs.  It is recommended to run scripts/tools to report on this at least quarterly.  There are also various 3rd party services that you can use to help report on Azure costs.

No comments:

Post a Comment