Kusto Query to get Report on Orphaned Azure VM Disks and when they became unattached.

Maurice Ojow 0 Reputation points
2023-06-21T19:49:42.36+00:00

I am looking at getting reports on Azure Orphaned Disks. Right now I can pull the reports, but I would like to include the date the disks became unattached or how long the disks have been unattached. I am pulling this for all our subscriptions using Azure Resource Graph Explorer. How can I capture that date component? So far, this is the query I am running:

Resources

| where type has "microsoft.compute/disks"

| extend diskState = tostring(properties.diskState)

| where managedBy == ""

or diskState == 'Unattached' and  diskState != 'ActiveSAS'

| project id, diskState, resourceGroup, location, subscriptionId

Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
668 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Luke Murray 11,436 Reputation points MVP Volunteer Moderator
    2023-06-22T08:27:13.2033333+00:00

    Hi, Maurice

    Unfortunately, this metadata is not kept on the managed disks; you could have an Azure Activity Log that triggers an email notification if the disk becomes unattached or have a runbook that alerts on any disks that are unattached each week, to help give you a timeframe.

    Heres another question that could be helpful to point you in the right direction: https://learn.microsoft.com/en-us/answers/questions/423773/how-to-find-disks-that-are-not-attached-used-more


  2. Maurice Ojow 0 Reputation points
    2023-06-27T22:58:54.92+00:00

    I went with a third party tool, Cloudhealth (https://cloudhealth.vmware.com/)

    0 comments No comments

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.