There is nothing built in, you would need to create a script using something like Azure automation to do this for you.
Scheduled Sandbox Cleanup in Azure.
Hey, is there a way to cleanup/delete all resources in the Sandbox subscription automatically, on a weekly basis?
Best regards
3 answers
Sort by: Most helpful
-
-
Nico Marino 31 Reputation points
2022-12-07T14:15:10.46+00:00 I think the following thread:
https://learn.microsoft.com/en-us/answers/questions/1014725/how-to-schedule-a-powershell-script-to-run-automat.html?sort=oldest
can be helpful!Take a look at the following one:
https://build5nines.com/azure-cli-delete-all-resources-within-resource-group/
as well. -
Luke Murray 11,241 Reputation points MVP
2022-12-08T02:27:04.247+00:00 You would need to setup an Azure Automation runbook, on a schedule to delete your resources,.
Jack Tracey - has published a script: https://github.com/jtracey93/PublicScripts/tree/master/Azure/PowerShell/Enterprise-scale
This script will remove everything under a management group and everything in the subscriptions, it can also remove SPNs and reset Cloud for Defender pricing back to Free.
Its a nuclear option - but very useful in sandbox environments.
THIS SCRIPT WILL REMOVE EVERYTHING IN A MANAGEMENT GROUP - so please be careful - and TEST it in a non-production environment.