Skip to content

feat: support code deploy in --no-prompt mode via CLI flags#8324

Merged
trangevi merged 5 commits into
Azure:mainfrom
v1212:feat/no-prompt-code-deploy
May 22, 2026
Merged

feat: support code deploy in --no-prompt mode via CLI flags#8324
trangevi merged 5 commits into
Azure:mainfrom
v1212:feat/no-prompt-code-deploy

Conversation

@v1212
Copy link
Copy Markdown
Collaborator

@v1212 v1212 commented May 22, 2026

Summary

Adds --deploy-mode, --runtime, --entry-point, and --dep-resolution flags to azd ai agent init for non-interactive code deploy support in CI/CD pipelines.

Closes #8323

What this PR changes

In --no-prompt mode, the deploy mode was hardcoded to "container" with no way to select code deploy. This PR adds four new flags:

Flag Values Default (no-prompt) Required
--deploy-mode container, code container No
--runtime python_3_13, python_3_14, dotnet_10 ΓÇö Yes, when --deploy-mode code --no-prompt
--entry-point file path (e.g. app.py) ΓÇö Yes, when --deploy-mode code --no-prompt
--dep-resolution remote_build, bundled remote_build No

Example usage

azd ai agent init --no-prompt \
  --project-id "/subscriptions/.../projects/my-project" \
  --model-deployment "gpt-4o" \
  --deploy-mode code \
  --runtime python_3_13 \
  --entry-point app.py

Interaction with existing --no-prompt behavior

This PR does not change how --no-prompt handles Foundry project or model deployment selection. The existing behavior remains:

Decision --no-prompt behavior (unchanged)
Foundry project --project-id is required (must be an existing project). Without it, init errors out with a hint to pass --project-id.
Model deployment If --model-deployment is passed, looks up that deployment in the Foundry project. If not passed, auto-selects the first matching deployment. If none exist, auto-configures a new deployment from the catalog (requires azd up).
End-of-init message Existing deployment selected → azd deploy. New deployment created → azd up (provision needed to create the model deployment via Bicep).

The new --deploy-mode / --runtime / --entry-point flags only control how the agent code is packaged and deployed (container image vs ZIP upload). They are orthogonal to project and model selection.

Tests added

  • TestPromptDeployMode_FlagOverride ΓÇö 6 cases: flag precedence, invalid flag error, noPrompt default
  • TestPromptCodeConfig_FlagOverrides ΓÇö 5 cases: opts override, noPrompt defaults for Python/dotnet
  • TestCodeDeployFlagValidation ΓÇö 5 cases: validates required flags in noPrompt+code mode

E2E Test Results

Build: azd x build --cwd cli/azd/extensions/azure.ai.agents on branch feat/no-prompt-code-deploy
Extension: 0.1.33-preview (local dev build)
Project: Existing Foundry project in North Central US with gpt-4.1-mini deployment

Test Matrix

# Scenario Command Flags Result
1 Full code deploy (init + deploy + invoke) --deploy-mode code --runtime python_3_13 --entry-point main.py --dep-resolution remote_build PASS
2 Bundled dependency resolution --deploy-mode code --runtime python_3_13 --entry-point main.py --dep-resolution bundled PASS
3 Missing --runtime validation --deploy-mode code --entry-point main.py PASS (error)
4 Missing --entry-point validation --deploy-mode code --runtime python_3_13 PASS (error)
5 Invalid --deploy-mode validation --deploy-mode invalid PASS (error)
6 Backward compat (no --deploy-mode) (no deploy-mode flag) PASS (defaults to container)
7 Explicit container mode --deploy-mode container PASS

Key Verifications

  • Case 1: azd ai agent init --no-prompt with all flags agent.yaml contains correct code_configuration (runtime, entry_point, dependency_resolution) azd deploy succeeds agent invoke returns valid LLM response
  • Cases 3-5: Proper validation errors with helpful suggestions when required flags are missing
  • Cases 6-7: Default behavior unchanged no --deploy-mode flag still defaults to container (backward compatible)

All tests used --no-prompt mode with -m <manifestUrl> and --project-id.

Add --deploy-mode, --runtime, --entry-point, and --dep-resolution flags
to enable non-interactive code deploy for CI/CD pipelines.

- --deploy-mode code|container (default: container, backward compatible)
- --runtime python_3_13|python_3_14|dotnet_10 (required for code deploy)
- --entry-point <file> (required for code deploy)
- --dep-resolution remote_build|bundled (default: remote_build)

These flags produce the same output as interactive mode (agent.yaml
code_configuration + azure.yaml language field + SKIP_ACR_CREATION env var).
No changes to deploy-time behavior.
@github-actions github-actions Bot added the ext-agents azure.ai.{agents,connections,inspector,projects,routines,skills,toolboxes} extensions label May 22, 2026
Jian Wu added 3 commits May 22, 2026 16:14
… promptCodeConfig

Extract validateCodeDeployFlags into a testable method and add 16 test
cases covering flag precedence, noPrompt defaults, and error conditions.
@v1212 v1212 marked this pull request as ready for review May 22, 2026 08:35
@v1212 v1212 requested a review from JeffreyCA as a code owner May 22, 2026 08:35
Copilot AI review requested due to automatic review settings May 22, 2026 08:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds non-interactive (“--no-prompt”) support for code deploy in azd ai agent init by introducing CLI flags that allow CI/CD pipelines to fully specify deploy mode and code-deploy configuration without prompts.

Changes:

  • Adds --deploy-mode, --runtime, --entry-point, and --dep-resolution flags to azd ai agent init.
  • Implements shared validation for required flags in --no-prompt + --deploy-mode code flows and threads flag overrides into the existing prompt helpers.
  • Adds unit tests covering deploy-mode flag precedence, code config flag overrides, and required-flag validation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
cli/azd/extensions/azure.ai.agents/internal/cmd/init.go Registers new CLI flags, validates required inputs for non-interactive code deploy, updates help/examples, and passes flag overrides into prompting.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go Updates deploy-mode and code-config prompt helpers to accept flag overrides and validates required flags in the init-from-code flow.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_test.go Adds tests for required-flag validation behavior in --no-prompt + code deploy mode.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code_test.go Adds tests for deploy-mode flag precedence and code-config flag override behavior.
Comments suppressed due to low confidence (1)

cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go:1292

  • When opts.runtime is provided (via --runtime), it’s accepted verbatim without validation against the supported runtime values shown in the prompt/help text. This can produce an agent.yaml with an invalid runtime and later failures (e.g., wrong command prefix). Add validation for opts.runtime (and ideally for interactive flag usage too) to ensure it matches one of the supported values (python_3_13/python_3_14/dotnet_10) and return a structured validation error when invalid.
	var runtime string
	if opts.runtime != "" {
		runtime = opts.runtime
	} else if noPrompt {
		if isDotnet && !isPython {
			runtime = "dotnet_10"
		} else {
			runtime = "python_3_13" // default to Python for mixed/unknown repos (language preference, not version compat)

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go
@trangevi trangevi enabled auto-merge (squash) May 22, 2026 15:51
@trangevi trangevi disabled auto-merge May 22, 2026 15:51
@trangevi
Copy link
Copy Markdown
Member

/check-enforcer override

@trangevi trangevi merged commit d6cf42b into Azure:main May 22, 2026
27 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-agents azure.ai.{agents,connections,inspector,projects,routines,skills,toolboxes} extensions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azd code deploy cannot be executed non-interactively

3 participants