Skip to content

feat: add sensible defaults for azd env new / init in --no-prompt mode #6934

@spboyer

Description

@spboyer

Feature Request

azd env new and azd init should handle --no-prompt mode more gracefully by providing sensible defaults instead of failing when optional arguments are omitted.

Current behavior

  • azd env new --no-prompt without <name> argument: prompts interactively (fails in CI/non-interactive)
  • azd init --no-prompt --template <t> without --environment: returns error requiring --environment
  • No subscription auto-selection from defaults.subscription config or single-subscription accounts

Proposed behavior

1. Auto-generate environment name from working directory
When --no-prompt is passed without an explicit environment name, default to filepath.Base(cwd) (sanitized for valid env name characters), matching how azd init already generates name suggestions interactively.

2. Auto-select subscription
When --no-prompt is passed without --subscription:

  • First check azd config for defaults.subscription
  • If not set and only one subscription exists, auto-select it
  • If multiple subscriptions and no default, return clear error with guidance

Motivation

Extensions (e.g. azure.ai.agents) need non-interactive init flows for CI/CD. Currently each extension must implement its own --no-prompt logic for env naming and subscription selection, which is inconsistent and duplicative. This should be a core capability.

See discussion in #6823 (PR feedback from @trangevi, @vhvb1989, @kristenwomack).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions