Simple but powerful script with AZ CLI to clean all resources from subscription, include disable subscriptions as well
At begining, I thought it would be a simple task because Azure manages resource via Resource Group. But that's not that simple.
- clean all resource groups - with
--no-wait
, you don't wait for the long-running operation to finish. - clean all blueprint assignments
- clean all deleted key vault - Yes, the key are still there when soft delete is enabled, until you purge it. Otherwise, you will face the error, such as ,
key with same name is exist
. - clean resources from disabled subscription as well, fix the error
the subscription name has more than one match
Make sure you have set the proper subscription
$ az account set -s <sub_id or sub_name>
$ az account show
When you are ready, just run below command
$ ./sub_cleaner.sh