Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/scripts/container-registry/add_auth_scopes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,40 @@ wait_for_app_creation() {
done
}

# accomodate for transient behavior where App Registration is created
# but an immediate query for its properties will fail
# and attempt for max_wait_in_seconds before giving up.
wait_for_app_query_from_list() {
app_name_to_query=$1
property_to_query=$2

property_query="az ad app list --display-name ${app_name_to_query} --query [].${property_to_query} --output tsv"

sleep_time_in_seconds=10
max_wait_in_seconds=180
max_retries=$((max_wait_in_seconds/sleep_time_in_seconds))

count=1

while [[ -z $($property_query) ]]
do
echo "INFO: waiting for query \"${property_query}\" to return results (${count}/${max_retries})"
echo "INFO: trying again in ${sleep_time_in_seconds} seconds..."
sleep "${sleep_time_in_seconds}"

if [[ ${count} -eq max_retries ]]; then
error_log "ERROR: unable to get results from query \"${property_query}\" in ${max_wait_in_seconds} seconds. Investigate and re-run script."
exit 1
fi

count=$((count +1))
done
}

wait_for_app_creation "${app_id}"
wait_for_app_query_from_list "${mlz_fe_app_name}" "appId"

echo "INFO: sourcing app registration information for app ID ${app_id}..."
client_password=$(az ad app credential reset \
--id ${app_id} \
--query password \
Expand Down