I've reached the hard cap of 250 storage accounts for my subscription. Storage accounts were created using ARM
I need a way to find unused storage accounts and delete them. Basically I want to find storage accounts with containers that have not been accessed in 90 days to and do a clean up.
Is there a way to check last accessed time or a better way to clean up using PowerShell or preferably the azure cli
Thanks
What you could do is get the most recent modified container from the
LastModified
property, then check if this timestamp is less than the current date minus 90 days. We would need to check both the container level and blob level LastModified properties.Since this action could be extremely harmful, you can run
Remove-AzStorageAccount
with-WhatIf
to see what storage accounts will be deleted before deleting them for real.