Thanks Peter!
I have converted it to bash and simplified for my use case. It seems that just a list of the storage containers is also blocked by the firewall.
FWTestAttempt=1
FWTestMax=10
while true; do
if az storage container list --account-name ${STORAGE_ACCOUNT_NAME} --account-key ${ACCOUNT_KEY} &> /dev/null; then
echo "Storage is now accessible."
break
else
if [ $FWTestAttempt -lt $FWTestMax ]; then
echo "Unable to access storage account $FWTestAttempt/$FWTestMax. Waiting for FW rule to take effect."
((FWTestAttempt++))
sleep 10
else
echo "Unable to access storage account $FWTestAttempt/$FWTestMax."
exit 1
fi
fi
done