fix: Refactor app sample enabling logic in auth_init scripts #103
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
The issue was that the user needed to set AZURE_APP_SAMPLE_ENABLED to true by running the azd command themselves. If they didn't set it and selected true when prompted during azd up, the script didn't recognize their choice, which prevented the App Service from being deployed.
The root cause was that the script only checked the .env file for the AZURE_APP_SAMPLE_ENABLED variable. However, when the user selected this option during the prompt, azd saved the value in config.json instead of the .env file. I have updated the script to check config.json as well.
This pull request updates both the PowerShell (
auth_init.ps1) and Bash (auth_init.sh) authentication initialization scripts to improve how they determine whether the "app sample" feature is enabled. The scripts now check both an environment variable and a configuration file, giving preference to the environment variable, and handle value normalization to ensure consistent behavior.Configuration and logic improvements:
auth_init.ps1andauth_init.shnow read theappSampleEnabledsetting from the.azure/<env>/config.jsonfile, in addition to supporting theAZURE_APP_SAMPLE_ENABLEDenvironment variable. The environment variable takes precedence if set. [1] [2]"false"values as disabling the app sample, ensuring consistent and predictable script behavior. [1] [2]Does this introduce a breaking change?
Golden Path Validation
Deployment Validation
What to Check
Verify that the following are valid
Other Information