Azure Container Registry – cost optimization

Azure Container Registry – cost optimization can be straightforward once you’re familiar with the service’s capabilities. The key is implementing an effective scheduling system to reduce costs associated with storage usage. The solution involves configuring a clean-up task. Ready to learn how to set it up? Let’s dive in!

Azure Container Registry – cost optimization – terraform

Anticipate a guide on setting up clean-up tasks with a Terraform script. A CRON job will automate these tasks, allowing you to tailor the timing to your requirements. You’ll have the flexibility to specify the CRON schedule, details of which are available at this link.

Before delving into the specifics, you can access all the necessary resources by downloading them from the provided link. Happy configuring!

Azure Container Registry - cost optimization - terraform setup
Azure Container Registry – cost optimization – terraform set up

To configure clean-up tasks, you’ll need to do the following:

  1. Start by specifying the steps for the task you want to execute. In my setup, I utilize an image that includes the Azure Container Registry CLI to run the acr_clean_cmd. By default, this command is set to purge –filter ‘messagereader:.*’ –keep 5 –ago 0d.
    • This configuration targets the messagereader repository specifically for clean-up, ensuring that only the most recent 5 images are retained.
  2. Next, establish the CRON schedule. In my example, it’s set to ’30 10 * * *’, which means the clean-up operation is performed daily at 10:30 AM UTC.

If necessary, you can set up multiple tasks, one for each repository, allowing for a more detailed level of management. If a broader approach suits your needs, you can stick with one cleaning task.

Prerequisite

Your Azure Container Registry needs to be at the Standard SKU level or higher, as this feature isn’t available with the Basic SKU.

Within the Standard SKU of Azure Container Registry, you’re charged approximately $0.003 for each extra GB. Considering the size of images today, let’s say each image is 250 MB. If you maintain 10 repositories and each repository holds 100 images, your entire registry consumes 250 GB. Since the Standard SKU includes 100 GB, you would only be billed for the additional 150 GB. This means you could achieve a monthly saving of around $14.

The sum may seem modest, but consider that the Standard SKU itself costs $20. Therefore, in my scenario, the cost for additional storage is nearly equivalent to the cost of the Registry itself.

Summary

I’m confident that by leveraging Tasks in Azure Container Registry, you can streamline expenses. The larger your solution, the greater the potential for cost reduction. Have you ever performed a cleanup on your registry? It might be time to start.

I genuinely hope you found this information valuable. If you did, I would greatly appreciate your support through actions like Liking, Commenting, or becoming a follower on my LinkedIn profile. Your engagement means a lot to me.

2 thoughts on “Azure Container Registry – cost optimization

  1. This is tactical fix not a strategic ; low hanging fruits.
    Storage is cheap and compute is not!!
    A better thing to do is to ensure smaller images,
    Crated and secured base images
    Build optimization ;
    Using multi-stage builds; build base images for all use cases
    check Alibaba approach and approach similar to those
    use better file systems squashfs for read-only container image and separate storage for write ops
    This sidecar pattern for storage avoids clubbing code with storage and also minimal re-build times and image sizes.

    unless its a multi tenant container orchestration platform that wants to optimize costs on storage, it is recommended to work on better images
    and build optimization than working on storage optimization

    1. Absolutely, your point is spot-on. I’ve encountered numerous projects where the container registry had not been maintained, and after two years, it had accumulated an extra terabyte of storage. Hence, this straightforward task, which is free in the Standard SKU, can be incredibly effective.

Leave a Reply

Your email address will not be published. Required fields are marked *