From the looks of it you are trying to do as documented here. If that is the case you are right in saying the Loop is required to find out the details and the operation with URL to complete. Here is the sample code we wrote for the same:
STATUS=$(az rest --method GET --url ${URL} --query 'status' -o tsv)
while [ -z $STATUS ] #-z is empty string, may need to modify if there is also a Status = pending option
do
echo "waiting for result"
sleep 1 #delay in seconds
#if pending statuses happen, poll the API endpoint again to get the latest status
done
if [ ! ${STATUS} == "Succeeded" ]
then
echo "Operation did not succeed"
echo "Operation status is ${STATUS}"
exit 1
else
#handle Suceeded status
fi
If this still doesn't work please get back to us with the URL and .log file data to TS it further.
Regards
Navtej S