diff --git a/scripts/auth_init.ps1 b/scripts/auth_init.ps1 index cfea366..0acc59c 100644 --- a/scripts/auth_init.ps1 +++ b/scripts/auth_init.ps1 @@ -1,7 +1,18 @@ . ./scripts/loadenv.ps1 -if (-not $env:AZURE_APP_SAMPLE_ENABLED -or $env:AZURE_APP_SAMPLE_ENABLED -eq "false") { - Write-Host "AZURE_APP_SAMPLE_ENABLED is false. Exiting auth_init script." +$appSampleEnabled = (Get-Content .\.azure\$env:AZURE_ENV_NAME\config.json | ConvertFrom-Json).infra.parameters.appSampleEnabled + +# Give preference to AZURE_APP_SAMPLE_ENABLED environment variable +if ($env:AZURE_APP_SAMPLE_ENABLED) { + $effectiveValue = $env:AZURE_APP_SAMPLE_ENABLED +} else { + $effectiveValue = $appSampleEnabled +} + +$effectiveValue = $effectiveValue.ToString().ToLower() + +if (-not $effectiveValue -or $effectiveValue -eq "false") { + Write-Host "App sample is disabled. Exiting auth_init script." exit } diff --git a/scripts/auth_init.sh b/scripts/auth_init.sh index 813ce50..137e614 100755 --- a/scripts/auth_init.sh +++ b/scripts/auth_init.sh @@ -3,9 +3,19 @@ # Load environment variables from a shell script . ./scripts/loadenv.sh -# Check if AZURE_APP_SAMPLE_ENABLED is not set or is "false" -if [[ -z "$AZURE_APP_SAMPLE_ENABLED" || "$AZURE_APP_SAMPLE_ENABLED" == "false" ]]; then - echo "AZURE_APP_SAMPLE_ENABLED is false. Exiting auth_init script." +appSampleEnabled=$(./.venv/bin/python -c "import json; print(str(json.load(open('.azure/$AZURE_ENV_NAME/config.json'))['infra']['parameters']['appSampleEnabled']).lower())" 2>/dev/null || echo "false") + +# Give preference to AZURE_APP_SAMPLE_ENABLED environment variable +if [[ -n "$AZURE_APP_SAMPLE_ENABLED" ]]; then + effectiveValue="${AZURE_APP_SAMPLE_ENABLED}" +else + effectiveValue="$appSampleEnabled" +fi + +effectiveValue=$(echo "$effectiveValue" | tr '[:upper:]' '[:lower:]') + +if [[ -z "$effectiveValue" || "$effectiveValue" == "false" ]]; then + echo "App sample is disabled. Exiting auth_init script." exit 0 fi