@@ -79,22 +79,23 @@ delegate_subnet() {
7979 subnet_id=$( az network vnet subnet show -g " $RG " --vnet-name " $vnet " -n " $subnet " --query id -o tsv)
8080 modified_custsubnet=" ${subnet_id// \/ /% 2F} "
8181
82+ responseFile=" delegate_response.txt"
83+ cmd_delegator_curl=" 'curl -X PUT http://localhost:8080/DelegatedSubnet/$modified_custsubnet '"
84+ cmd_containerapp_exec=" az containerapp exec -n subnetdelegator-westus-u3h4j -g subnetdelegator-westus --subscription 9b8218f9-902a-4d20-a65c-e98acec5362f --command $cmd_delegator_curl "
85+
8286 while [ $attempt -le $max_attempts ]; do
8387 echo " Attempt $attempt of $max_attempts ..."
8488
85- # Use az containerapp exec with --command properly formatted for non-interactive execution
86- response=$( az containerapp exec \
87- -n subnetdelegator-westus-u3h4j \
88- -g subnetdelegator-westus \
89- --subscription 9b8218f9-902a-4d20-a65c-e98acec5362f \
90- --command " curl -X PUT http://localhost:8080/DelegatedSubnet/$modified_custsubnet " 2>&1 || echo " EXEC_FAILED" )
91-
92- if [[ $response == * " success" * ]]; then
89+ # Use script command to provide PTY for az containerapp exec
90+ script --quiet -c " $cmd_containerapp_exec " " $responseFile "
91+
92+ if grep -qF " success" " $responseFile " ; then
9393 echo " Subnet Delegator successfully registered the subnet"
94+ rm -f " $responseFile "
9495 return 0
9596 else
9697 echo " Subnet Delegator failed to register the subnet (attempt $attempt )"
97- echo " Response: $response "
98+ cat " $responseFile "
9899
99100 if [ $attempt -lt $max_attempts ]; then
100101 echo " Retrying in 5 seconds..."
@@ -106,6 +107,7 @@ delegate_subnet() {
106107 done
107108
108109 echo " [ERROR] Failed to delegate subnet after $max_attempts attempts"
110+ rm -f " $responseFile "
109111 exit 1
110112}
111113
0 commit comments