Skip to content

feat: add azd exec — run commands and scripts with azd environment context#7400

Merged
jongio merged 13 commits into
Azure:mainfrom
jongio:feature/microsoft-azd-exec
May 12, 2026
Merged

feat: add azd exec — run commands and scripts with azd environment context#7400
jongio merged 13 commits into
Azure:mainfrom
jongio:feature/microsoft-azd-exec

Conversation

@jongio
Copy link
Copy Markdown
Member

@jongio jongio commented Mar 31, 2026

Fixes #7520

Design Specification: design-spec.md

Description

Add azd exec ΓÇö a cross-platform command and script execution engine that runs programs with full azd environment context (environment variables, Key Vault secret resolution).

This addresses long-standing requests for running scripts with azd env vars: #391, #1697, #2336, #4067.

Example Usage

# Install
azd extension install microsoft.azd.exec

# Run a command directly with azd environment (exact argv, no shell wrapping)
azd exec python script.py
azd exec npm run dev
azd exec -- python app.py --port 8000 --reload
azd exec docker compose up --build

# Execute a script file ΓÇö shell auto-detected from file extension
azd exec ./setup.sh

# Inline shell command (single quoted argument uses shell)
azd exec 'echo $AZURE_ENV_NAME'

# Specify a shell explicitly
azd exec --shell pwsh "Write-Host $env:AZURE_STORAGE_ACCOUNT"

# Pass arguments through to the script
azd exec ./build.sh -- --verbose --output ./dist

# Interactive mode ΓÇö stdin passthrough for prompts
azd exec -i ./interactive-setup.sh

Execution Modes

Invocation Mode How it works
azd exec python script.py Direct exec exec.Command("python", "script.py") ΓÇö exact argv, no shell
azd exec 'echo $VAR' Shell inline bash -c "echo $VAR" ΓÇö shell expansion available
azd exec ./setup.sh Script file bash ./setup.sh ΓÇö shell detected from extension
azd exec --shell pwsh "cmd" Shell inline pwsh -Command "cmd" ΓÇö explicit shell

Heuristic: Multiple arguments without --shell → direct process execution (OS exec semantics). Single quoted argument or explicit --shell → shell inline execution. File path → script file execution with auto-detected or explicit shell.

Features

  • Direct process execution: Run programs with exact argv semantics (no shell wrapping) ΓÇö azd exec python script.py just works
  • Script execution: Run script files or inline commands with configurable shell
  • Environment loading: Inherits azd environment variables (Key Vault secret resolution handled by azd core)
  • Cross-platform shells: bash, sh, zsh, pwsh, powershell, cmd
  • Shell auto-detection: Detects shell from script file extension
  • Exit code propagation: Child process exit codes forwarded faithfully for CI/CD pipelines
  • Interactive mode: stdin passthrough for interactive scripts

Architecture

main.go                    → Entry point with exit code propagation
internal/cmd/              → Cobra CLI commands (root, version, listen)
internal/executor/         → Script execution engine + command builder + error types
internal/shellutil/        → Shared shell detection and validation

3 focused internal packages, no circular dependencies, structured error types for programmatic handling.

Test Coverage

Package Coverage
cmd 91.4%
executor 96.5%
shellutil 93.3%
Total 94.3%

23 tests passing. Table-driven tests with platform-aware scaffolding.

What's Included

  • Extension source code (cli/azd/extensions/microsoft.azd.exec/)
  • GitHub Actions lint workflow (.github/workflows/lint-ext-microsoft-azd-exec.yml)
  • ADO release pipeline (eng/pipelines/release-ext-microsoft-azd-exec.yml)
  • Cross-platform build scripts (build.ps1, build.sh, ci-build.ps1)

What's NOT Included (Follow-Up)

  • Registry entry: Will be added when first release publishes binaries with artifact checksums

Dependencies

