|
185 | 185 |
|
186 | 186 | # Temporarily allow outbound internet connections through the NSG from this IP address only |
187 | 187 | PRIVATEIPADDRESS=${VNET_IPTRIPLET}.4 |
188 | | - echo -e "${BOLD}Temporarily allowing outbound internet access from ${BLUE}$PRIVATEIPADDRESS${END}${BOLD} in NSG ${BLUE}$NSG_EXTERNAL${END}${BOLD} (for use during deployment *only*)${END}" |
| 188 | + echo -e "${BOLD}Temporarily allowing outbound internet access on ports 80, 443 and 3128 from ${BLUE}$PRIVATEIPADDRESS${END}${BOLD} in NSG ${BLUE}$NSG_EXTERNAL${END}${BOLD} (for installing software during deployment *only*)${END}" |
189 | 189 | az network nsg rule create --resource-group $RESOURCEGROUP --nsg-name $NSG_EXTERNAL --direction Outbound --name configurationOutboundTemporary --description "Allow ports 80 (http), 443 (pip) and 3128 (pip) for installing software" --access "Allow" --source-address-prefixes $PRIVATEIPADDRESS --destination-port-ranges 80 443 3128 --protocol TCP --destination-address-prefixes Internet --priority 100 --output none |
190 | 190 | az network nsg rule create --resource-group $RESOURCEGROUP --nsg-name $NSG_EXTERNAL --direction Outbound --name vnetOutboundTemporary --description "Block connections to the VNet" --access "Deny" --source-address-prefixes $PRIVATEIPADDRESS --destination-port-ranges "*" --protocol "*" --destination-address-prefixes VirtualNetwork --priority 150 --output none |
191 | 191 |
|
@@ -215,14 +215,10 @@ else |
215 | 215 |
|
216 | 216 | # Poll VM to see whether it has finished running |
217 | 217 | echo -e "${BOLD}Waiting for VM setup to finish (this may take several minutes)...${END}" |
218 | | - while true; do |
219 | | - POLL=$(az vm get-instance-view --resource-group $RESOURCEGROUP --name $MACHINENAME --query "instanceView.statuses[?code == 'PowerState/running'].displayStatus") |
220 | | - if [ "$(echo $POLL | grep 'VM running')" == "" ]; then break; fi |
221 | | - sleep 10 |
222 | | - done |
| 218 | + az vm wait --name $MACHINENAME --resource-group $RESOURCEGROUP --custom "instanceView.statuses[?code == 'PowerState/stopped'].displayStatus" --output none |
223 | 219 |
|
224 | 220 | # Delete the configuration NSG rule and restart the VM |
225 | | - echo -e "${BOLD}Restarting VM: ${BLUE}${MACHINENAME}${END}" --output none |
| 221 | + echo -e "${BOLD}Restarting VM: ${BLUE}${MACHINENAME}${END}" |
226 | 222 | az network nsg rule delete --resource-group $RESOURCEGROUP --nsg-name $NSG_EXTERNAL --name configurationOutboundTemporary --output none |
227 | 223 | az network nsg rule delete --resource-group $RESOURCEGROUP --nsg-name $NSG_EXTERNAL --name vnetOutboundTemporary --output none |
228 | 224 | az vm start --resource-group $RESOURCEGROUP --name $MACHINENAME --output none |
@@ -271,7 +267,7 @@ if [ "$TIER" == "2" ]; then # we do not support Tier-3 CRAN mirrors at present |
271 | 267 |
|
272 | 268 | # Temporarily allow outbound internet connections through the NSG from this IP address only |
273 | 269 | PRIVATEIPADDRESS=${VNET_IPTRIPLET}.5 |
274 | | - echo -e "${BOLD}Temporarily allowing outbound internet access from ${BLUE}$PRIVATEIPADDRESS${END}${BOLD} in NSG ${BLUE}$NSG_EXTERNAL${END}${BOLD} (for use during deployment *only*)${END}" |
| 270 | + echo -e "${BOLD}Temporarily allowing outbound internet access on ports 80, 443 and 3128 from ${BLUE}$PRIVATEIPADDRESS${END}${BOLD} in NSG ${BLUE}$NSG_EXTERNAL${END}${BOLD} (for installing software during deployment *only*)${END}" |
275 | 271 | az network nsg rule create --resource-group $RESOURCEGROUP --nsg-name $NSG_EXTERNAL --direction Outbound --name configurationOutboundTemporary --description "Allow ports 80 (http), 443 (pip) and 3128 (pip) for installing software" --access "Allow" --source-address-prefixes $PRIVATEIPADDRESS --destination-port-ranges 80 443 3128 --protocol TCP --destination-address-prefixes Internet --priority 100 --output none |
276 | 272 | az network nsg rule create --resource-group $RESOURCEGROUP --nsg-name $NSG_EXTERNAL --direction Outbound --name vnetOutboundTemporary --description "Block connections to the VNet" --access "Deny" --source-address-prefixes $PRIVATEIPADDRESS --destination-port-ranges "*" --protocol "*" --destination-address-prefixes VirtualNetwork --priority 200 --output none |
277 | 273 |
|
@@ -300,11 +296,7 @@ if [ "$TIER" == "2" ]; then # we do not support Tier-3 CRAN mirrors at present |
300 | 296 |
|
301 | 297 | # Poll VM to see whether it has finished running |
302 | 298 | echo -e "${BOLD}Waiting for VM setup to finish (this may take several minutes)...${END}" |
303 | | - while true; do |
304 | | - POLL=$(az vm get-instance-view --resource-group $RESOURCEGROUP --name $MACHINENAME --query "instanceView.statuses[?code == 'PowerState/running'].displayStatus") |
305 | | - if [ "$(echo $POLL | grep 'VM running')" == "" ]; then break; fi |
306 | | - sleep 10 |
307 | | - done |
| 299 | + az vm wait --name $MACHINENAME --resource-group $RESOURCEGROUP --custom "instanceView.statuses[?code == 'PowerState/stopped'].displayStatus" --output none |
308 | 300 |
|
309 | 301 | # Delete the configuration NSG rule and restart the VM |
310 | 302 | echo -e "${BOLD}Restarting VM: ${BLUE}${MACHINENAME}${END}" |
|
0 commit comments