Skip to content

Commit

Permalink
chore: azure hack for delete from az image rg with stopped vms
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Riobo Lorenzo <[email protected]>
  • Loading branch information
adrianriobo committed Jun 5, 2024
1 parent 3b8bda4 commit 8294b1f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hacks/azure/azure_delete_rg_by_spot_stopped.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

az graph query -q "Resources
| where type == 'microsoft.compute/virtualmachines'
| where properties.extended.instanceView.powerState.code == 'PowerState/deallocated'
| project resourceGroup" > groups.json

jq -r 'recurse | scalars' groups.json > groups.list

# Define the file path
file="groups.list"

# Read the file line by line
while IFS= read -r line
do
echo "Processing resource group: $line"
# Perform operations, e.g., delete the resource group
az group delete --name $line --yes --no-wait
done < "$file"
File renamed without changes.

0 comments on commit 8294b1f

Please sign in to comment.