Avere/templates/rg_delete.yml

35 строки
1.4 KiB
YAML

# 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)