Skip to content

Commit ea77b67

Browse files
author
sivakami
committed
Verify each resource creation - long running cluster test pipeline.
1 parent 4eee951 commit ea77b67

File tree

5 files changed

+176
-37
lines changed

5 files changed

+176
-37
lines changed

.pipelines/swiftv2-long-running/scripts/create_nsg.sh

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,52 @@ SUBNET1_PREFIX="10.10.1.0/24"
1111
SUBNET2_PREFIX="10.10.2.0/24"
1212
NSG_NAME="${VNET_A1}-nsg"
1313

14+
verify_nsg() {
15+
local rg="$1"; local name="$2"
16+
echo "==> Verifying NSG: $name"
17+
if az network nsg show -g "$rg" -n "$name" &>/dev/null; then
18+
echo "[OK] Verified NSG $name exists."
19+
else
20+
echo "[ERROR] NSG $name not found!" >&2
21+
exit 1
22+
fi
23+
}
24+
25+
verify_nsg_rule() {
26+
local rg="$1"; local nsg="$2"; local rule="$3"
27+
echo "==> Verifying NSG rule: $rule in $nsg"
28+
if az network nsg rule show -g "$rg" --nsg-name "$nsg" -n "$rule" &>/dev/null; then
29+
echo "[OK] Verified NSG rule $rule exists in $nsg."
30+
else
31+
echo "[ERROR] NSG rule $rule not found in $nsg!" >&2
32+
exit 1
33+
fi
34+
}
35+
36+
verify_subnet_nsg_association() {
37+
local rg="$1"; local vnet="$2"; local subnet="$3"; local nsg="$4"
38+
echo "==> Verifying NSG association on subnet $subnet..."
39+
local associated_nsg
40+
associated_nsg=$(az network vnet subnet show -g "$rg" --vnet-name "$vnet" -n "$subnet" --query "networkSecurityGroup.id" -o tsv 2>/dev/null || echo "")
41+
if [[ "$associated_nsg" == *"$nsg"* ]]; then
42+
echo "[OK] Verified subnet $subnet is associated with NSG $nsg."
43+
else
44+
echo "[ERROR] Subnet $subnet is NOT associated with NSG $nsg!" >&2
45+
exit 1
46+
fi
47+
}
48+
49+
# -------------------------------
50+
# 1. Create NSG
51+
# -------------------------------
1452
echo "==> Creating Network Security Group: $NSG_NAME"
1553
az network nsg create -g "$RG" -n "$NSG_NAME" -l "$LOCATION" --output none \
1654
&& echo "[OK] NSG '$NSG_NAME' created."
55+
verify_nsg "$RG" "$NSG_NAME"
1756

57+
# -------------------------------
58+
# 2. Create NSG Rules
59+
# -------------------------------
1860
echo "==> Creating NSG rule to DENY traffic from Subnet1 ($SUBNET1_PREFIX) to Subnet2 ($SUBNET2_PREFIX)"
1961
az network nsg rule create \
2062
--resource-group "$RG" \
@@ -30,6 +72,8 @@ az network nsg rule create \
3072
--output none \
3173
&& echo "[OK] Deny rule from Subnet1 → Subnet2 created."
3274

75+
verify_nsg_rule "$RG" "$NSG_NAME" "deny-subnet1-to-subnet2"
76+
3377
echo "==> Creating NSG rule to DENY traffic from Subnet2 ($SUBNET2_PREFIX) to Subnet1 ($SUBNET1_PREFIX)"
3478
az network nsg rule create \
3579
--resource-group "$RG" \
@@ -45,19 +89,21 @@ az network nsg rule create \
4589
--output none \
4690
&& echo "[OK] Deny rule from Subnet2 → Subnet1 created."
4791

48-
az network vnet subnet update \
49-
--name s1 \
50-
--vnet-name "$VNET_A1" \
51-
--resource-group "$RG" \
52-
--network-security-group "$NSG_NAME" \
53-
--output none
92+
verify_nsg_rule "$RG" "$NSG_NAME" "deny-subnet2-to-subnet1"
5493

