How to check cost of unused disk in Azure

vadiraj desai 0 Reputation points
2024-01-10T04:52:43.45+00:00

Hi All,

I have a list of Unattached disks which are in different subscriptions and resource groups. So is there a way to get all these disks cost usage when they are unattached now?

I checked in the Azure advisory recommendation which is not showing the exact amount.

Thanks in advance.

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

2 answers

Sort by: Most helpful
  1. Sedat SALMAN 13,265 Reputation points
    2024-01-10T07:19:45.61+00:00

    you can write a script similar to below to calculate it

    Connect-AzAccount
    
    $subscriptions = Get-AzSubscription
    
    foreach ($subscription in $subscriptions) {
    
        Set-AzContext -SubscriptionId $subscription.Id
    
        $unattachedDisks = Get-AzDisk | Where-Object { -not $_.ManagedBy }
    
        foreach ($disk in $unattachedDisks) {
        
            $costPerGB = 0.05 # you need to find an average cost of disk per GB from Azure Pricing Calculator
            $cost = $disk.DiskSizeGB * $costPerGB
    
            Write-Output "Resource Group: $($disk.ResourceGroupName)"
            Write-Output "Disk Name: $($disk.Name)"
            Write-Output "Disk Size (GB): $($disk.DiskSizeGB)"
            Write-Output "Estimated Monthly Cost: `$$cost"
            Write-Output "--------------------------------------"
        }
    }
    
    Disconnect-AzAccount
    
    
    0 comments No comments

  2. Anand Prakash Yadav 7,775 Reputation points Microsoft Vendor
    2024-01-11T12:23:15.57+00:00

    Hello vadiraj desai,

    Thank you for posting your query here!

    You may refer to Azure Pricing Calculator to have a rough estimation: https://azure.microsoft.com/en-au/pricing/calculator/

    However, based on your scenario I would recommend contacting Azure Billing and Subscription team. They are best equipped to offer comprehensive insights and guidance on which Azure service consumes more resources and when this consumption occurs. You can expect to receive detailed information and one-on-one support when you engage with them. https://azure.microsoft.com/en-us/support/options/
    It's a free support and the best option for you.

    To find and delete unattached disk in Azure, we can refer: https://video2.skills-academy.com/en-us/azure/virtual-machines/disks-find-unattached-portal

    Kindly let us know if you have any further queries. I’m happy to assist you further.

    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.