https://github.com/finoops/azure-sandbox-subscription-nightly-cleanup
Sandbox Cleanup automation for Azure subscriptions
https://github.com/finoops/azure-sandbox-subscription-nightly-cleanup
automation azure finops
Last synced: 5 months ago
JSON representation
Sandbox Cleanup automation for Azure subscriptions
- Host: GitHub
- URL: https://github.com/finoops/azure-sandbox-subscription-nightly-cleanup
- Owner: finoops
- Created: 2023-05-30T07:29:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-31T09:34:22.000Z (over 2 years ago)
- Last Synced: 2024-12-26T18:20:44.971Z (10 months ago)
- Topics: automation, azure, finops
- Language: Bicep
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Azure Subscription Nightly Cleanup Automation
It's encouraged that Azure "Sandbox" subscriptions are used for experimentation and learning. This can mean however that Sandboxes become the wild west, hosting a mess of orphaned resources and abandoned projects.
To keep sandbox subscriptions tidy and cost optimised, Azure Automation can be leveraged.
> This sample shows how to deploy on a per subscription basis.
## Creating automation
The Automation Account runs 3 runbooks daily.
It will flag resource groups for subsequent deletion, and clear the contents of other resource groups all based on a resource group tag.The tag that is evaluated is `Cleanup`.
- When set to `Automatically` then the resource group will be cleared each night. The use case here is that you'll want to keep a Resource Group because of the RBAC that has been assigned to it.
- When set to `Never` the resource group will be ignored. This tag should be used for any resource group that contains a resource you want to persist in your subscription. EG. The Cloudshell resource group.
- When there is no tag, a cleanup tag `PendingRGDelete` will be added on Day1, then on Day2 the entire resource group will be removed. The use case here is for quick deployments that you've forgotten about.```bash
az deployment sub create -u https://raw.githubusercontent.com/Gordonby/Snippets/master/AzureSubscriptionBootstrap/main.json -n SubscriptionMaintenance -l WestEurope
```