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!
To configure clean-up tasks, you’ll need to do the following:
- 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.
- 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.
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.
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.