Search code examples
azuredockerazure-container-registryacr

How to get ACR image details that are not used (pulled) for a specific period?


I have two questions regarding ACR image pulling.

  1. Is there a possibility to get the pull count of an ACR docker image?
  2. Can we get the details of docker images that are not pulled for a specific time period? For example, the images that are not pulled for the last 7 days?

Solution

    1. Is there a possibility to get the pull count of an ACR docker image?
    2. Can we get the details of docker images that are not pulled for a specific time period? For example, the images that are not pulled for the last 7 days?

    As I have mentioned above in the comments, You can achieve this by enabling the diagnostic settings on the container registry & passing those logs to log analytics workspace. you can write some custom kusto queries & pull the logs based on your requirement.

    The below query can help in getting the pull count of an image from acr over a period of time.

    ContainerRegistryRepositoryEvents| where ArtifactType contains "acr.docker"
    |where Repository contains "<repoName>" and Tag contains "<TagName>"
    | where OperationName contains "Pull"
    | where TimeGenerated > ago(24h)
    | count 
    

    You can refer this documentation for more sample Kusto queries.