To delete mulitple resource group use the below script
#!/bin/bash
# Define the names of the resource groups to delete
resource_groups=("mg-baker" "mg-css" "mg-atos" "mg-nsgiht")
# Iterate through each resource group name and delete it if it exists
for rg in "${resource_groups[@]}"
do
echo "Checking if resource group $rg exists..."
if az group exists --name $rg
then
echo "Deleting resource group: $rg"
az group delete --name $rg --yes --no-wait --verbose
else
echo "Resource group $rg does not exist."
fi
done
To Create a resource group in Azure using shell script:
#!/bin/bash
# Define the resource group name and location
resource_group_name="myResourceGroup"
location="westus2"
# Create the resource group
az group create --name $resource_group_name --location $location
0 Comments