Search code examples
azureazure-container-registry

Know number of images in Azure Container Registry


Im new to Azure Container Registry. How can I know the number of images per repository? It is possible by Portal? And also I want to know to do it by command-line


Solution

  • Well, I will show you something to you to understand what is the difference between the image tag and the repository.

    When you create an image, it must have a tag, then you push the image with the tag to Azure Container Registry. This time, there will be a repository with the name of your image to store the image manifest and tag.

    Here will be two conditions:

    1. If you update the image with a new tag and do not change the image name, then you push it to Azure Container Registry. The image will still store in the old repository with the new tag. Now your Azure Container Registry has one repository with two tags for the image.
    2. If you update the image with a new tag or still the old one and change the image name, then you push it to Azure Container Registry. It will create a new repository to store the image with the new name. Now you have two repositories, and each one has a tag for the image.

    Now, come back to your question:

    How can I know the number of images per repository?

    If you want to know the number of the images in the same repository, you just need to calculate the number of the tags.

    If you want to know the number of the image with different names, you need to calculate the number of repositories.

    There is no Azure command to get the number of the images directly, you need to do it yourself. For example, use Azure CLI in bash:

    az acr repository list -n yourACR | wc -l
    

    This command will show you a number, but it's not the real number of the repositories. You need to subtract 2. Hope it helps :-)