Azure ACR automatic cleaning

Eduards 791 Reputation points
2021-11-05T07:06:32.837+00:00

Hello,

Currently we are configuring Azure ACR and it has some repositories each of repository consists of images.

Images are locked and tagged in incremental by numbers. Every time developers push their code, an image is created in Azure ACR repository.

We need to configure cleaning of this image, but we can't delete everything because there is a chance that image will contain some information needed for development.

  1. Is there possibility to monitor used space by repository? - I can see used space on all Azure ACR, but I need to see and repository instead.
  2. How could I automate repository image cleaning? - for steps would be (1. unlock image, 2. un-tag image 3. purge image 4. purge is initiated by date) - this probably is not possible from azure UI interface? Azure CLI?
  3. How could I identify that I could remove this Image and that would not damage all production environment?
  4. Also this should be monitored by used space and make alerting to notify users, that it's time to clean up some space in repo.

Thanks.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,826 questions
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
645 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SRIJIT-BOSE-MSFT 4,331 Reputation points Microsoft Employee
    2021-11-05T08:53:17.787+00:00

    @Eduards , thank you for your question.

    1. Is there possibility to monitor used space by repository? - I can see used space on all Azure ACR, but I need to see and repository instead.

    At the time of writing, there is no out of the box metric for spaced used by an ACR repository granularly. The available metrics in the Container registry standard metrics namespace are:

    Metric Exportable via Diagnostic Settings? Unit Aggregation Type Description Dimensions
    AgentPoolCPUTime Yes Seconds Total CPU time used by ACR tasks running on dedicated agent pools None
    RunDuration Yes Milliseconds Total Duration of ACR tasks runs None
    StorageUsed No Bytes Average Storage used by the container registry. Sum of storage for unique and shared layers, manifest files, and replica copies in all repositories** Geolocation
    SuccessfulPullCount Yes Count Total Successful pulls of container images and other artifacts from the registry None
    SuccessfulPushCount Yes Count Total Successful pushes of container images and other artifacts to the registry None
    TotalPullCount Yes Count Total Total pulls of container images and other artifacts from the registry None
    TotalPushCount Yes Count Total Total pushes of container images and other artifacts to the registry None

    **Because of layer sharing, registry storage used may be less than the sum of storage for individual repositories. When you delete a repository or tag, you recover only the storage used by manifest files and the unique layers referenced.

    For more information please check here.

    2. How could I automate repository image cleaning? - for steps would be (1. unlock image, 2. un-tag image 3. purge image 4. purge is initiated by date) - this probably is not possible from azure UI interface? Azure CLI?

    Again, there is no out of the box automation mechanism for all of this from Azure. However, you can write your own steps in scripts using Azure CLI. Following are the references:

    .

    3. How could I identify that I could remove this Image and that would not damage all production environment?

    Please check out the Recommendations for tagging and versioning container images.

    4. Also this should be monitored by used space and make alerting to notify users, that it's time to clean up some space in repo.

    From 1. currently, there is no out of the box metric for spaced used by an ACR repository granularly. However, here's an example of how to Send email alert when registry storage used exceeds a value

    ----
    Hope this helps.

    Please "Accept as Answer" if it helped, so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.
    0 comments No comments