-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathpublic_ip_delete.yml
36 lines (35 loc) · 1.68 KB
/
public_ip_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
35
36
# 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
for x in "-vmss" "-vfxt" "-filer" "-storage" "-proxy" "-network"; do
exists=$(az group exists --name ${RESOURCE_GROUP_NAME}$x)
_ipcfgs_file=/tmp/ipcfgs.lst
if [ "${exists}" = "true" ]; then
echo "${RESOURCE_GROUP_NAME}$x exists - checking for public IPs"
az network public-ip list \
--resource-group ${RESOURCE_GROUP_NAME}$x \
--output tsv --query '[].ipConfiguration.id' |& tee ${_ipcfgs_file}
check_rc.sh ${PIPESTATUS[0]} "List IP configs with a public IP address" || exit 0
az network nic ip-config update \
--public-ip-address "" \
--ids @- < ${_ipcfgs_file}
check_rc.sh ${PIPESTATUS[0]} "Disassociate public IP addresses from all IP configs" || exit 0
_pubips_file=/tmp/pubips.lst
az network public-ip list \
--resource-group ${RESOURCE_GROUP_NAME}$x \
--output tsv --query '[].id' |& tee ${_pubips_file}
check_rc.sh ${PIPESTATUS[0]} "List all public IP address resources" || exit 0
az network public-ip delete --ids @- < ${_pubips_file}
check_rc.sh ${PIPESTATUS[0]} "Delete all public IP address resources" || exit 0
fi
done
displayName: 'Public IP Delete'
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)