Is there any function by which I can get details of Data disks attached to the VM like Disk Size,Space allocated/Remaining disk space ?

Tajman Kaur 0 Reputation points
2025-01-14T09:53:25+00:00

I am trying to get the details for Data Disk attached to the particular VM. The Main purpose is to get notified when the disk space is highly utilized.

I can get the names of Data disks attached to the VM , but not getting the details like Disk Size,Space allocated/Remaining disk space etc.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,356 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,286 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,609 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,762 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shikha Ghildiyal 3,255 Reputation points Microsoft Employee
    2025-01-14T10:27:47.8366667+00:00

    Hi Tajman Kaur

    Thanks for reaching out to Microsoft Q&A.

    You can first enable VM insights and send logs to Log analytics workspace

    https://learn.microsoft.com/en-us/azure/azure-monitor/vm/vminsights-enable?tabs=portal

    Monitor your performance metrics as per guidelines here - https://learn.microsoft.com/en-us/azure/azure-monitor/vm/vminsights-performance

    And then you can create alerts - https://learn.microsoft.com/en-us/azure/azure-monitor/vm/monitor-virtual-machine-alerts

    Example- Available memory in percentage

    KustoCopy

    InsightsMetrics
    | where Origin == "vm.azm.ms"
    | where Namespace == "Memory" and Name == "AvailableMB"
    | extend TotalMemory = toreal(todynamic(Tags)["vm.azm.ms/memorySizeMB"]) | extend AvailableMemoryPercentage = (toreal(Val) / TotalMemory) * 100.0
    | summarize AvailableMemoryInPercentageAverage = avg(AvailableMemoryPercentage) by bin(TimeGenerated, 
    

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    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.