skip to Main Content

I am working to delete the unused azure resources which are not used since last 3 months to save the cost.
I tried to find in internet but not getting the proper answer.

Is any one know how to get the list though powershell or can export the details from the azure portal?

2

Answers


  1. "Unused" means a lot of different things when you look at different resource types. Maybe you are looking for VMs which are deallocated? Or for a SQL DB which had zero per cent CPU util? Or….

    So, there is no general way to determine this through the ARM APIs.

    Login or Signup to reply.
  2. or can export the details from the azure portal?

    Yes, you can get the status of Vms as it is deallocated or not by using Azure resource graph as below and i followed SO-thread as below:

    Resources
            | project name, location,     PowerState=tostring(properties.extended.instanceView.powerState.code),
            type
            | where type =~ 'Microsoft.Compute/virtualMachines'
            | order  by name desc
    

    enter image description here

    As you asked that you want Vms if its not used in 3 months by using Azure log Analytics Worksapce query and followed M-QandA as below:

    AzureActivity
     |  where  TimeGenerated  >= ago(90d)
    |  where  _ResourceId contains "Microsoft.Compute/disks"  or  _ResourceId contains "Microsoft.Compute/virtualMachines"
    | distinct _ResourceId
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search