55-
az network vnet subnet update \
56-
--name s2 \
57-
--vnet-name "$VNET_A1" \
58-
--resource-group "$RG" \
59-
--network-security-group "$NSG_NAME" \
60-
--output none
94+
# -------------------------------
95+
# 3. Associate NSG with Subnets
96+
# -------------------------------
97+
for SUBNET in s1 s2; do
98+
echo "==> Associating NSG $NSG_NAME with subnet $SUBNET"
99+
az network vnet subnet update \
100+
--name "$SUBNET" \
101+
--vnet-name "$VNET_A1" \
102+
--resource-group "$RG" \
103+
--network-security-group "$NSG_NAME" \
104+
--output none
105+
verify_subnet_nsg_association "$RG" "$VNET_A1" "$SUBNET" "$NSG_NAME"
106+
done
61107

62108
echo "NSG '$NSG_NAME' created successfully with bidirectional isolation between Subnet1 and Subnet2."
63109

.pipelines/swiftv2-long-running/scripts/create_pe.sh

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,62 @@ SUBNET_PE_A1="pe"
1414
PE_NAME="${SA1_NAME}-pe"
1515
PRIVATE_DNS_ZONE="privatelink.blob.core.windows.net"
1616

17+
# -------------------------------
18+
# Function: Verify Resource Exists
19+
# -------------------------------
20+
verify_dns_zone() {
21+
local rg="$1"; local zone="$2"
22+
echo "==> Verifying Private DNS zone: $zone"
23+
if az network private-dns zone show -g "$rg" -n "$zone" &>/dev/null; then
24+
echo "[OK] Verified DNS zone $zone exists."
25+
else
26+
echo "[ERROR] DNS zone $zone not found!" >&2
27+
exit 1
28+
fi
29+
}
30+
31+
verify_dns_link() {
32+
local rg="$1"; local zone="$2"; local link="$3"
33+
echo "==> Verifying DNS link: $link for zone $zone"
34+
if az network private-dns link vnet show -g "$rg" --zone-name "$zone" -n "$link" &>/dev/null; then
35+
echo "[OK] Verified DNS link $link exists."
36+
else
37+
echo "[ERROR] DNS link $link not found!" >&2
38+
exit 1
39+
fi
40+
}
41+
42+
verify_private_endpoint() {
43+
local rg="$1"; local name="$2"
44+
echo "==> Verifying Private Endpoint: $name"
45+
if az network private-endpoint show -g "$rg" -n "$name" &>/dev/null; then
46+
echo "[OK] Verified Private Endpoint $name exists."
47+
else
48+
echo "[ERROR] Private Endpoint $name not found!" >&2
49+
exit 1
50+
fi
51+
}
52+
1753
# 1. Create Private DNS zone
1854
echo "==> Creating Private DNS zone: $PRIVATE_DNS_ZONE"
1955
az network private-dns zone create -g "$RG" -n "$PRIVATE_DNS_ZONE" --output none \
2056
&& echo "[OK] DNS zone $PRIVATE_DNS_ZONE created."
2157

22-
# 2. Link DNS zone to VNet
23-
echo "==> Linking DNS zone $PRIVATE_DNS_ZONE to VNet $VNET_A1"
24-
az network private-dns link vnet create \
25-
-g "$RG" -n "${VNET_A1}-link" \
26-
--zone-name "$PRIVATE_DNS_ZONE" \
27-
--virtual-network "$VNET_A1" \
28-
--registration-enabled false \
29-
&& echo "[OK] Linked DNS zone to $VNET_A1."
30-
31-
az network private-dns link vnet create \
32-
-g "$RG" -n "${VNET_A2}-link" \
33-
--zone-name "$PRIVATE_DNS_ZONE" \
34-
--virtual-network "$VNET_A2" \
35-
--registration-enabled false \
36-
&& echo "[OK] Linked DNS zone to $VNET_A2."
37-
38-
az network private-dns link vnet create \
39-
-g "$RG" -n "${VNET_A3}-link" \
40-
--zone-name "$PRIVATE_DNS_ZONE" \
41-
--virtual-network "$VNET_A3" \
42-
--registration-enabled false \
43-
&& echo "[OK] Linked DNS zone to $VNET_A3."
58+
verify_dns_zone "$RG" "$PRIVATE_DNS_ZONE"
4459

