-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathrg_delete.yml
34 lines (33 loc) · 1.37 KB
/
rg_delete.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright (C) Microsoft Corporation. All rights reserved.
# https://aka.ms/yaml
steps:
- bash: |
export PATH=$PATH:${BUILD_SOURCESDIRECTORY}/test/utils
az login --service-principal -u $ARM_CLIENT_ID -p $ARM_CLIENT_SECRET --tenant $ARM_TENANT_ID
check_rc.sh $? "Az login" || exit 0
for x in "-vmss" "-vfxt" "-filer" "-storage" "-proxy" "-network"; do
rg_del_rc=111111
exists=$(az group exists --name ${RESOURCE_GROUP_NAME}$x)
if [ "${exists}" = "true" ]; then
echo "${RESOURCE_GROUP_NAME}$x exists"
for i in {1..3}; do
az group delete --yes --name ${RESOURCE_GROUP_NAME}$x --subscription ${ARM_SUBSCRIPTION_ID}
rg_del_rc=$?
if [ "${rg_del_rc}" -ne 0 ]; then
echo "##vso[task.logissue type=error;]Deleting resource group ${RESOURCE_GROUP_NAME}$x failed. Attempt $i of 3."
echo "##vso[task.complete result=Failed;]"
else
break
fi
done
fi
done
# Final delete is for the Resource group that has the VM runner in it.
az group delete --yes --name ${RESOURCE_GROUP_NAME} --subscription ${ARM_SUBSCRIPTION_ID}
displayName: 'RG Delete Check'
condition: always()
env:
ARM_CLIENT_ID: $(AZURE-CLIENT-ID)
ARM_CLIENT_SECRET: $(AZURE-CLIENT-SECRET)
ARM_TENANT_ID: $(AZURE-TENANT-ID)
ARM_SUBSCRIPTION_ID: $(AZURE-SUBSCRIPTION-ID)