question

RavindraShukla-2370 avatar image
0 Votes"
RavindraShukla-2370 asked learn2skills edited

How to check images in ACR are in use or not

Hello,

I am using Azure ACR as storage for my container images. Some of my images are vulnerable, so I want to check whether those images are in use by any other resource(like pipeline, deployment, container or any other application) before deleting it.

Is it possible to identify whether the image in ACR is in use by any other resource in Azure?

Please suggest.

azure-container-registry
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

To follow-up, Please let us know if you have further query on this.
Please don’t forget to Accept the answer

0 Votes 0 ·
learn2skills avatar image
0 Votes"
learn2skills answered

Hi @RavindraShukla-2370

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.



If the Answer is helpful, please click Accept Answer and up-vote, so that it can help others in the community looking for help on similar topics.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RavindraShukla-2370 avatar image
0 Votes"
RavindraShukla-2370 answered

Hi @learn2skills Thanks for your reply.

I would also like to know whether there is any Azure CLI command to get the information about all the vulnerable images from Azure.

I don't want to have it from UI, instead I want to get it using CLI.

Please let me know if there is any option.

Thanks

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

learn2skills avatar image
0 Votes"
learn2skills answered learn2skills edited

@RavindraShukla-2370

You can try the below Azure CLI command.

 az graph query -q "SecurityResources | where type == 'microsoft.security/assessments' | where properties.displayName contains 'Container registry images should have vulnerability findings resolved' | summarize by assessmentKey=name //the ID of the assessment | join kind=inner ( securityresources | where type == 'microsoft.security/assessments/subassessments' | extend assessmentKey = extract('.*assessments/(.+?)/.*',1, id) ) on assessmentKey | project assessmentKey, subassessmentKey=name, id, parse_json(properties), resourceGroup, subscriptionId, tenantId | extend description = properties.description, displayName = properties.displayName, resourceId = properties.resourceDetails.id, resourceSource = properties.resourceDetails.source, category = properties.category, severity = properties.status.severity, code = properties.status.code, timeGenerated = properties.timeGenerated, remediation = properties.remediation, impact = properties.impact, vulnId = properties.id, additionalData = properties.additionalData"


refer- https://docs.microsoft.com/en-us/azure/container-registry/resource-graph-samples?tabs=azure-cli#code-try-1



If this answers your query, do click Accept Answer and Up-Vote for the same. And, if you have any further query do let us know.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.