This is a simple Python script that allows you to remove all useless containers from your Azure Storage Account
The script will list all the containers that start with a generic string and that have not been modified since a specific date. It will then ask you if you want to remove them.
The idea behind this is to remove tons of Bootdiagnostics containers that were generated by Azure VMs at every startup.
- Edit the following variables in the remove_old_blobs.py file:
CONTAINER_NAME_STARTS_WITH
: The beggining of the name of your containers to mass-remove (e.g. "bootdiagnostics-")LAST_EDIT_DATE
: The most recent edit date of the containers you wish to remove (e.g. "2024-31-01")
- Set the BLOB_CONNECTION_STRING environment variable
The Connection String starts with "DefaultEndpointsProtocol=https......" It can be found in the Azure Portal under the Access keys section of your Azure Storage Account
echo "Enter your Connection String then press Enter..." && read -s secret && export BLOB_CONNECTION_STRING=$secret
- Install the required packages:
pip install requirements.txt
- Run the script:
python remove_old_blobs.py
- Enter "yes" to remove the containers that are listed in the console and on the "output.txt" file.
If you fork this repo, please make sure to remove the Connection String variable as it can be used maliciously.