Problem
When running azd init --template <url> without --environment in a non-interactive context (--no-prompt or non-TTY), azd downloads the entire template repository before failing at the environment name prompt. This leaves a half-initialized directory that must be manually cleaned up before retrying.
Current execution order:
initializeTemplate() — downloads and copies template files ✅ (expensive, succeeds)
initializeEnv() — prompts for environment name ❌ (fails in non-interactive mode)
This is the worst outcome for automated workflows: do expensive work, then fail.
Proposed Solution
Add an early validation check in cli/azd/cmd/init.go before initializeTemplate() is called:
- If running non-interactively (
--no-prompt flag or non-TTY stdin) and --environment is not provided, return a clear error immediately:
--environment is required when running non-interactively. Use: azd init --template <url> --environment <name>
Scope
- Only affects non-interactive mode — interactive users still get the prompt as before
- No changes to template download logic
- Targeted guard, minimal code change
Impact
Prevents the frustrating download-then-fail-then-cleanup cycle for agents and CI/CD pipelines.
Problem
When running
azd init --template <url>without--environmentin a non-interactive context (--no-promptor non-TTY), azd downloads the entire template repository before failing at the environment name prompt. This leaves a half-initialized directory that must be manually cleaned up before retrying.Current execution order:
initializeTemplate()— downloads and copies template files ✅ (expensive, succeeds)initializeEnv()— prompts for environment name ❌ (fails in non-interactive mode)This is the worst outcome for automated workflows: do expensive work, then fail.
Proposed Solution
Add an early validation check in
cli/azd/cmd/init.gobeforeinitializeTemplate()is called:--no-promptflag or non-TTY stdin) and--environmentis not provided, return a clear error immediately:--environment is required when running non-interactively. Use: azd init --template <url> --environment <name>Scope
Impact
Prevents the frustrating download-then-fail-then-cleanup cycle for agents and CI/CD pipelines.