Need to check Azure Shared Image Gallery Usage

Shinde, Balaji 116 Reputation points
2021-06-28T12:36:40.95+00:00

Hi All,

We have a shared image gallery in Azure. We have many Linux and Windows images in it. We want to see if the images inside it are being used for creating VMs by the users or not. We want to do this to assess if its being used or not to decide future roadmap.

In Activity logs of the shared image gallery or the image definitions, the events are logged for updating image version, deleting image version etc.. But for creating VM, nothing is logged. I can see the deployment detail in the resource group in which VM is deployed, but we have 400+ subscriptions and it is not feasible to check each resource group.

Is it possible to check shared image gallery usage in any way?

Regards,
Balaji.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,017 questions
0 comments No comments
{count} votes

Accepted answer
  1. SRIJIT-BOSE-MSFT 4,346 Reputation points Microsoft Employee
    2021-06-29T13:53:12.537+00:00

    @Shinde, Balaji , Thank you for your question. We regret the delay in response and if it caused you any inconvenience.

    You can use tenant wide Azure Resource Graph : Overview of Azure Resource Graph - Azure Resource Graph | Microsoft Learn

    With Azure CLI you can use the following command:

    az graph query -q "Resources | where type in ('microsoft.compute/virtualmachinescalesets',  'microsoft.compute/virtualmachines')| project id, name, vmImageSourceID = coalesce(tostring(properties.virtualMachineProfile.storageProfile.imageReference.id), tostring(properties.storageProfile.imageReference.id))| where vmImageSourceID contains 'providers/Microsoft.Compute/galleries' | extend idx = indexof(vmImageSourceID, '/versions/', 1) | extend imageID = iff(idx>0, substring(vmImageSourceID, 0, idx), vmImageSourceID) | project id, name, imageID"  
    

    You can use that same query with Az PowerShell Module and the Azure Portal as well. The most important thing will always be the query itself.

    Example:

    110288-image.png

    You can specify all the subscriptions at the right hand side:

    110268-image.png

    Note: This will only be able to be seen under the same tenant and the user that is reviewing this needs to have visibility on such subscriptions.

    ----------

    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.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.