Open Discussion (ref: #7423)

The following items are open for broader team discussion. They don't block this PR but affect the longer-term direction:

1. Extension vs Core Command

This capability is implemented as an extension (microsoft.azd.exec). Issue #7423 proposes a core azd env exec command for the same use case. The extension approach provides:

  • Faster iteration cycle (independent release)
  • No impact on azd core binary size or command surface
  • Can be promoted to core later if usage validates the design

The tradeoff is discoverability ΓÇö users need to install the extension. This should be evaluated based on adoption data.

2. Key Vault Secret Auto-Resolution

The azd host resolves akvs:// and @Microsoft.KeyVault(...) references before passing environment to extension subprocesses. This means child processes launched by azd exec receive materialized secrets in their environment. This is consistent with how azd hooks work today.

weikanglim's concern: automatic secret materialization should be opt-in rather than implicit. If this is addressed, it should be at the host level (affecting all extensions/hooks), not the extension level. The extension has no mechanism to "un-resolve" secrets that the host already materialized.

Testing

cd cli/azd/extensions/microsoft.azd.exec
GOWORK=off go test -count=1 ./...
GOWORK=off go vet ./...

Copilot AI review requested due to automatic review settings March 31, 2026 00:05
@jongio jongio marked this pull request as draft March 31, 2026 00:09
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 the first-party microsoft.azd.exec extension to the azure-dev repo, enabling azd exec to run scripts/inline commands with azd environment context and optional Key Vault secret resolution, plus MCP tooling. It also introduces/extends Key Vault reference parsing and host-side secret resolution so extensions receive resolved env vars.

Changes:

  • Introduces the cli/azd/extensions/microsoft.azd.exec extension module (cobra command, executor, MCP server, skills, build scripts, metadata).
  • Adds Key Vault secret reference parsing/resolution helpers in core (pkg/keyvault) and a new resolver in the extension SDK (pkg/azdext).
  • Wires Key Vault env var resolution into extension invocation and adds CI/release pipeline + registry/workflow entries for the new extension.

Reviewed changes

Copilot reviewed 31 out of 32 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
eng/pipelines/release-ext-microsoft-azd-exec.yml Adds ADO release pipeline definition for the new extension.
.github/workflows/lint-ext-microsoft-azd-exec.yml Adds GitHub Actions lint workflow scoped to the new extension module.
cli/azd/cmd/extensions.go Resolves Key Vault secret references in azd-managed env vars before invoking extensions.
cli/azd/pkg/keyvault/keyvault.go Adds support for @Microsoft.KeyVault(SecretUri=...) parsing + unified reference resolution + env var list resolver.
cli/azd/pkg/keyvault/keyvault_test.go Adds unit tests for new reference parsing and env var secret resolution behavior.
cli/azd/pkg/cmdsubst/cmdsubst_additional_test.go Updates KeyVaultService mock to satisfy the expanded interface.
cli/azd/pkg/azdext/keyvault_resolver.go Adds SDK-side Key Vault resolver supporting multiple reference formats and caching.
cli/azd/pkg/azdext/keyvault_resolver_test.go Adds comprehensive resolver tests (parsing, error classification, concurrency, env/map helpers).
cli/azd/extensions/registry.json Registers the new microsoft.azd.exec extension (id/namespace/version/capabilities).
cli/azd/extensions/microsoft.azd.exec/version.txt Introduces extension version tracking (0.5.0).
cli/azd/extensions/microsoft.azd.exec/README.md Adds end-user docs for install/usage/features of azd exec.
cli/azd/extensions/microsoft.azd.exec/main.go Adds extension entrypoint and error rendering.
cli/azd/extensions/microsoft.azd.exec/go.mod Adds Pattern B module for the extension with replace to core azd module.
cli/azd/extensions/microsoft.azd.exec/go.sum Adds extension module dependency lockfile.
cli/azd/extensions/microsoft.azd.exec/extension.yaml Defines extension metadata/capabilities and MCP serve args/env mapping.
cli/azd/extensions/microsoft.azd.exec/.golangci.yaml Adds extension-specific golangci-lint configuration.
cli/azd/extensions/microsoft.azd.exec/CHANGELOG.md Adds initial changelog for the extension.
cli/azd/extensions/microsoft.azd.exec/build.sh Adds cross-platform build script for producing extension binaries.
cli/azd/extensions/microsoft.azd.exec/build.ps1 Adds PowerShell cross-platform build script for producing extension binaries.
cli/azd/extensions/microsoft.azd.exec/ci-build.ps1 Adds CI build wrapper for the extension (flags/tags/ldflags).
cli/azd/extensions/microsoft.azd.exec/internal/cmd/root.go Implements azd exec root command wiring, flags, env loading, and subcommands.
cli/azd/extensions/microsoft.azd.exec/internal/cmd/root_test.go Adds basic tests for root/version command construction.
cli/azd/extensions/microsoft.azd.exec/internal/cmd/version.go Implements version subcommand output.
cli/azd/extensions/microsoft.azd.exec/internal/cmd/mcp.go Implements hidden MCP server command and tool handlers (exec/list shells/env).
cli/azd/extensions/microsoft.azd.exec/internal/cmd/mcp_test.go Adds unit tests for MCP handlers, validation, and helper functions.
cli/azd/extensions/microsoft.azd.exec/internal/executor/executor.go Implements script/inline execution and env preparation with optional Key Vault resolution.
cli/azd/extensions/microsoft.azd.exec/internal/executor/command_builder.go Builds shell-specific exec command lines (including PowerShell quoting).
cli/azd/extensions/microsoft.azd.exec/internal/executor/command_builder_test.go Adds tests for command construction and PowerShell arg quoting.
cli/azd/extensions/microsoft.azd.exec/internal/executor/errors.go Adds typed executor errors (validation/shell/exit code).
cli/azd/extensions/microsoft.azd.exec/internal/executor/errors_test.go Adds tests validating error messages and config validation.
cli/azd/extensions/microsoft.azd.exec/internal/skills/skills.go Implements embedded Copilot skill installation to ~/.copilot/skills/azd-exec.
cli/azd/extensions/microsoft.azd.exec/internal/skills/azd-exec/SKILL.md Adds embedded skill definition/documentation for the extension.

Comment thread cli/azd/extensions/microsoft.azd.exec/internal/cmd/root.go Outdated
Comment thread cli/azd/extensions/microsoft.azd.exec/internal/executor/executor.go Outdated
Comment thread cli/azd/extensions/microsoft.azd.exec/README.md Outdated
Comment thread cli/azd/extensions/microsoft.azd.exec/internal/skills/azd-exec/SKILL.md Outdated
Comment thread cli/azd/extensions/microsoft.azd.exec/internal/skills/azd-exec/SKILL.md Outdated
Comment thread cli/azd/extensions/microsoft.azd.exec/ci-build.ps1 Outdated
Comment thread cli/azd/pkg/keyvault/keyvault.go
Comment thread cli/azd/extensions/microsoft.azd.exec/internal/cmd/mcp.go Outdated
Comment thread cli/azd/extensions/microsoft.azd.exec/internal/cmd/mcp.go Outdated
Comment thread cli/azd/extensions/microsoft.azd.exec/internal/cmd/root.go Outdated
@jongio jongio force-pushed the feature/microsoft-azd-exec branch 8 times, most recently from 81565b7 to b721a0a Compare April 1, 2026 22:55
@jongio jongio marked this pull request as ready for review April 1, 2026 23:19
@jongio
Copy link
Copy Markdown
Member Author

jongio commented Apr 1, 2026

Dependent on #7314

@jongio
Copy link
Copy Markdown
Member Author

jongio commented Apr 1, 2026

Known Issue: Environment Value Munging

When loadAzdEnvironment() is called (via azd env get-values), values go through a godotenv.Marshal → dotenv text → parse roundtrip that can munge certain values (e.g., leading zeros stripped, multiline values corrupted).

azd core already passes env vars directly to the extension process environment, so this roundtrip is only needed when -e/--environment overrides to a different environment. Without -e, the correct values are already present.

PR #7314 addresses the core godotenv.Marshal munging issue. Once that lands, the roundtrip will be safe. In the meantime, the default case (no -e flag) works correctly since it uses the env vars passed directly by azd core.

Tracking: depends on #7314

Copy link
Copy Markdown
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

Code Review — microsoft.azd.exec Extension

Good work on the clean architecture and comprehensive test coverage! A few items to consider before this is ready to merge.

What Looks Good ✅

  • Clean package structure — 3 focused packages (cmd, executor, shellutil) with clear separation of concerns
  • Strong error hierarchy — Typed errors enable programmatic handling and clear user messages
  • Comprehensive table-driven tests — Platform-aware scaffolding, validation edge cases, and PowerShell quoting coverage
  • Faithful exit code propagation — Critical for CI/CD usage, well-implemented
  • Correct SDK usageNewExtensionRootCommand, PersistentPreRunE chain preservation, NewMetadataCommand

Summary

Priority Count
Critical 0
High 2
Medium 3
Low 2
Total 7

Overall Assessment: Comment — see inline comments for details.

Comment thread cli/azd/extensions/microsoft.azd.exec/main.go Outdated
Comment thread cli/azd/extensions/microsoft.azd.exec/extension.yaml Outdated
Comment thread cli/azd/extensions/microsoft.azd.exec/build.ps1 Outdated
Comment thread cli/azd/extensions/microsoft.azd.exec/build.ps1 Outdated
Comment thread cli/azd/extensions/microsoft.azd.exec/main.go Outdated
Comment thread eng/pipelines/release-ext-microsoft-azd-exec.yml Outdated
@jongio jongio force-pushed the feature/microsoft-azd-exec branch from b721a0a to b2cf453 Compare April 2, 2026 05:26
@spboyer
Copy link
Copy Markdown
Member

spboyer commented Apr 2, 2026

How are we logging failures, preflight on the script (if needed), if the script itself fails does it use azd logs so we can report when a user has used exec and passed or failed and why

Also how does this differ from hooks, pre and post?

@jongio
Copy link
Copy Markdown
Member Author

jongio commented Apr 2, 2026

Good questions.

On logging and error reporting:

We're using the SDK's telemetry stack. NewContext() for trace propagation, ReportError() for structured error reporting on all failures (including script exit codes). When AZD_DEBUG=true it logs shell, command, and working dir to stderr. Script output streams straight to the console, same as running the script directly.

On how this differs from hooks:

Hooks are tied to azd lifecycle events. You define them in azure.yaml and they run as pre/post steps on provision, deploy, etc. azd exec is ad-hoc. No yaml config needed. Just azd exec npm run dev or azd exec ./setup.sh whenever you need your azd env vars available. It's the quick path for local dev, scripting, and CI tasks where hooks are overkill.

@jongio jongio force-pushed the feature/microsoft-azd-exec branch from b2cf453 to 7cf929e Compare April 2, 2026 16:16
@jongio jongio requested a review from wbreza May 4, 2026 19:35
Copy link
Copy Markdown
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

Code Review — �zd exec

PR #7400 adds �zd exec, a cross-platform command/script execution engine that runs programs with full azd environment context (env vars, Key Vault secret resolution), implemented as a core command with a new pkg/exec/scripting package.

🔴 Must Fix

1. Windows Command Injection via Shell Metacharacters

  • File: cli/azd/pkg/exec/scripting/command_builder.go (Windows path)
  • Issue: When cmd.exe /c is used, arguments are joined into a single string. Shell metacharacters (&, |, (, )) in user-provided arguments can break out and execute arbitrary commands. E.g., �zd exec "echo test & whoami" executes both commands. The inline cmd.exe path also doesn't escape % characters (unlike the script file path), allowing %VAR% environment variable expansion.
  • Contrast: The Unix path properly uses positional parameters ("", "") preventing injection.
  • Suggested fix: Escape shell metacharacters on Windows inline path, matching the existing script file path behavior.

2. PR Description / Implementation Mismatch

  • Issue: The PR description documents an extension at cli/azd/extensions/microsoft.azd.exec/ with build scripts, pipelines, extension.yaml, and 94.3% test coverage across extension packages. The actual diff shows a core command at cli/azd/cmd/exec.go with pkg/exec/scripting/. The design note mentions moving to core, but the description body was never updated.
  • Suggested fix: Update the PR description to accurately describe the core command implementation.

🟡 Should Fix

3. Secret Exposure to Subprocesses

  • File: cli/azd/cmd/exec.go (�uildChildEnv)
  • Resolved Key Vault secrets are passed to child processes. While secrets aren't leaked to the parent process via os.Setenv (good), any child command can dump them with �nv or set. Consider documenting this risk or providing an opt-in mechanism for secret resolution.

4. Exit Code Propagation Complexity

  • Exit codes go through a multi-layer wrap/unwrap chain: �xec.ExitError → scripting.ExecutionError → internal.ExitCodeError. This works correctly (validated by TestExecAction_ExitCodePropagation), but ensure this test runs cross-platform in CI.

5. Missing Windows %VAR% Expansion Test

  • File: cli/azd/cmd/exec_test.go
  • No test verifies that %WINDIR% or similar Windows-style references are not unexpectedly expanded in inline cmd.exe commands. This is the test-side companion to Finding #1.

6. Shell Detection Test Coverage

  • Shell auto-detection from file extensions (.sh → bash, .ps1 → pwsh) should have explicit tests for all supported shells on each platform, including fallback behavior when a shell isn't available.

🟢 Nitpick

7. Scope Clarity — Several foundational changes (�rrors.go, main.go, �nvironment-variables.md) aren't called out in the PR description. A brief mention would help reviewers.

8. cspell Dictionary — stretchr addition is fine (testify package author), minor housekeeping.


Overall: Core architecture is sound — proper DI patterns, clean package separation in pkg/exec/scripting/, correct exit code propagation, and secrets isolated from the parent process. The Windows command injection (#1) is the key item to address.

Copy link
Copy Markdown
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

Re-Review — �zd exec (commit a1d8ecf)

The latest commit directly addresses the blocking findings from my prior review. Security fix verified, interactive mode corrected, tests improved.

Previously Flagged → Now Resolved

  • Windows %VAR% expansion (CVE-2024-24576 class) — Fixed with %%% escaping in both file paths (buildCommand) and arguments (quoteCmdArg). Test updated to verify %%PATH%% output.
  • Stdin gatingcmd.Stdin now gated on config.Interactive with parity across both ExecuteDirect and executeCommand paths.
  • Ctrl-C in interactive modeCREATE_NEW_PROCESS_GROUP skipped when interactive=true, matching Unix Setpgid behavior. Ctrl-C now correctly reaches the child process.
  • Job Object handle leakCloseHandle added after TerminateJobObject in the kill closure.
  • Exit code test portability — Replaced shell-dependent exit 42 with a compiled Go binary (testdata/exit42.go), portable across all platforms.

Residual Items (non-blocking)

  • 🟡 Delayed expansion !VAR!! characters are not escaped in quoteCmdArg. If cmd.exe has delayed expansion enabled (SetLocal EnableDelayedExpansion), !VAR! references would expand. Low practical risk (delayed expansion is off by default), but worth a follow-up.
  • 🟡 Exit code test coverage — The updated test exercises ExecuteDirect (direct binary path) but not the full execAction.Run() → shell-dispatch path. Consider adding a companion test for shell-wrapped exit code propagation.
  • 🟡 PR description — Still describes the extension architecture (cli/azd/extensions/microsoft.azd.exec/). Should be updated to reflect the core command implementation.

Verdict

Approve — The blocking security vulnerability is resolved with correct escaping. Interactive mode, process tree management, and test portability are all properly addressed. Remaining items are improvements, not blockers.

Copy link
Copy Markdown
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

Re-Approval — azd exec (commit 718e8c6)

Single new commit since last approval: adds //nolint:gosec // G204 to the test build command in exec_test.go. This is a standard lint suppression for a known test fixture — no functional or security impact.

Standing approval unchanged. Previously noted non-blocking items remain:

  • Delayed expansion !VAR! unescaped (low practical risk — off by default)
  • Exit code test covers ExecuteDirect only, not shell-dispatch path
  • PR description still describes extension architecture

jongio and others added 11 commits May 11, 2026 16:22
Move the microsoft.azd.exec extension into azd-core as a built-in
top-level command. This provides 'azd exec' for running commands and
scripts with full azd environment context, including automatic Key
Vault secret resolution for both akvs:// and @Microsoft.KeyVault
references.

Three execution modes (selected by heuristic):
- Direct exec: azd exec python script.py (exact argv, no shell)
- Shell inline: azd exec 'echo \' (shell expansion)
- Script file: azd exec ./setup.sh (shell auto-detected from ext)

New packages:
- pkg/exec/scripting/ — execution engine, shell detection, command
  builder with Windows cmd.exe CmdLine override
- cmd/exec.go — ActionDescriptor command with --shell/-s,
  --interactive/-i flags and IoC-injected environment + keyvault

Resolves design decisions from Issue Azure#7423:
- D1: Top-level 'azd exec' (not 'azd env exec')
- D2: Stable GA (not beta)
- D3: Automatic secret resolution (matches hooks behavior)
- D4: In-process env loading via IoC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add cmd/exec_test.go with 6 tests covering:
- Environment variable injection from azd env
- Key Vault secret reference resolution (akvs://)
- Secret resolution failure error propagation
- Invalid shell validation
- Direct exec mode with multiple args
- Command metadata (Use, Args validator, flag parsing)

Update docs/environment-variables.md with azd exec section documenting
execution modes (script file, direct exec, shell inline), flags, and
automatic Key Vault secret resolution behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dleware cleanup

- Add ExitCodeError type to internal/errors.go for custom exit codes
- Update main.go to extract exit code from ExitCodeError instead of hardcoded 1
- Replace os.Exit(exitCode) in exec action with returning ExitCodeError
- Fix potential panic in logDebugInfo when cmdArgs is empty
- Make ValidShells unexported to prevent external mutation; add IsSupportedShell()
- Add test for @Microsoft.KeyVault reference format resolution
- Add test for exit code propagation via ExitCodeError

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address findings from adversarial security review:

- F1+F4+F7: Replace os.Setenv with scoped child env slice passed via
  Config.Env. Secrets never leak into the parent process or telemetry
  subprocesses. Extract buildChildEnv() as a testable method.

- F5: Escape embedded double-quotes in scriptOrPath for cmd.exe file
  execution to prevent injection via script.bat\" & calc & \"x.

- F8: Guard ExitCodeError{ExitCode:0} in main.go — only override the
  default exit code 1 when ExitCode is non-zero, preventing silent
  success on Windows TerminateProcess edge cases.

- F12: Replace partial controlCharReplacer (7 of 33 chars) with
  stripControlChars() that removes all ASCII control chars 0x00-0x1F
  and 0x7F using strings.Map.

- F13: Combine containsPrintable() with TrimSpace check in
  ExecuteInline to reject both whitespace-only and control-char-only
  input.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…eanup

F15: Prevent unsafe inline fallback when input looks like a file path.
If the input contains path separators or has a known script extension
(.sh, .ps1, .cmd, .bat, .py, etc.), error on file-not-found instead of
falling through to ExecuteInline. This stops typos like 'azd exec typo.sh'
from executing unexpected commands found on PATH.

F6: Add process tree cleanup using OS-native process groups.
- POSIX: Setpgid + SIGKILL to process group on context cancellation
- Windows: CREATE_NEW_PROCESS_GROUP + Job Object with
  JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE

Refactor runCommand to use Start()+Wait() with a cancellation goroutine
that kills the entire process tree, matching the pattern in pkg/exec/CmdTree.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Run gofmt on all scripting package files
- Add //nolint:gosec for G101 (test credential constants) and G703 (test path traversal)
- Update TestUsage snapshot for new --fail-on-prompt global flag from main

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
gosec G101 reports on the map literal line, not the value line.
Extract the akvs:// string to a variable so the nolint:gosec
directive is on the same line as the flagged string literal,
matching the pattern in TestExecAction_ResolvesSecretReferences.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…windows.go

Add log.Printf at all four best-effort Job Object setup fallback points
(CreateJobObject, SetInformationJobObject, OpenProcess, AssignProcessToJobObject)
to aid diagnosis of orphaned child processes on Windows.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…teractive, fix Ctrl-C in interactive mode, strengthen exit-code test

- Escape % as %% in cmd.exe paths and args to prevent env var expansion (CVE-2024-24576 class)
- Gate cmd.Stdin on e.config.Interactive in ExecuteDirect (parity with executeCommand)
- Skip CREATE_NEW_PROCESS_GROUP when interactive=true (match Unix Setpgid behavior)
- Close Job Object handle after TerminateJobObject in kill closure
- Replace shell-dependent exit-code test with portable compiled binary approach

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jongio
Copy link
Copy Markdown
Member Author

jongio commented May 12, 2026

Review Comment Resolution Summary

Rebased onto current main (063282153) and verified all 8 unresolved review threads. Here's the resolution status:

✅ Confirmed Fixed

Thread Issue Fix Commit
1 cmd.exe %VAR% expansion in quoteCmdArg 0bb3f04 — escapes %%% via strings.ReplaceAll
2 ExecuteDirect ignores -i flag (stdin not gated) 0bb3f04cmd.Stdin = os.Stdin gated on Interactive
6 CREATE_NEW_PROCESS_GROUP breaks Ctrl-C in interactive 0bb3f04 — flag skipped when interactive == true
7 quoteCmdArg % passthrough 0bb3f04 — same fix as thread 1
8 Exit-code test no-op on Windows 0bb3f04 — test compiles exit42.go, asserts exit code 42
4 Job Object handle leak + silent fallback 0bb3f04 + 2761a54 — handle closed on all paths, log.Printf at every fallback

⚠️ Go stdlib limitation (unfixable)

Thread Issue Status
5 Race between cmd.Start() and AssignProcessToJobObject Go os/exec doesn't expose CREATE_SUSPENDED. Standard pattern used by Docker/containerd. Grandchild spawned in the gap is unlikely and mitigated by KILL_ON_JOB_CLOSE on the parent.

💬 Disagree — intentional behavior

Thread Issue Status
3 Extensionless file dispatch via default shell This is intentional — unknown file types are dispatched through the platform default shell, matching the behavior of ./script on Unix (which uses the shell/shebang). Users running ELF binaries should use azd exec ./mybinary arg1 which routes through ExecuteDirect.

@jongio jongio force-pushed the feature/microsoft-azd-exec branch from c227033 to 6bf1f01 Compare May 12, 2026 02:13
jongio and others added 2 commits May 11, 2026 19:20
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Global flags changed upstream (removed --fail-on-prompt, updated --no-prompt wording).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-sdk
Copy link
Copy Markdown
Collaborator

Azure Dev CLI Install Instructions

Install scripts

MacOS/Linux

May elevate using sudo on some platforms and configurations

bash:

curl -fsSL https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/7400/uninstall-azd.sh | bash;
curl -fsSL https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/7400/install-azd.sh | bash -s -- --base-url https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/7400 --version '' --verbose --skip-verify

pwsh:

Invoke-RestMethod 'https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/7400/uninstall-azd.ps1' -OutFile uninstall-azd.ps1; ./uninstall-azd.ps1
Invoke-RestMethod 'https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/7400/install-azd.ps1' -OutFile install-azd.ps1; ./install-azd.ps1 -BaseUrl 'https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/7400' -Version '' -SkipVerify -Verbose

Windows

PowerShell install

powershell -c "Set-ExecutionPolicy Bypass Process; irm 'https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/7400/uninstall-azd.ps1' > uninstall-azd.ps1; ./uninstall-azd.ps1;"
powershell -c "Set-ExecutionPolicy Bypass Process; irm 'https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/7400/install-azd.ps1' > install-azd.ps1; ./install-azd.ps1 -BaseUrl 'https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/7400' -Version '' -SkipVerify -Verbose;"

MSI install

powershell -c "irm 'https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/7400/azd-windows-amd64.msi' -OutFile azd-windows-amd64.msi; msiexec /i azd-windows-amd64.msi /qn"

Standalone Binary

MSI

Documentation

learn.microsoft.com documentation

title: Azure Developer CLI reference
description: This article explains the syntax and parameters for the various Azure Developer CLI commands.
author: alexwolfmsft
ms.author: alexwolf
ms.date: 05/12/2026
ms.service: azure-dev-cli
ms.topic: conceptual
ms.custom: devx-track-azdevcli

Azure Developer CLI reference

This article explains the syntax and parameters for the various Azure Developer CLI commands.

azd

The Azure Developer CLI (azd) is an open-source tool that helps onboard and manage your project on Azure

Options

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
      --docs                 Opens the documentation for azd in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for azd.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

  • azd add: Add a component to your project.
  • azd auth: Authenticate with Azure.
  • azd completion: Generate shell completion scripts.
  • azd config: Manage azd configurations (ex: default Azure subscription, location).
  • azd copilot: Manage GitHub Copilot agent settings. (Preview)
  • azd deploy: Deploy your project code to Azure.
  • azd down: Delete your project's Azure resources.
  • azd env: Manage environments (ex: default environment, environment variables).
  • azd exec: Execute commands and scripts with azd environment context.
  • azd extension: Manage azd extensions.
  • azd hooks: Develop, test and run hooks for a project.
  • azd infra: Manage your Infrastructure as Code (IaC).
  • azd init: Initialize a new application.
  • azd mcp: Manage Model Context Protocol (MCP) server. (Alpha)
  • azd monitor: Monitor a deployed project.
  • azd package: Packages the project's code to be deployed to Azure.
  • azd pipeline: Manage and configure your deployment pipelines.
  • azd provision: Provision Azure resources for your project.
  • azd publish: Publish a service to a container registry.
  • azd restore: Restores the project's dependencies.
  • azd show: Display information about your project and its resources.
  • azd template: Find and view template details.
  • azd up: Provision and deploy your project to Azure with a single command.
  • azd update: Updates azd to the latest version.
  • azd version: Print the version number of Azure Developer CLI.

azd add

Add a component to your project.

azd add [flags]

Options

      --docs   Opens the documentation for azd add in your web browser.
  -h, --help   Gets help for add.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd auth

Authenticate with Azure.

Options

      --docs   Opens the documentation for azd auth in your web browser.
  -h, --help   Gets help for auth.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd auth login

Log in to Azure.

Synopsis

Log in to Azure.

When run without any arguments, log in interactively using a browser. To log in using a device code, pass
--use-device-code.

To log in as a service principal, pass --client-id and --tenant-id as well as one of: --client-secret,
--client-certificate, or --federated-credential-provider.

To log in using a managed identity, pass --managed-identity, which will use the system assigned managed identity.
To use a user assigned managed identity, pass --client-id in addition to --managed-identity with the client id of
the user assigned managed identity you wish to use.

azd auth login [flags]

Options

      --check-status                           Checks the log-in status instead of logging in.
      --client-certificate string              The path to the client certificate for the service principal to authenticate with.
      --client-id string                       The client id for the service principal to authenticate with.
      --client-secret string                   The client secret for the service principal to authenticate with. Set to the empty string to read the value from the console.
      --docs                                   Opens the documentation for azd auth login in your web browser.
      --federated-credential-provider string   The provider to use to acquire a federated token to authenticate with. Supported values: github, azure-pipelines, oidc
  -h, --help                                   Gets help for login.
      --managed-identity                       Use a managed identity to authenticate.
      --redirect-port int                      Choose the port to be used as part of the redirect URI during interactive login.
      --tenant-id string                       The tenant id or domain name to authenticate with.
      --use-device-code[=true]                 When true, log in by using a device code instead of a browser.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd auth logout

Log out of Azure.

Synopsis

Log out of Azure

azd auth logout [flags]

Options

      --docs   Opens the documentation for azd auth logout in your web browser.
  -h, --help   Gets help for logout.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd auth status

Show the current authentication status.

Synopsis

Display whether you are logged in to Azure and the associated account information.

azd auth status [flags]

Options

      --docs   Opens the documentation for azd auth status in your web browser.
  -h, --help   Gets help for status.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd completion

Generate shell completion scripts.

Synopsis

Generate shell completion scripts for azd.

The completion command allows you to generate autocompletion scripts for your shell,
currently supports bash, zsh, fish and PowerShell.

See each sub-command's help for details on how to use the generated script.

Options

      --docs   Opens the documentation for azd completion in your web browser.
  -h, --help   Gets help for completion.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd completion bash

Generate bash completion script.

azd completion bash

Options

      --docs   Opens the documentation for azd completion bash in your web browser.
  -h, --help   Gets help for bash.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd completion fig

Generate Fig autocomplete spec.

azd completion fig

Options

      --docs   Opens the documentation for azd completion fig in your web browser.
  -h, --help   Gets help for fig.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd completion fish

Generate fish completion script.

azd completion fish

Options

      --docs   Opens the documentation for azd completion fish in your web browser.
  -h, --help   Gets help for fish.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd completion powershell

Generate PowerShell completion script.

azd completion powershell

Options

      --docs   Opens the documentation for azd completion powershell in your web browser.
  -h, --help   Gets help for powershell.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd completion zsh

Generate zsh completion script.

azd completion zsh

Options

      --docs   Opens the documentation for azd completion zsh in your web browser.
  -h, --help   Gets help for zsh.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd config

Manage azd configurations (ex: default Azure subscription, location).

Synopsis

Manage the Azure Developer CLI user configuration, which includes your default Azure subscription and location.

Available since azure-dev-cli_0.4.0-beta.1.

The easiest way to configure azd for the first time is to run azd init. The subscription and location you select will be stored in the config.json file located in the config directory. To configure azd anytime afterwards, you'll use azd config set.

The default value of the config directory is:

  • $HOME/.azd on Linux and macOS
  • %USERPROFILE%.azd on Windows

The configuration directory can be overridden by specifying a path in the AZD_CONFIG_DIR environment variable.

Options

      --docs   Opens the documentation for azd config in your web browser.
  -h, --help   Gets help for config.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd config get

Gets a configuration.

Synopsis

Gets a configuration in the configuration path.

The default value of the config directory is:

  • $HOME/.azd on Linux and macOS
  • %USERPROFILE%\.azd on Windows

The configuration directory can be overridden by specifying a path in the AZD_CONFIG_DIR environment variable.

azd config get <path> [flags]

Options

      --docs   Opens the documentation for azd config get in your web browser.
  -h, --help   Gets help for get.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd config list-alpha

Display the list of available features in alpha stage.

azd config list-alpha [flags]

Options

      --docs   Opens the documentation for azd config list-alpha in your web browser.
  -h, --help   Gets help for list-alpha.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd config options

List all available configuration settings.

Synopsis

List all possible configuration settings that can be set with azd, including descriptions and allowed values.

azd config options [flags]

Options

      --docs   Opens the documentation for azd config options in your web browser.
  -h, --help   Gets help for options.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd config reset

Resets configuration to default.

Synopsis

Resets all configuration in the configuration path.

The default value of the config directory is:

  • $HOME/.azd on Linux and macOS
  • %USERPROFILE%\.azd on Windows

The configuration directory can be overridden by specifying a path in the AZD_CONFIG_DIR environment variable to the default.

azd config reset [flags]

Options

      --docs    Opens the documentation for azd config reset in your web browser.
  -f, --force   Force reset without confirmation.
  -h, --help    Gets help for reset.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd config set

Sets a configuration.

Synopsis

Sets a configuration in the configuration path.

The default value of the config directory is:

  • $HOME/.azd on Linux and macOS
  • %USERPROFILE%\.azd on Windows

The configuration directory can be overridden by specifying a path in the AZD_CONFIG_DIR environment variable.

azd config set <path> <value> [flags]

Examples

azd config set defaults.subscription <yourSubscriptionID>
azd config set defaults.location eastus

Options

      --docs   Opens the documentation for azd config set in your web browser.
  -h, --help   Gets help for set.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd config show

Show all the configuration values.

Synopsis

Show all configuration values in the configuration path.

The default value of the config directory is:

  • $HOME/.azd on Linux and macOS
  • %USERPROFILE%\.azd on Windows

The configuration directory can be overridden by specifying a path in the AZD_CONFIG_DIR environment variable.

azd config show [flags]

Options

      --docs   Opens the documentation for azd config show in your web browser.
  -h, --help   Gets help for show.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd config unset

Unsets a configuration.

Synopsis

Removes a configuration in the configuration path.

The default value of the config directory is:

  • $HOME/.azd on Linux and macOS
  • %USERPROFILE%\.azd on Windows

The configuration directory can be overridden by specifying a path in the AZD_CONFIG_DIR environment variable.

azd config unset <path> [flags]

Examples

azd config unset defaults.location

Options

      --docs   Opens the documentation for azd config unset in your web browser.
  -h, --help   Gets help for unset.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd copilot

Manage GitHub Copilot agent settings. (Preview)

Options

      --docs   Opens the documentation for azd copilot in your web browser.
  -h, --help   Gets help for copilot.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd copilot consent

Manage tool consent.

Synopsis

Manage consent rules for tool execution.

Options

      --docs   Opens the documentation for azd copilot consent in your web browser.
  -h, --help   Gets help for consent.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd copilot consent grant

Grant consent trust rules.

Synopsis

Grant trust rules for tools and servers.

This command creates consent rules that allow tools to execute
without prompting for permission. You can specify different permission
levels and scopes for the rules.

Examples:
Grant always permission to all tools globally
azd copilot consent grant --global --permission always

Grant project permission to a specific tool with read-only scope
azd copilot consent grant --server my-server --tool my-tool --permission project --scope read-only

azd copilot consent grant [flags]

Options

      --action string       Action type: 'all' or 'readonly' (default "all")
      --docs                Opens the documentation for azd copilot consent grant in your web browser.
      --global              Apply globally to all servers
  -h, --help                Gets help for grant.
      --operation string    Operation type: 'tool' or 'sampling' (default "tool")
      --permission string   Permission: 'allow', 'deny', or 'prompt' (default "allow")
      --scope string        Rule scope: 'global', or 'project' (default "global")
      --server string       Server name
      --tool string         Specific tool name (requires --server)

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd copilot consent list

List consent rules.

Synopsis

List all consent rules for tools.

azd copilot consent list [flags]

Options

      --action string       Action type to filter by (all, readonly)
      --docs                Opens the documentation for azd copilot consent list in your web browser.
  -h, --help                Gets help for list.
      --operation string    Operation to filter by (tool, sampling)
      --permission string   Permission to filter by (allow, deny, prompt)
      --scope string        Consent scope to filter by (global, project). If not specified, lists rules from all scopes.
      --target string       Specific target to operate on (server/tool format)

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd copilot consent revoke

Revoke consent rules.

Synopsis

Revoke consent rules for tools.

azd copilot consent revoke [flags]

Options

      --action string       Action type to filter by (all, readonly)
      --docs                Opens the documentation for azd copilot consent revoke in your web browser.
  -h, --help                Gets help for revoke.
      --operation string    Operation to filter by (tool, sampling)
      --permission string   Permission to filter by (allow, deny, prompt)
      --scope string        Consent scope to filter by (global, project). If not specified, revokes rules from all scopes.
      --target string       Specific target to operate on (server/tool format)

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd deploy

Deploy your project code to Azure.

azd deploy <service> [flags]

Options

      --all                   Deploys all services that are listed in azure.yaml
      --docs                  Opens the documentation for azd deploy in your web browser.
  -e, --environment string    The name of the environment to use.
      --from-package string   Deploys the packaged service located at the provided path. Supports zipped file packages (file path) or container images (image tag).
  -h, --help                  Gets help for deploy.
      --timeout int           Maximum time in seconds for azd to wait for each service deployment. This stops azd from waiting but does not cancel the Azure-side deployment. (default: 1200) (default 1200)

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd down

Delete your project's Azure resources.

azd down [<layer>] [flags]

Options

      --docs                 Opens the documentation for azd down in your web browser.
  -e, --environment string   The name of the environment to use.
      --force                Does not require confirmation before it deletes resources.
  -h, --help                 Gets help for down.
      --purge                Does not require confirmation before it permanently deletes resources that are soft-deleted by default (for example, key vaults).

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd env

Manage environments (ex: default environment, environment variables).

Options

      --docs   Opens the documentation for azd env in your web browser.
  -h, --help   Gets help for env.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd env config

Manage environment configuration (ex: stored in .azure/{environment}/config.json).

Options

      --docs   Opens the documentation for azd env config in your web browser.
  -h, --help   Gets help for config.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd env config get

Gets a configuration value from the environment.

Synopsis

Gets a configuration value from the environment's config.json file.

azd env config get <path> [flags]

Options

      --docs                 Opens the documentation for azd env config get in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for get.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd env config set

Sets a configuration value in the environment.

Synopsis

Sets a configuration value in the environment's config.json file.

Values are automatically parsed as JSON types when possible. Booleans (true/false),
numbers (42, 3.14), arrays ([...]), and objects ({...}) are stored with their native
JSON types. Plain text values are stored as strings. To force a JSON-typed value to be
stored as a string, wrap it in JSON quotes (e.g. '"true"' or '"8080"').

azd env config set <path> <value> [flags]

Examples

azd env config set myapp.endpoint https://example.com
azd env config set myapp.debug true
azd env config set myapp.count 42
azd env config set infra.parameters.tags '{"env":"dev"}'
azd env config set myapp.port '"8080"'

Options

      --docs                 Opens the documentation for azd env config set in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for set.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd env config unset

Unsets a configuration value in the environment.

Synopsis

Removes a configuration value from the environment's config.json file.

azd env config unset <path> [flags]

Examples

azd env config unset myapp.endpoint

Options

      --docs                 Opens the documentation for azd env config unset in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for unset.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd env get-value

Get specific environment value.

azd env get-value <keyName> [flags]

Options

      --docs                 Opens the documentation for azd env get-value in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for get-value.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

  • azd env: Manage environments (ex: default environment, environment variables).
  • Back to top

azd env get-values

Get all environment values.

azd env get-values [flags]

Options

      --docs                 Opens the documentation for azd env get-values in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for get-values.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

  • azd env: Manage environments (ex: default environment, environment variables).
  • Back to top

azd env list

List environments.

azd env list [flags]

Options

      --docs   Opens the documentation for azd env list in your web browser.
  -h, --help   Gets help for list.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

  • azd env: Manage environments (ex: default environment, environment variables).
  • Back to top

azd env new

Create a new environment and set it as the default.

azd env new <environment> [flags]

Options

      --docs                  Opens the documentation for azd env new in your web browser.
  -h, --help                  Gets help for new.
  -l, --location string       Azure location for the new environment
      --subscription string   ID of an Azure subscription to use for the new environment

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

  • azd env: Manage environments (ex: default environment, environment variables).
  • Back to top

azd env refresh

Refresh environment values by using information from a previous infrastructure provision.

azd env refresh <environment> [flags]

Options

      --docs                 Opens the documentation for azd env refresh in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for refresh.
      --hint string          Hint to help identify the environment to refresh
      --layer string         Provisioning layer to refresh the environment from.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

  • azd env: Manage environments (ex: default environment, environment variables).
  • Back to top

azd env remove

Remove an environment.

azd env remove <environment> [flags]

Options

      --docs                 Opens the documentation for azd env remove in your web browser.
  -e, --environment string   The name of the environment to use.
      --force                Skips confirmation before performing removal.
  -h, --help                 Gets help for remove.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

  • azd env: Manage environments (ex: default environment, environment variables).
  • Back to top

azd env select

Set the default environment.

azd env select [<environment>] [flags]

Options

      --docs   Opens the documentation for azd env select in your web browser.
  -h, --help   Gets help for select.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

  • azd env: Manage environments (ex: default environment, environment variables).
  • Back to top

azd env set

Set one or more environment values.

Synopsis

Set one or more environment values using key-value pairs or by loading from a .env formatted file.

azd env set [<key> <value>] | [<key>=<value> ...] | [--file <filepath>] [flags]

Options

      --docs                 Opens the documentation for azd env set in your web browser.
  -e, --environment string   The name of the environment to use.
      --file string          Path to .env formatted file to load environment values from.
  -h, --help                 Gets help for set.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

  • azd env: Manage environments (ex: default environment, environment variables).
  • Back to top

azd env set-secret

Set a name as a reference to a Key Vault secret in the environment.

Synopsis

You can either create a new Key Vault secret or select an existing one.
The provided name is the key for the .env file which holds the secret reference to the Key Vault secret.

azd env set-secret <name> [flags]

Options

      --docs                 Opens the documentation for azd env set-secret in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for set-secret.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

  • azd env: Manage environments (ex: default environment, environment variables).
  • Back to top

azd exec

Execute commands and scripts with azd environment context.

Synopsis

Execute commands and scripts with full access to azd environment variables.

Commands are run with the azd environment loaded into the child process.
Multiple arguments use direct process execution (no shell wrapping).
A single quoted argument uses shell inline execution.

Examples:
azd exec python script.py # Direct exec (exact argv)
azd exec npm run dev # Direct exec (no shell)
azd exec -- python app.py --port 8000 # Direct exec with flags
azd exec 'echo $AZURE_ENV_NAME' # Inline via shell
azd exec ./setup.sh # Execute script file
azd exec --shell pwsh "Write-Host 'Hello'" # Inline PowerShell
azd exec ./build.sh -- --verbose # Script with args
azd exec -i ./init.sh # Interactive mode

azd exec [command] [args...] [-- script-args...] [flags]

Options

      --docs                 Opens the documentation for azd exec in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for exec.
  -i, --interactive          Run in interactive mode (connect stdin)
  -s, --shell string         Shell to use (bash, sh, zsh, pwsh, powershell, cmd). Auto-detected if not specified.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd extension

Manage azd extensions.

Options

      --docs   Opens the documentation for azd extension in your web browser.
  -h, --help   Gets help for extension.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd extension install

Installs specified extensions.

azd extension install <extension-id> [flags]

Options

      --docs             Opens the documentation for azd extension install in your web browser.
  -f, --force            Force installation, including downgrades and reinstalls
  -h, --help             Gets help for install.
  -s, --source string    The extension source to use for installs
  -v, --version string   The version of the extension to install

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd extension list

List available extensions.

azd extension list [--installed] [flags]

Options

      --docs            Opens the documentation for azd extension list in your web browser.
  -h, --help            Gets help for list.
      --installed       List installed extensions
      --source string   Filter extensions by source
      --tags strings    Filter extensions by tags

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd extension show

Show details for a specific extension.

azd extension show <extension-id> [flags]

Options

      --docs            Opens the documentation for azd extension show in your web browser.
  -h, --help            Gets help for show.
  -s, --source string   The extension source to use.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd extension source

View and manage extension sources

Options

      --docs   Opens the documentation for azd extension source in your web browser.
  -h, --help   Gets help for source.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd extension source add

Add an extension source with the specified name

azd extension source add [flags]

Options

      --docs              Opens the documentation for azd extension source add in your web browser.
  -h, --help              Gets help for add.
  -l, --location string   The location of the extension source
  -n, --name string       The name of the extension source
  -t, --type string       The type of the extension source. Supported types are 'file' and 'url'

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd extension source list

List extension sources

azd extension source list [flags]

Options

      --docs   Opens the documentation for azd extension source list in your web browser.
  -h, --help   Gets help for list.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd extension source remove

Remove an extension source with the specified name

azd extension source remove <name> [flags]

Options

      --docs   Opens the documentation for azd extension source remove in your web browser.
  -h, --help   Gets help for remove.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd extension source validate

Validate an extension source's registry.json file.

Synopsis

Validate an extension source's registry.json file.

Accepts a source name (from 'azd extension source list'), a local file path,
or a URL. Checks required fields, valid capabilities, semver version format,
platform artifact structure, and extension ID format.

azd extension source validate <name-or-path-or-url> [flags]

Options

      --docs     Opens the documentation for azd extension source validate in your web browser.
  -h, --help     Gets help for validate.
      --strict   Enable strict validation (require checksums)

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd extension uninstall

Uninstall specified extensions.

azd extension uninstall [extension-id] [flags]

Options

      --all    Uninstall all installed extensions
      --docs   Opens the documentation for azd extension uninstall in your web browser.
  -h, --help   Gets help for uninstall.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd extension upgrade

Upgrade installed extensions to the latest version.

Synopsis

Upgrade one or more installed extensions.

By default, uses the stored registry source for each extension. If the stored
source is unavailable, falls back to the main (azd) registry. Extensions that
were installed from a non-main registry (e.g., dev) are automatically promoted
to the main registry when a newer version is available there.

Use --source to explicitly override the registry source for the upgrade. Use
--all to upgrade all installed extensions in a single batch; failures in one
extension do not prevent the remaining extensions from being upgraded.

Use --output json for a structured report of all upgrade results.

azd extension upgrade [extension-id] [flags]

Options

      --all              Upgrade all installed extensions
      --docs             Opens the documentation for azd extension upgrade in your web browser.
  -h, --help             Gets help for upgrade.
  -s, --source string    The extension source to use for upgrades
  -v, --version string   The version of the extension to upgrade to

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd hooks

Develop, test and run hooks for a project.

Options

      --docs   Opens the documentation for azd hooks in your web browser.
  -h, --help   Gets help for hooks.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd hooks run

Runs the specified hook for the project, provisioning layers, and services

azd hooks run <name> [flags]

Options

      --docs                 Opens the documentation for azd hooks run in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for run.
      --layer string         Only runs hooks for the specified provisioning layer.
      --platform string      Forces hooks to run for the specified platform.
      --service string       Only runs hooks for the specified service.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd infra

Manage your Infrastructure as Code (IaC).

Options

      --docs   Opens the documentation for azd infra in your web browser.
  -h, --help   Gets help for infra.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd infra generate

Write IaC for your project to disk, allowing you to manually manage it.

azd infra generate [flags]

Options

      --docs                 Opens the documentation for azd infra generate in your web browser.
  -e, --environment string   The name of the environment to use.
      --force                Overwrite any existing files without prompting
  -h, --help                 Gets help for generate.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd init

Initialize a new application.

Synopsis

Initialize a new application.

When used with --template, a new directory is created (named after the template)
and the project is initialized inside it — similar to git clone.
Pass "." as the directory to initialize in the current directory instead.

azd init [flags]

Options

  -b, --branch string         The template branch to initialize from. Must be used with a template argument (--template or -t).
      --docs                  Opens the documentation for azd init in your web browser.
  -e, --environment string    The name of the environment to use.
  -f, --filter strings        The tag(s) used to filter template results. Supports comma-separated values.
      --from-code             Initializes a new application from your existing code.
  -h, --help                  Gets help for init.
  -l, --location string       Azure location for the new environment
  -m, --minimal               Initializes a minimal project.
  -s, --subscription string   ID of an Azure subscription to use for the new environment
  -t, --template string       Initializes a new application from a template. You can use a Full URI, <owner>/<repository>, <repository> if it's part of the azure-samples organization, or a local directory path (./dir, ../dir, or absolute path).
      --up                    Provision and deploy to Azure after initializing the project from a template.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd mcp

Manage Model Context Protocol (MCP) server. (Alpha)

Options

      --docs   Opens the documentation for azd mcp in your web browser.
  -h, --help   Gets help for mcp.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd mcp start

Starts the MCP server.

Synopsis

Starts the Model Context Protocol (MCP) server.

This command starts an MCP server that can be used by MCP clients to access
azd functionality through the Model Context Protocol interface.

azd mcp start [flags]

Options

      --docs   Opens the documentation for azd mcp start in your web browser.
  -h, --help   Gets help for start.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd monitor

Monitor a deployed project.

azd monitor [flags]

Options

      --docs                 Opens the documentation for azd monitor in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for monitor.
      --live                 Open a browser to Application Insights Live Metrics. Live Metrics is currently not supported for Python apps.
      --logs                 Open a browser to Application Insights Logs.
      --overview             Open a browser to Application Insights Overview Dashboard.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd package

Packages the project's code to be deployed to Azure.

azd package <service> [flags]

Options

      --all                  Packages all services that are listed in azure.yaml
      --docs                 Opens the documentation for azd package in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for package.
      --output-path string   File or folder path where the generated packages will be saved.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd pipeline

Manage and configure your deployment pipelines.

Options

      --docs   Opens the documentation for azd pipeline in your web browser.
  -h, --help   Gets help for pipeline.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd pipeline config

Configure your deployment pipeline to connect securely to Azure. (Beta)

azd pipeline config [flags]

Options

  -m, --applicationServiceManagementReference string   Service Management Reference. References application or service contact information from a Service or Asset Management database. This value must be a Universally Unique Identifier (UUID). You can set this value globally by running azd config set pipeline.config.applicationServiceManagementReference <UUID>.
      --auth-type string                               The authentication type used between the pipeline provider and Azure for deployment (Only valid for GitHub provider). Valid values: federated, client-credentials.
      --docs                                           Opens the documentation for azd pipeline config in your web browser.
  -e, --environment string                             The name of the environment to use.
  -h, --help                                           Gets help for config.
      --principal-id string                            The client id of the service principal to use to grant access to Azure resources as part of the pipeline.
      --principal-name string                          The name of the service principal to use to grant access to Azure resources as part of the pipeline.
      --principal-role stringArray                     The roles to assign to the service principal. By default the service principal will be granted the Contributor and User Access Administrator roles. (default [Contributor,User Access Administrator])
      --provider string                                The pipeline provider to use (github for Github Actions and azdo for Azure Pipelines).
      --remote-name string                             The name of the git remote to configure the pipeline to run on. (default "origin")

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd provision

Provision Azure resources for your project.

azd provision [<layer>] [flags]

Options

      --docs                  Opens the documentation for azd provision in your web browser.
  -e, --environment string    The name of the environment to use.
  -h, --help                  Gets help for provision.
  -l, --location string       Azure location for the new environment
      --no-state              (Bicep only) Forces a fresh deployment based on current Bicep template files, ignoring any stored deployment state.
      --preview               Preview changes to Azure resources.
      --subscription string   ID of an Azure subscription to use for the new environment

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd publish

Publish a service to a container registry.

azd publish <service> [flags]

Options

      --all                   Publishes all services that are listed in azure.yaml
      --docs                  Opens the documentation for azd publish in your web browser.
  -e, --environment string    The name of the environment to use.
      --from-package string   Publishes the service from a container image (image tag).
  -h, --help                  Gets help for publish.
      --to string             The target container image in the form '[registry/]repository[:tag]' to publish to.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd restore

Restores the project's dependencies.

azd restore <service> [flags]

Options

      --all                  Restores all services that are listed in azure.yaml
      --docs                 Opens the documentation for azd restore in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for restore.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd show

Display information about your project and its resources.

azd show [resource-name|resource-id] [flags]

Options

      --docs                 Opens the documentation for azd show in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for show.
      --show-secrets         Unmask secrets in output.

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd template

Find and view template details.

Options

      --docs   Opens the documentation for azd template in your web browser.
  -h, --help   Gets help for template.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd template list

Show list of sample azd templates. (Beta)

azd template list [flags]

Options

      --docs             Opens the documentation for azd template list in your web browser.
  -f, --filter strings   The tag(s) used to filter template results. Supports comma-separated values.
  -h, --help             Gets help for list.
  -s, --source string    Filters templates by source.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd template show

Show details for a given template. (Beta)

azd template show <template> [flags]

Options

      --docs   Opens the documentation for azd template show in your web browser.
  -h, --help   Gets help for show.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd template source

View and manage template sources. (Beta)

Options

      --docs   Opens the documentation for azd template source in your web browser.
  -h, --help   Gets help for source.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd template source add

Adds an azd template source with the specified key. (Beta)

Synopsis

The key can be any value that uniquely identifies the template source, with well-known values being:
・default: Default templates
・awesome-azd: Templates from https://aka.ms/awesome-azd

azd template source add <key> [flags]

Options

      --docs              Opens the documentation for azd template source add in your web browser.
  -h, --help              Gets help for add.
  -l, --location string   Location of the template source. Required when using type flag.
  -n, --name string       Display name of the template source.
  -t, --type string       Kind of the template source. Supported types are 'file', 'url' and 'gh'.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd template source list

Lists the configured azd template sources. (Beta)

azd template source list [flags]

Options

      --docs   Opens the documentation for azd template source list in your web browser.
  -h, --help   Gets help for list.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd template source remove

Removes the specified azd template source (Beta)

azd template source remove <key> [flags]

Options

      --docs   Opens the documentation for azd template source remove in your web browser.
  -h, --help   Gets help for remove.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd up

Provision and deploy your project to Azure with a single command.

azd up [flags]

Options

      --docs                  Opens the documentation for azd up in your web browser.
  -e, --environment string    The name of the environment to use.
  -h, --help                  Gets help for up.
  -l, --location string       Azure location for the new environment
      --subscription string   ID of an Azure subscription to use for the new environment

Options inherited from parent commands

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd update

Updates azd to the latest version.

azd update [flags]

Options

      --channel string             Update channel: stable or daily.
      --check-interval-hours int   Override the update check interval in hours.
      --docs                       Opens the documentation for azd update in your web browser.
  -h, --help                       Gets help for update.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

azd version

Print the version number of Azure Developer CLI.

azd version [flags]

Options

      --docs   Opens the documentation for azd version in your web browser.
  -h, --help   Gets help for version.

Options inherited from parent commands

  -C, --cwd string           Sets the current working directory.
      --debug                Enables debugging and diagnostics logging.
  -e, --environment string   The name of the environment to use.
      --no-prompt            Runs without prompts. Uses existing values; fails if any required value or decision cannot be resolved automatically.

See also

@jongio jongio merged commit af7011e into Azure:main May 12, 2026
31 checks passed
@jongio jongio deleted the feature/microsoft-azd-exec branch May 12, 2026 04:50
jongio added a commit to jongio/azd-extensions that referenced this pull request May 18, 2026
azd exec has been merged into core Azure Developer CLI as microsoft.azd.exec
via Azure/azure-dev#7400. Remove from registry and website.

- Remove jongio.azd.exec from registry.json
- Remove exec extension card from website
- Update copy from 4 extensions to 3
- Remove exec from install commands

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
vhvb1989 pushed a commit that referenced this pull request May 18, 2026
…ap (#8221)

The changelog generation skill missed PR #7400 (azd exec) in the 1.25.1
release notes. The PR was in the commit range but was silently skipped
during processing.

Changes:
- Add #7400 entry to CHANGELOG.md under 1.25.1 Features Added
- Add reverse cross-reference (coverage check) to changelog skill Step 5
  that verifies every commit in range is either included or has an
  explicit exclusion reason, preventing silent omissions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI pushed a commit that referenced this pull request May 21, 2026
…ntext (#7400)

* feat: add azd exec as a core command

Move the microsoft.azd.exec extension into azd-core as a built-in
top-level command. This provides 'azd exec' for running commands and
scripts with full azd environment context, including automatic Key
Vault secret resolution for both akvs:// and @Microsoft.KeyVault
references.

Three execution modes (selected by heuristic):
- Direct exec: azd exec python script.py (exact argv, no shell)
- Shell inline: azd exec 'echo \' (shell expansion)
- Script file: azd exec ./setup.sh (shell auto-detected from ext)

New packages:
- pkg/exec/scripting/ — execution engine, shell detection, command
  builder with Windows cmd.exe CmdLine override
- cmd/exec.go — ActionDescriptor command with --shell/-s,
  --interactive/-i flags and IoC-injected environment + keyvault

Resolves design decisions from Issue #7423:
- D1: Top-level 'azd exec' (not 'azd env exec')
- D2: Stable GA (not beta)
- D3: Automatic secret resolution (matches hooks behavior)
- D4: In-process env loading via IoC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* test/docs: add exec action tests and update environment docs

Add cmd/exec_test.go with 6 tests covering:
- Environment variable injection from azd env
- Key Vault secret reference resolution (akvs://)
- Secret resolution failure error propagation
- Invalid shell validation
- Direct exec mode with multiple args
- Command metadata (Use, Args validator, flag parsing)

Update docs/environment-variables.md with azd exec section documenting
execution modes (script file, direct exec, shell inline), flags, and
automatic Key Vault secret resolution behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: replace os.Exit in exec action with ExitCodeError for proper middleware cleanup

- Add ExitCodeError type to internal/errors.go for custom exit codes
- Update main.go to extract exit code from ExitCodeError instead of hardcoded 1
- Replace os.Exit(exitCode) in exec action with returning ExitCodeError
- Fix potential panic in logDebugInfo when cmdArgs is empty
- Make ValidShells unexported to prevent external mutation; add IsSupportedShell()
- Add test for @Microsoft.KeyVault reference format resolution
- Add test for exit code propagation via ExitCodeError

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* security: scope child env, harden cmd.exe quoting, guard exit code

Address findings from adversarial security review:

- F1+F4+F7: Replace os.Setenv with scoped child env slice passed via
  Config.Env. Secrets never leak into the parent process or telemetry
  subprocesses. Extract buildChildEnv() as a testable method.

- F5: Escape embedded double-quotes in scriptOrPath for cmd.exe file
  execution to prevent injection via script.bat\" & calc & \"x.

- F8: Guard ExitCodeError{ExitCode:0} in main.go — only override the
  default exit code 1 when ExitCode is non-zero, preventing silent
  success on Windows TerminateProcess edge cases.

- F12: Replace partial controlCharReplacer (7 of 33 chars) with
  stripControlChars() that removes all ASCII control chars 0x00-0x1F
  and 0x7F using strings.Map.

- F13: Combine containsPrintable() with TrimSpace check in
  ExecuteInline to reject both whitespace-only and control-char-only
  input.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* security: prevent inline fallback for file paths, add process tree cleanup

F15: Prevent unsafe inline fallback when input looks like a file path.
If the input contains path separators or has a known script extension
(.sh, .ps1, .cmd, .bat, .py, etc.), error on file-not-found instead of
falling through to ExecuteInline. This stops typos like 'azd exec typo.sh'
from executing unexpected commands found on PATH.

F6: Add process tree cleanup using OS-native process groups.
- POSIX: Setpgid + SIGKILL to process group on context cancellation
- Windows: CREATE_NEW_PROCESS_GROUP + Job Object with
  JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE

Refactor runCommand to use Start()+Wait() with a cancellation goroutine
that kills the entire process tree, matching the pattern in pkg/exec/CmdTree.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: resolve CI lint failures (gofmt, gosec) and update snapshots

- Run gofmt on all scripting package files
- Add //nolint:gosec for G101 (test credential constants) and G703 (test path traversal)
- Update TestUsage snapshot for new --fail-on-prompt global flag from main

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: add remaining gosec nolint directives for test credentials

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: move gosec nolint directive to variable declaration line

gosec G101 reports on the map literal line, not the value line.
Extract the akvs:// string to a variable so the nolint:gosec
directive is on the same line as the flagged string literal,
matching the pattern in TestExecAction_ResolvesSecretReferences.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: add diagnostic logging to Job Object fallback paths in proctree_windows.go

Add log.Printf at all four best-effort Job Object setup fallback points
(CreateJobObject, SetInformationJobObject, OpenProcess, AssignProcessToJobObject)
to aid diagnosis of orphaned child processes on Windows.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: address review feedback - escape cmd.exe %VAR%, gate stdin on interactive, fix Ctrl-C in interactive mode, strengthen exit-code test

- Escape % as %% in cmd.exe paths and args to prevent env var expansion (CVE-2024-24576 class)
- Gate cmd.Stdin on e.config.Interactive in ExecuteDirect (parity with executeCommand)
- Skip CREATE_NEW_PROCESS_GROUP when interactive=true (match Unix Setpgid behavior)
- Close Job Object handle after TerminateJobObject in kill closure
- Replace shell-dependent exit-code test with portable compiled binary approach

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: add gosec nolint comment for test build command

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: move nolint directive above line to satisfy lll lint rule

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: update exec usage snapshot after rebase onto main

Global flags changed upstream (removed --fail-on-prompt, updated --no-prompt wording).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: therealjohn <1501196+therealjohn@users.noreply.github.com>
Copilot AI pushed a commit that referenced this pull request May 21, 2026
…ap (#8221)

The changelog generation skill missed PR #7400 (azd exec) in the 1.25.1
release notes. The PR was in the commit range but was silently skipped
during processing.

Changes:
- Add #7400 entry to CHANGELOG.md under 1.25.1 Features Added
- Add reverse cross-reference (coverage check) to changelog skill Step 5
  that verifies every commit in range is either included or has an
  explicit exclusion reason, preventing silent omissions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: therealjohn <1501196+therealjohn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core-cli CLI commands, cmd/, internal/cmd/ area/public-docs Public documentation (Microsoft Learn, etc.) feature Feature request needs-discussion Needs team discussion before proceeding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add azd exec: run commands and scripts with azd environment context

10 participants