I would like to run some custom cleanup script in powershell or Az CLI to cleanup some resources that get created in a resource group but do not get cleaned up automatically when the resource group is deleted.
I can run a custom script manually and then delete the resource group, but I was wondering if there was a way to have it setup so a script is called automatically when the resource group is deleted from the Portal from example.
CodePudding user response:
Have a look at Azure Automation:
Azure Automation delivers a cloud-based automation and configuration service that supports consistent management across your Azure and non-Azure environments. It comprises process automation, configuration management, update management, shared capabilities, and heterogeneous features. Automation gives you complete control during deployment, operations, and decommissioning of workloads and resources.
You can use an Event Grid event as the trigger to run your automation runbook.