anonymous user Welcome to Microsoft Q&A, Thank you for posting your query!
- Firstly, you may check usage capacity and transaction of the Storage account through Azure Monitor based on the subscription which provided the details which hasn't been used from when and how much data does it holds : Navigate to Azure portal -> Monitor -> Storage accounts: Then select your subscription; For storage accounts, select "All" -> At last, click "Capacity"(You can also select the time range). The screenshot as below:
Note: You should calculate the total space used one by one, there is no such built-in feature. Or you can write a code calculate total space used one by one.
- 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.
Set current context to subscription
Set-AzContext -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"Go through every storage account in your subscription
foreach ($storageAccount in Get-AzStorageAccount) {
$storageAccountName = $storageAccount.StorageAccountName
$resourceGroupName = $storageAccount.ResourceGroupName
}# Get key1 storage account key $storageAccountKey = (Get-AzStorageAccountKey -Name $storageAccountName -ResourceGroupName $resourceGroupName).Value[0] # Create storage account context using above key $context = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey # Get the most recently accessed container by sorting by LastModified and picking the last object $lastModified = Get-AzStorageContainer -Context $context | Sort-Object -Property @{Expression = {$_.LastModified.DateTime}} | Select-Object -Last 1 -ExpandProperty LastModified # Remove storage account if it is older than 90 days if ($lastModified.DateTime -lt (Get-Date).AddDays(-90)) { Remove-AzStorageAccount -Name $storageAccountName -ResourceGroupName $resourceGroupName -Force -WhatIf }
- You can also check in Azure Metrics for more detailed information based on the region:
If you still find any issues, please let us know we would like to work closer on this issue.
Hope this helps!
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.