From af2ac9a10df15b735a05737cd7974eb263656325 Mon Sep 17 00:00:00 2001 From: Harsh-Microsoft Date: Wed, 17 Dec 2025 19:50:10 +0530 Subject: [PATCH 1/2] fix: Refactor app sample enabling logic in auth_init scripts --- scripts/auth_init.ps1 | 15 +++++++++++++-- scripts/auth_init.sh | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/scripts/auth_init.ps1 b/scripts/auth_init.ps1 index cfea366..e7c0003 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" -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 From e821025b04fbb6689d5f9caa4bba5dea733e6398 Mon Sep 17 00:00:00 2001 From: Harsh-Microsoft Date: Thu, 18 Dec 2025 15:06:47 +0530 Subject: [PATCH 2/2] fix: Remove redundant check for false value in auth_init script --- scripts/auth_init.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auth_init.ps1 b/scripts/auth_init.ps1 index e7c0003..0acc59c 100644 --- a/scripts/auth_init.ps1 +++ b/scripts/auth_init.ps1 @@ -11,7 +11,7 @@ if ($env:AZURE_APP_SAMPLE_ENABLED) { $effectiveValue = $effectiveValue.ToString().ToLower() -if (-not $effectiveValue -or $effectiveValue -eq "false" -or $effectiveValue -eq $false) { +if (-not $effectiveValue -or $effectiveValue -eq "false") { Write-Host "App sample is disabled. Exiting auth_init script." exit }