60+
# 2. Link DNS zone to VNet
61+
for VNET in "$VNET_A1" "$VNET_A2" "$VNET_A3"; do
62+
LINK_NAME="${VNET}-link"
63+
echo "==> Linking DNS zone $PRIVATE_DNS_ZONE to VNet $VNET"
64+
az network private-dns link vnet create \
65+
-g "$RG" -n "$LINK_NAME" \
66+
--zone-name "$PRIVATE_DNS_ZONE" \
67+
--virtual-network "$VNET" \
68+
--registration-enabled false \
69+
--output none \
70+
&& echo "[OK] Linked DNS zone to $VNET."
71+
verify_dns_link "$RG" "$PRIVATE_DNS_ZONE" "$LINK_NAME"
72+
done
4573

4674
# 3. Create Private Endpoint
4775
echo "==> Creating Private Endpoint for Storage Account: $SA1_NAME"
@@ -54,3 +82,6 @@ az network private-endpoint create \
5482
--connection-name "${PE_NAME}-conn" \
5583
--output none \
5684
&& echo "[OK] Private Endpoint $PE_NAME created for $SA1_NAME."
85+
verify_private_endpoint "$RG" "$PE_NAME"
86+
87+
echo "All Private DNS and Endpoint resources created and verified successfully."

.pipelines/swiftv2-long-running/scripts/create_peerings.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,31 @@ VNET_A2="cx_vnet_a2"
88
VNET_A3="cx_vnet_a3"
99
VNET_B1="cx_vnet_b1"
1010

11+
verify_peering() {
12+
local rg="$1"; local vnet="$2"; local peering="$3"
13+
echo "==> Verifying peering $peering on $vnet..."
14+
if az network vnet peering show -g "$rg" --vnet-name "$vnet" -n "$peering" --query "peeringState" -o tsv | grep -q "Connected"; then
15+
echo "[OK] Peering $peering on $vnet is Connected."
16+
else
17+
echo "[ERROR] Peering $peering on $vnet not found or not Connected!" >&2
18+
exit 1
19+
fi
20+
}
21+
1122
peer_two_vnets() {
1223
local rg="$1"; local v1="$2"; local v2="$3"; local name12="$4"; local name21="$5"
1324
echo "==> Peering $v1 <-> $v2"
1425
az network vnet peering create -g "$rg" -n "$name12" --vnet-name "$v1" --remote-vnet "$v2" --allow-vnet-access --output none \
1526
&& echo "Created peering $name12"
1627
az network vnet peering create -g "$rg" -n "$name21" --vnet-name "$v2" --remote-vnet "$v1" --allow-vnet-access --output none \
1728
&& echo "Created peering $name21"
29+
30+
# Verify both peerings are active
31+
verify_peering "$rg" "$v1" "$name12"
32+
verify_peering "$rg" "$v2" "$name21"
1833
}
1934

2035
peer_two_vnets "$RG" "$VNET_A1" "$VNET_A2" "A1-to-A2" "A2-to-A1"
2136
peer_two_vnets "$RG" "$VNET_A2" "$VNET_A3" "A2-to-A3" "A3-to-A2"
2237
peer_two_vnets "$RG" "$VNET_A1" "$VNET_A3" "A1-to-A3" "A3-to-A1"
23-
echo "VNet peerings created successfully."
38+
echo "All VNet peerings created and verified successfully."

.pipelines/swiftv2-long-running/scripts/create_storage.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,17 @@ for SA in "$SA1" "$SA2"; do
3030
&& echo "Storage account $SA created successfully."
3131
done
3232

