Generate disk usage percentage report for all VMS

mohammadSayed-1052 1 Reputation point
2023-09-24T19:13:03.43+00:00

Hello All,

I am trying to generate disk usage percentage report from Azure portal then export to csv for all vms I have,

I tried Insight - metrics but it does not show used disk space percentage if I filter with all vms, moreover , I can't export any report to csv

using IAAS

your support is highly appreciated

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,157 questions
Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
572 questions
{count} votes

1 answer

Sort by: Most helpful
  1. WAMBI YVETTE NERIMA 0 Reputation points
    2023-09-24T21:16:31.4933333+00:00

    Hello, can you try this in PowerShell

    Here's an example using Azure PowerShell:

    $vmName = "YourVMName"
    $resourceGroupName = "YourResourceGroupName"
    $metrics = Get-AzMetric -ResourceId "/subscriptions/your-subscription-id/resourceGroups/$resourceGroupName/providers/Microsoft.Compute/virtualMachines/$vmName" -MetricName "Percentage Disk Space Used" -TimeAggregation Total -DetailedOutput
    

    Replace "YourVMName", "YourResourceGroupName", and "your-subscription-id" with your VM's name, resource group name, and subscription ID.

    Export to CSV: You can then export the metrics data to a CSV file for further analysis using PowerShell:

    $metrics | Export-Csv -Path "DiskUsageReport.csv" -NoTypeInformation