[containerapp] Fix compose create not expanding ${VAR:-default} for unset environment variables - #9965
Draft
Aditya Pujara (a0x1ab) with Copilot wants to merge 2 commits into
Draft
[containerapp] Fix compose create not expanding ${VAR:-default} for unset environment variables#9965Aditya Pujara (a0x1ab) with Copilot wants to merge 2 commits into
Aditya Pujara (a0x1ab) with Copilot wants to merge 2 commits into
Conversation
️✔️Azure CLI Extensions Breaking Change Test
|
|
Hi Copilot, |
microsoft-github-policy-service
Bot
requested review from
Greedygre (Greedygre),
JennyLawrance,
Zunli Hu (Juliehzl),
Vincent He (chinadragon0515),
Eben Carek (ebencarek),
Hong Wang (howang-ms),
Jitin John (jijohn14),
Yu Chen (jsntcy),
Alok Pagariya (pagariyaalok),
Ruslan Yakushev (ruslany),
Sanchit Mehta (sanchitmehta),
Tomer Rosenthal (torosent),
Vini Soto (vinisoto),
Vaclav Turecek (vturecek),
ZelinWang (wangzelin007),
Julie Zhu (yanzhudd) and
Yong Zhang (yonzhan)
June 22, 2026 03:27
Collaborator
|
containerapp |
…ironment variables
- Add _expand_env_var_substitution() to _compose_utils.py to handle Docker
Compose variable substitution syntax (${VAR:-default}, ${VAR-default}, ${VAR})
- Add resolve_environment_from_service() to _compose_utils.py that applies
explicit expansion after pycomposefile processing, ensuring unset variables
with defaults are resolved to their default values rather than being passed
as literal placeholder strings
- Update custom.py to import resolve_environment_from_service from the local
_compose_utils module instead of the core azure-cli module
- Add unit tests (test_containerapp_compose_unit.py) covering the expansion logic
- Add scenario test for the unset env var default expansion case
Copilot
AI
changed the title
[WIP] Fix containerapp compose create to read unset environment variables
[containerapp] Fix compose create not expanding ${VAR:-default} for unset environment variables
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
az containerapp compose createwas passing literal strings like${VAR_C:-bar}as environment variable values instead of expanding them to their defaults (bar) when the variable was unset in the local shell.Changes
azext_containerapp/_compose_utils.py_expand_env_var_substitution(value): explicit Docker Compose variable substitution expansion covering all three syntax forms:${VAR:-default}— use default when unset or empty${VAR-default}— use default only when unset${VAR}— substitute value (empty string when unset)resolve_environment_from_service(service): overrides the core azure-cli function, applying explicit expansion as a second pass afterpycomposefileprocessingazext_containerapp/custom.pyresolve_environment_from_serviceimport fromazure.cli.command_modules.containerapp._compose_utilsto the local module, so the extension's expansion logic is always appliedTests
test_containerapp_compose_unit.py(new): 17 unit tests for_expand_env_var_substitutionandresolve_environment_from_servicecovering set/unset/empty var combinations, the primary bug scenario, and non-string passthroughtest_containerapp_compose_environment.py: added scenario testtest_containerapp_compose_create_with_unset_env_defaultsfor E2E validationExample
Related command
az containerapp compose createGeneral Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (azdevrequired; see.azure-pipelines/templates/azdev_setup.ymlfor the install command untilazdev==0.2.11b1is on PyPI)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.