33-
echo "All storage accounts created successfully."
33+
# Verify creation success
34+
echo "==> Verifying storage account $SA exists..."
35+
if az storage account show --name "$SA" --resource-group "$RG" &>/dev/null; then
36+
echo "[OK] Storage account $SA verified successfully."
37+
else
38+
echo "[ERROR] Storage account $SA not found after creation!" >&2
39+
exit 1
40+
fi
41+
done
42+
43+
echo "All storage accounts created and verified successfully."
3444

3545
# Set pipeline output variables
3646
set +x

.pipelines/swiftv2-long-running/scripts/create_vnets.sh

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,61 @@ A3_MAIN="10.12.1.0/24"
2424

2525
B1_MAIN="10.20.1.0/24"
2626

27+
# -------------------------------
28+
# Verification functions
29+
# -------------------------------
30+
verify_vnet() {
31+
local rg="$1"; local vnet="$2"
32+
echo "==> Verifying VNet: $vnet"
33+
if az network vnet show -g "$rg" -n "$vnet" &>/dev/null; then
34+
echo "[OK] Verified VNet $vnet exists."
35+
else
36+
echo "[ERROR] VNet $vnet not found!" >&2
37+
exit 1
38+
fi
39+
}
40+
41+
verify_subnet() {
42+
local rg="$1"; local vnet="$2"; local subnet="$3"
43+
echo "==> Verifying subnet: $subnet in $vnet"
44+
if az network vnet subnet show -g "$rg" --vnet-name "$vnet" -n "$subnet" &>/dev/null; then
45+
echo "[OK] Verified subnet $subnet exists in $vnet."
46+
else
47+
echo "[ERROR] Subnet $subnet not found in $vnet!" >&2
48+
exit 1
49+
fi
50+
}
51+
52+
# -------------------------------
53+
# Create VNets and Subnets
54+
# -------------------------------
2755
# A1
2856
az network vnet create -g "$RG" -n "$VNET_A1" --address-prefix 10.10.0.0/16 --subnet-name s1 --subnet-prefix "$A1_S1" -l "$LOCATION" --output none \
2957
&& echo "Created $VNET_A1 with subnet s1"
3058
az network vnet subnet create -g "$RG" --vnet-name "$VNET_A1" -n s2 --address-prefix "$A1_S2" --output none \
3159
&& echo "Created $VNET_A1 with subnet s2"
3260
az network vnet subnet create -g "$RG" --vnet-name "$VNET_A1" -n pe --address-prefix "$A1_PE" --output none \
3361
&& echo "Created $VNET_A1 with subnet pe"
62+
# Verify A1
63+
verify_vnet "$RG" "$VNET_A1"
64+
for sn in s1 s2 pe; do verify_subnet "$RG" "$VNET_A1" "$sn"; done
3465

3566
# A2
3667
az network vnet create -g "$RG" -n "$VNET_A2" --address-prefix 10.11.0.0/16 --subnet-name s1 --subnet-prefix "$A2_MAIN" -l "$LOCATION" --output none \
3768
&& echo "Created $VNET_A2 with subnet s1"
69+
verify_vnet "$RG" "$VNET_A2"
70+
verify_subnet "$RG" "$VNET_A2" "s1"
3871

3972
# A3
4073
az network vnet create -g "$RG" -n "$VNET_A3" --address-prefix 10.12.0.0/16 --subnet-name s1 --subnet-prefix "$A3_MAIN" -l "$LOCATION" --output none \
4174
&& echo "Created $VNET_A3 with subnet s1"
75+
verify_vnet "$RG" "$VNET_A3"
76+
verify_subnet "$RG" "$VNET_A3" "s1"
4277

4378
# B1
4479
az network vnet create -g "$RG" -n "$VNET_B1" --address-prefix 10.20.0.0/16 --subnet-name s1 --subnet-prefix "$B1_MAIN" -l "$LOCATION" --output none \
4580
&& echo "Created $VNET_B1 with subnet s1"
81+
verify_vnet "$RG" "$VNET_B1"
82+
verify_subnet "$RG" "$VNET_B1" "s1"
4683

47-
echo "All VNets and subnets created successfully."
84+
echo " All VNets and subnets created and verified successfully."

0 commit comments

Comments
 (0)