Commit 75433355 authored by Aryaan Singh's avatar Aryaan Singh
Browse files

Lopp through login

parent 9e48dec4
Pipeline #71640 passed with stages
in 1 minute and 22 seconds
......@@ -19,6 +19,7 @@ RUN pip3 install --no-cache --upgrade azure-cosmos
WORKDIR /usr/src/app
COPY data_initialization_agent/access_token/get_access_token.sh ./
COPY data_seeding_agent/seed_data.sh ./
COPY test_data/Legal_COO.json ./test_data/
COPY test_data/tenant_info_1.json ./test_data/
......
......@@ -4,11 +4,34 @@ currentStatus=""
currentMessage=""
retryCount=0
maxRetry=7
loginAttemptCount=0
# This logs the Azure CLI in using the configured service principal.
# az login --service-principal -u $ARM_CLIENT_ID -p $ARM_CLIENT_SECRET --tenant $ARM_TENANT_ID
# az account set -s $ARM_SUBSCRIPTION_ID
az login --identity --username $OSDU_IDENTITY_ID
while [[ $loginAttemptCount -lt $maxRetry ]]; do
loginAttemptCount=$(expr $loginAttemptCount + 1)
echo "Trying to Fetch Access Token"
ACCESS_TOKEN=$(sh ./get_access_token.sh)
if [[ "$ACCESS_TOKEN" == "TOKEN_FETCH_FAILURE" ]]; then
echo "Failure manually fetching Access Token. Attempt ${loginAttemptCount} of ${maxRetry}."
currentMessage="${currentMessage}. Failure manually fetching Access Token. Attempt ${loginAttemptCount} of ${maxRetry}. "
continue
else
echo "Manual fetch access token successful. Attempt ${loginAttemptCount} of ${maxRetry}."
currentMessage="${currentMessage}. Manual fetch access token successful. Attempt ${loginAttemptCount} of ${maxRetry}. "
AZ_LOGIN=$(az login --identity --username $OSDU_IDENTITY_ID)
echo $AZ_LOGIN
if [[ ${AZ_LOGIN} == *"AzureConnectionError"* ]] || [[ ${AZ_LOGIN} == *"Failed to connect to MSI"* ]];then
echo "az login failed. Attempt ${loginAttemptCount} of ${maxRetry}."
currentMessage="${currentMessage}. az login failed: ${AZ_LOGIN}. Attempt ${loginAttemptCount} of ${maxRetry}. "
continue
else
echo "az login successful. Attempt ${loginAttemptCount} of ${maxRetry}."
currentMessage="${currentMessage}. az login successful. Attempt ${loginAttemptCount} of ${maxRetry}. "
break
fi
fi
done
# The Legal_COO.json file needs to be loaded into the Data Partition Storage Account,
# in the container legal-service-azure-configuration.
......@@ -136,7 +159,7 @@ fi
if [[ ${currentStatus} == "success" ]]; then
exit 0
elif [[ ${currentStatus} == "failure" ]]; then
exit 0
exit 1
else
exit 1
fi
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment