Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 13 additions & 2 deletions scripts/auth_init.ps1
Original file line number Diff line number Diff line change
@@ -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
}

Expand Down
16 changes: 13 additions & 3 deletions scripts/auth_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down