Extract information from Azure

Angelo Bertolotti 21 Reputation points
2021-02-24T13:51:35.52+00:00

Good morning I would need to extract the following information from an Azure subscription. A table where the following information is associated for each VM: - VM name - VM SKU - SKU OS DISK (with related IOPS and throughput) - SKU Data DISK (same information) It would also be appreciated to be able to extract: - CPU USAGE - DISK USAGE I am also looking for an official Microsoft table with the list of all the VM SKUs and the list of all the disk SKUs, with related information. Thanks for your help

Azure Cloud Services
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
695 questions
{count} votes

Accepted answer
  1. shiva patpi 13,251 Reputation points Microsoft Employee
    2021-04-14T06:01:58.467+00:00

    Hello @Angelo Bertolotti ,
    Apologies for the delay , here is the edited script to extract the information into a CSV file

    $AllVMs = Get-AzureRMVM
    Write-Host "VMName,VMSKU,OSDiskName,OSDiskIOPS,OSDiskSize,OSDiskThroughPut,DataDiskName,DataDiskSize" -ForegroundColor "Cyan"
    foreach($vm in $AllVMs)
    {

    $VMDetails = Get-AzureRMVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName
    $OsDisk = Get-AzureRmDisk -ResourceGroupName $vm.ResourceGroupName -DiskName $VMDetails.StorageProfile.OsDisk.Name
    $datadisk = $VMDetails.StorageProfile.DataDisks
    $details = $VMDetails.Name +","+ $VMDetails.HardwareProfile.VmSize+","+ $VMDetails.StorageProfile.OsDisk.Name+","+ $OsDisk.DiskIOPSReadWrite+","+$OsDisk.DiskSizeGB +","+$OsDisk.DiskMBpsReadWrite+"," + $datadisk.Name+","+$datadisk.DiskSizeGB
    $details >> "output.csv"

    }

    Let us know if you have additional questions , if the above information helps out kindly make sure to "Upvote and accept the answer"

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. shiva patpi 13,251 Reputation points Microsoft Employee
    2021-02-25T00:12:06.11+00:00

    Hello @Angelo Bertolotti ,
    Thanks for your query . Below is the requested information.

    Sample Script to get VM and Disk details:

    $AllVMs = Get-AzureRMVM //get all the VMs
    Write-Host "VMName,VMSKU,OSDiskName,OSDiskIOPS,OSDiskSize,OSDiskThroughPut,DataDiskName,DataDiskSize" -ForegroundColor "Cyan"
    foreach($vm in $AllVMs) //loop through each VM
    {

    $VMDetails = Get-AzureRMVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName //get particular VM instance details
    $OsDisk = Get-AzureRmDisk -ResourceGroupName $vm.ResourceGroupName -DiskName $VMDetails.StorageProfile.OsDisk.Name //get os disk details reference
    $datadisk = $VMDetails.StorageProfile.DataDisks //get data disks collection list
    //please note if there are multiple data disks you might have to loop through that enumeration list
    $details = $VMDetails.Name +","+ $VMDetails.HardwareProfile.VmSize+","+ $VMDetails.StorageProfile.OsDisk.Name+","+ $OsDisk.DiskIOPSReadWrite+","+$OsDisk.DiskSizeGB +","+$OsDisk.DiskMBpsReadWrite+"," + $datadisk.Name+","+$datadisk.DiskSizeGB

    Write-Host $details //print results
    }

    To extract the CPU metrics data you can use the sample script mentioned in below article

    As of now disk utilization details can't be extracted

    Below article provides the details w.r.t all available compute skus categorized by type

    Below document provides the details w.r.t disks

    Managed disk detailed information w.r.t pricing , performance

    If the above information helps you out , please make sure to "Accept the answer" and Upvote

    1 person found this answer helpful.

  2. Angelo Bertolotti 21 Reputation points
    2021-04-16T12:09:18.027+00:00

    thank you very much it works answer accepted

    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.