Created
July 21, 2021 19:14
-
-
Save Piotr1215/0ded87c51d52e8b3b4e15862c4acde27 to your computer and use it in GitHub Desktop.
Create or Delete Azure Resource Group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Setup variables | |
group='rg-unique-name' | |
location='rg-location' | |
groupExists=$(az group exists -n $group) | |
if $groupExists; then | |
echo 'Group' $group 'already exists' | |
else | |
az group create --name $group --location $location --output json | |
echo 'Resource group' $group 'created.' | |
fi | |
delete=${1:-false} | |
if $delete; then | |
groupExists=$(az group exists -n $group) | |
if $groupExists; then | |
az group delete --name $group --yes | |
echo 'Resource group' $group 'destroyed' | |
else | |
echo 'Group' $group 'not found' | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment