Know number of images in Azure Container Registry - azure

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

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:
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.
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 :-)

Related

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

I have two questions regarding ACR image pulling.
Is there a possibility to get the pull count of an ACR docker image?
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?
Is there a possibility to get the pull count of an ACR docker image?
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.

How can I find owner of Azure Container Registry Image

I am managing one Azure Container Registry which is having good amount of repository and image inside. Time-to-time I see some security issue with few images for which I need to reach out to image owner to fix it, but I don't know how to find owner of the image. Is there any way I can find owner of ACR Image or ACR repo at least?
Also, is there a way we can set image owner while pushing image from pipeline?
Cheers
Den
ACR does not record who owns an image.
The activity log records who pushed the image to the repository. Activity logs are kept for 90 days by default.
A strategy is to add labels to images when they are pushed.

Azure AppService continuous deployment from container registry tag selection

I have an AppService which uses Azure Container Registry.
The docker images are built by the pipeline and pushed with a 'Docker push' task in Azure Release.
I am using semantic versioning, I put the version into the BuildNumber and to the image name.
I can see my images being available in the DeploymentCenter, along with all the tags that have been pushed so far.
However, whenever I create a Release in AZ DevOps, it does not automatically get deployed to the AppService.
I have to go to the DeploymentCenter, pick the newest tag and then redeploy again (restarting the app didn't seem to work, but am no 100% sure).
In any case, I would like the AppService to be updated and run the latest image automatically when the release succeeds in DevOps.
Is that possible with the Docker push task to ACR?
Also, I wonder - I have the 'Include latest tag' tickbox checked, but the 'latest' tag is not available in the tag dropdown in Deployment Center. Why is that?
Is that possible with the Docker push task to ACR?
Of course, yes. But the thing you need to know is the continuous deployment of the App Service only triggers for the one tag can it can't change. Generally, we use the certain tag latest. So you need to create the image with the tag latest all the time, don't use the default tag $(Build.BuildId) in DevOps.
I have the 'Include latest tag' tickbox checked, but the 'latest' tag
is not available in the tag dropdown in Deployment Center. Why is
that?
I'm not familiar with DevOps, but I think the include latest tag means the latest Build.BuildId, not one certain tag, so it will change each time when you create the image and push it. And it won't work for App Service Continuous Deployment.

How can I update all images in azure container registry when base image is updated

I have a bunch of repositories in an Azure container registry. Each repository can have several versions of an image, tagged like this, imagename:v_1_0 or imagename:v_1_2. Almost all of these images uses the base image mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim.
My question is, how do I create an acr task that updates all of my images when that base image is updated by microsoft? I have seen tutorials on creating an acr task but almost all of them assume that the source code is pushed from github and that I am only updating a single image. I would like to avoid creating a task for n number of images in each repository but I suppose I could create a job that automatically creates a task whenever I publish from visual studio.
Has anyone else solved this problem?
So, if you are building your images via ACR tasks they do that automatically for the following base images:
The same Azure container registry where the task runs
Another private Azure container registry in the same or a different region
A public repo in Docker Hub
A public repo in Microsoft Container Registry
https://learn.microsoft.com/en-us/azure/container-registry/container-registry-tasks-base-images#base-image-notifications
if you are building them outside of ACR and pushing to ACR - you probably need to handle that in the same place you are building them. ACR cant do that for images its not building (seems fair).

Docker images version change do not trigger terraform container update

I'm using terraform to create container on Azure using azure_container_group. My container is based on a docker image stored on a private registry. When I update this image by pushing a new version with the latest tag my docker image have a new SHA256 ... but terraform seems not able to trigger this update.
Am i missing something ?
Thanks,
Dan
First of all, Azure Container Instance does not have the feature that automatically updates the images. So you need to update the images yourself manually. And Terraform is just a tool to create the Azure Container Instance, you can use it to create a trigger to update the images, but you cannot use Terraform itself to do it.
To automatically update the images, I recommend you use the Azure Container Registry, it provides the trigger on the commit to update the images. Take a look at Automate container image builds in the cloud when you commit source code.

Resources