Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve transient failure with creating Service Principals in MAG #122

Merged
merged 12 commits into from
Apr 7, 2021
2 changes: 1 addition & 1 deletion src/docs/ui-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ From the "src" directory

```BASH
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these changes are unrelated to the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just trying to cleanup the documentation some as I run across things that need to be fixed or modified for clarity. Should I not do that here in this PR?

chmod u+x ./scripts/setup_ezdeploy.sh
./script/setup_ezdeploy.sh -d build -s <subscription_id> -t <tenant_id> -l <location> -e <tf_env_name> -m <mlz_env_name> -p port -0 <saca_subscription_id> -1 <tier0_subscription_id> -2 <tier1_subscription_id> -3 <tier2_subscription_id>"
./scripts/setup_ezdeploy.sh -d build -s <subscription_id> -t <tenant_id> -l <location> -e <tf_env_name> -m <mlz_env_name> -p port -0 <saca_subscription_id> -1 <tier0_subscription_id> -2 <tier1_subscription_id> -3 <tier2_subscription_id>"
```

The final results will include a URI that you can use to access the front end running in a remote azure container instance.
Expand Down
42 changes: 41 additions & 1 deletion src/scripts/config/mlz_config_create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,52 @@ if [[ -z $(az ad sp list --filter "displayName eq '${mlz_sp_name}'" --query "[].
--output tsv)

# Get Service Principal AppId
# Added the sleep below to accomodate for the transient behavior where the Service Principal creation
Phydeauxman marked this conversation as resolved.
Show resolved Hide resolved
# is complete but an immediate query for it will fail. The sleep loop will run for 3 minutes and then
# the script will exit due to a platform problem
sp_exists="az ad sp show \
--id http://${mlz_sp_name} \
--query appId"

sleep_time_in_seconds=10
elapsed_time=0
while ! $sp_exists &> /dev/null
do
echo "Waiting up to 3 minutes for the Service Principal appId provisioning to complete"
sleep "${sleep_time_in_seconds}"
elapsed_time=$((elapsed_time + sleep_time_in_seconds))
if [[ "${elapsed_time}" -ge "180" ]]; then
error_log "The Service Principal creation did not complete in the exected time. Please check Azure and re-run the script."
exit 1
fi
done

sp_clientid=$(az ad sp show \
--id "http://${mlz_sp_name}" \
--query appId \
--output tsv)

# Get Service Principal ObjectId
# Get Service Principal ObjectId
# Added the sleep below to accomodate for the transient behavior where the Service Principal creation
# is complete but an immediate query for it will fail. The sleep loop will run for 3 minutes and then
# the script will exit due to a platform problem
sp_exists="az ad sp show \
--id http://${mlz_sp_name} \
--query objectId"

sleep_time_in_seconds=10
elapsed_time=0
while ! $sp_exists &> /dev/null
do
echo "Waiting up to 3 minutes for the Service Principal objectId provisioning to complete"
sleep "${sleep_time_in_seconds}"
elapsed_time=$((elapsed_time + sleep_time_in_seconds))
if [[ "${elapsed_time}" -ge "180" ]]; then
error_log "The Service Principal creation did not complete in the exected time. Please check Azure and re-run the script."
exit 1
fi
done

sp_objid=$(az ad sp show \
--id "http://${mlz_sp_name}" \
--query objectId \
Expand Down