Skip to content

azd x: non-fatal metadata warnings and azd x init wizard polish#8197

Open
Copilot wants to merge 6 commits into
mainfrom
copilot/fix-azd-x-init-metadata-warnings
Open

azd x: non-fatal metadata warnings and azd x init wizard polish#8197
Copilot wants to merge 6 commits into
mainfrom
copilot/fix-azd-x-init-metadata-warnings

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

Fixes #8207
Fixes #8196

This PR makes azd x build extension metadata warnings non-fatal so they no longer abort azd x init, surfaces the real cause when an init subtask does fail, and rolls in several azd x init wizard fixes including Issue #8207.

image

Warning handling

azd x build previously treated validation warnings (e.g. missing providers when the service-target-provider capability is declared) as command failures. azd x init then aborted on those warnings, and its build subprocess output was discarded so the user never saw why.

  • ux.TaskList: a task returning (Warning, err) no longer cancels subsequent tasks, and warning details render with warning styling instead of error styling. TaskState constants now have GoDoc and a dedicated unit test pins the "warning does not collect as error" contract.
  • azd x build reports validation warnings via the ux.Warning state and reserves the ux.Error state for missing required fields.
  • validateExtensionMetadata is extracted as a shared helper so azd x init validates the in-memory schema directly. The old subprocess-output-parsing approach (ANSI stripping, marker probing, trailing-paren trimming) is gone.
  • Validation warning messages now name the YAML field, the capability that requires it, and what to set.
  • A short inline summary appears in the init task list; the full bulleted detail prints once below it via a deferred flush, so warnings are still shown if a later task fails.
  • Validation runs before any filesystem side effect (extension directory creation and local registry bootstrap), and validationFailureError / validationWarningSummary are shared between init and build so the wording stays in sync.
  • The redundant "Local extension source already exists." message is removed (the (-) Skipped task line already conveys that).

Init subprocess error surfacing

The four child steps in azd x init (build, package, publish, install) previously bubbled up as exit status 1 with no underlying message, and their TaskList canvases replayed inside the parent's UI. A shared runSubprocess helper now captures CombinedOutput, strips ANSI sequences, and inlines the first ERROR:/Error: line (fallback: last non-empty line) into the wrapped error. The end result for a namespace-conflict install failure is a single Details: block with the actual reason — no duplicated rendering, no opaque exit code.

Wizard UX (resolves #8207)

  • Confirmation prompt now defaults to "yes".
  • Tags prompt is optional and accepts empty input. Also fixes a pre-existing bug where parsed tags were discarded and tags: was always empty. Tag parsing now enforces count, per-tag length, and control-character limits.
  • The namespace shape is validated by a single regex (^[a-z][a-z0-9]*(\.[a-z][a-z0-9]*)*$) applied to both the interactive and --no-prompt paths.
  • If the target directory already exists, the confirm prompt now defaults to "no" and, when the directory is non-empty, calls out that existing files may be overwritten and includes a help message describing overwrite semantics.
  • Dotted namespaces (ai.project) are translated into the actual command path (azd ai project <command>) when generating the usage field and the "Try out the extension" follow-up hint, matching how bindExtension registers nested namespaces. The namespace prompt help text now explains this behavior.
  • Generated extension.yaml includes a # yaml-language-server: $schema=... modeline pointing at the published schema URL so editor tooling validates the file out of the box.

Scaffolded extension root command

The Go template produced Use: "azd {{namespace}} <command> [options]", which made cobra parse "azd" as the command name and rendered Usage: azd [command] in the extension's own --help output. The template now uses the leaf segment of the namespace for both Name and Use (matching the convention in azure.ai.agents), so azd ai test --help displays Usage: test <command> [options] as expected. The user-supplied Description is also routed through a goString template helper (strconv.Quote) before being embedded as the cobra Short: literal, so descriptions containing quotes, backslashes, or newlines produce valid Go source rather than a broken scaffold.

Copilot AI linked an issue May 15, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix azd x init to handle extension metadata warnings Treat extension metadata warnings as non-fatal May 15, 2026
Copilot AI requested a review from JeffreyCA May 15, 2026 01:25
@JeffreyCA JeffreyCA force-pushed the copilot/fix-azd-x-init-metadata-warnings branch from 7072a55 to bac949d Compare May 15, 2026 18:08
@JeffreyCA JeffreyCA changed the base branch from main to copilot/migrate-to-new-extension-root-command May 15, 2026 18:12
@JeffreyCA JeffreyCA force-pushed the copilot/fix-azd-x-init-metadata-warnings branch from bac949d to 47e5638 Compare May 15, 2026 18:18
@JeffreyCA JeffreyCA changed the title Treat extension metadata warnings as non-fatal azd x: non-fatal metadata warnings and azd x init wizard polish May 15, 2026
Base automatically changed from copilot/migrate-to-new-extension-root-command to main May 18, 2026 18:15
`azd x build` previously treated validation warnings (e.g. missing
`providers` when `service-target-provider` is declared) as failures.
That aborted `azd x init`, and the build subprocess output was
discarded so the user never saw why.

Warning handling:
- `ux.TaskList`: a task returning `(Warning, err)` no longer cancels
  subsequent tasks, and warning detail renders with warning styling
  instead of error styling.
- Extract `validateExtensionMetadata` as a shared helper. `azd x init`
  validates the in-memory schema directly instead of shelling out to
  `azd x build` and parsing its rendered output.
- Show a short summary in the task list and the full bulleted detail
  once below it.
- Drop the redundant "Local extension source already exists." message.
- Rephrase warnings to name the YAML field, the capability that needs
  it, and what to set.

Wizard UX (resolves #8207):
- Confirmation prompt defaults to "yes".
- Tags prompt is optional; also fixes a pre-existing bug where parsed
  tags were discarded.
- Translate dotted namespaces (`ai.project`) into the actual command
  path (`azd ai project <command>`) in the generated `usage` field and
  follow-up hints, matching how `bindExtension` registers them.
- Generated `extension.yaml` includes a `yaml-language-server` header
  pointing at the published schema URL.

Scaffolded extension root command:
- The Go template set `Use` to `"azd <namespace> <command> [options]"`,
  so cobra parsed `"azd"` as the root command name and rendered
  `Usage: azd [command]`. Use the leaf segment of the namespace for
  both `Name` and `Use`, matching the convention in `azure.ai.agents`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JeffreyCA JeffreyCA force-pushed the copilot/fix-azd-x-init-metadata-warnings branch from 47e5638 to 08859f8 Compare May 18, 2026 18:21
@JeffreyCA
Copy link
Copy Markdown
Contributor

/azp run azure-dev - cli

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@JeffreyCA JeffreyCA marked this pull request as ready for review May 18, 2026 18:52
Copilot AI review requested due to automatic review settings May 18, 2026 18:52
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

This PR improves azd x init and azd x build extension metadata validation behavior by making warnings non-fatal and polishing generated scaffold UX for extension authors.

Changes:

  • Updates task list warning handling so warning-state errors render as warnings and do not stop subsequent tasks.
  • Adds shared extension metadata validation with improved warning text and uses it from both build and init flows.
  • Improves init wizard/scaffold output for tags, confirmation defaults, dotted namespaces, schema modelines, and generated Go root command usage.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
cli/azd/pkg/ux/task_list.go Changes task warning errors to be non-fatal and renders warning details with warning styling.
cli/azd/pkg/ux/render_test.go Adds coverage for warning tasks continuing to subsequent tasks.
cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/go/internal/cmd/root.go.tmpl Uses the leaf namespace for generated Go cobra root command metadata.
cli/azd/extensions/microsoft.azd.extensions/internal/cmd/init.go Adds metadata validation, warning output, namespace formatting, optional tags, schema header, and build failure output handling.
cli/azd/extensions/microsoft.azd.extensions/internal/cmd/init_test.go Adds tests for namespace formatting and metadata validation behavior.
cli/azd/extensions/microsoft.azd.extensions/internal/cmd/build.go Extracts shared metadata validation and makes warnings non-fatal during build.

Comment thread cli/azd/extensions/microsoft.azd.extensions/internal/cmd/build.go
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Review may take a bit longer — reach out to @rajeshkamal5050 or @kristenwomack if you'd like to discuss prioritization.

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 x: non-fatal metadata warnings & init wizard polish

Automated review (Claude Opus 4.7) — 8 parallel focus-area passes. Multi-reviewer consensus findings called out. Recommendation: comment-only so this is discussion fuel, not a block — but the P1 items below are real and worth resolving before merge.

TL;DR

The core change — splitting Warning from Error in TaskList — is conceptually sound and the new �alidateExtensionMetadata extraction is clean. However the implementation has one real backward-compat regression in an unrelated consumer (cmd/tool.go), a rendering bug (multi-line warning string corrupts the live canvas), an ordering bug (filesystem mutation before validation), and several documentation/test gaps for behavior the PR is explicitly trying to change.


🔴 P1 — Should fix before merge

# File:line Finding
1 pkg/ux/task_list.go:373–376 (shouldCollectTaskError) + cmd/tool.go:~1241,1296,1303–1310 Silent backward-compat break in unrelated consumer. Pre-PR, any task returning (ux.Warning, err) had its error joined into Run()'s aggregated return. Existing �zd tool install/uninstall already returns (ux.Warning, fmt.Errorf("%s did not succeed", …)) when a tool fails. Post-PR that error is silently dropped → the "Some tools could not be installed…" notice never fires and �zd tool install/uninstall exits 0 even when tools fail. The Warning semantics flip wasn't audited against existing call sites. Fix: either (a) audit and migrate cmd/tool.go to return Error for real failures (preferred — its current "Warning + err" was always semantically muddled), or (b) keep collecting Warning errors but branch on Warning only at the "skip remaining" gate.
2 �xtensions/microsoft.azd.extensions/internal/cmd/build.go:135 (�alidationWarningsMessage) → rendered via pkg/ux/task_list.go:255–262 Multi-line warning string corrupts the live canvas. �alidationWarningsMessage returns "validation warnings:\n - foo\n - bar" and is set as the task's error. The TaskList renders it inline as (%s) on a single status row; embedded newlines + bullets break ANSI cursor positioning during the per-second canvas re-render. Pre-PR this string never reached this code path because Warning was treated as Error. Fix: keep the inline summary single-line (e.g. "N validation warning(s)") and emit detailed bullets after askList.Run() returns — exactly the pattern init.go's new writeCollectedWarnings already uses. Have �uild.go reuse it.
3 �xtensions/microsoft.azd.extensions/internal/cmd/init.go (task order in
unInitAction) Validation runs after the filesystem mutation. �alidateExtensionAction currently runs after createExtensionDirectoryAction. Schema validation is pure (no I/O); if it returns Error, the partially-created directory is left on disk and confuses subsequent re-runs ("directory exists / continue to create/update files"). Move validation before directory creation.
4 �xtensions/microsoft.azd.extensions/internal/cmd/init.go:~373–380 (early-return on askList.Run() != nil) Collected warnings dropped exactly when users need them. If a later task (build/package/publish) fails, the function returns early and writeCollectedWarnings(buildWarnings) is never invoked — even though the inline status said "see details below". Fix: defer writeCollectedWarnings(buildWarnings) once warnings are populated, or call it unconditionally before the early return.
5 �xtensions/microsoft.azd.extensions/CHANGELOG.md (top) No changelog entry for a user-visible extension behavior change. Latest release (0.10.0, 2026-03-04) doesn't include this and there's no Unreleased section. Extension authors need to know about it — �zd x build exit semantics change, and the generated
oot.go's Name: field changes from full namespace to leaf (see #9 below).
6 pkg/ux/render_test.go:561–589 (TestTaskList_Run_warningContinues) + :173–195 (TestTaskList_Render_warning) The actual visual bug fix is untested. The literal change at ask_list.go:261 is WithErrorFormat → WithWarningFormat (red → yellow). Neither test asserts the ANSI format used — they only �ssert.Contains(output, "partial failure"), which would have passed pre-PR too. Add an assertion that the warning row uses output.WithWarningFormat(...) and explicitly does not contain WithErrorFormat(...). Also assert l.errors is empty after the warning-only run, to lock shouldCollectTaskError's contract.

🟡 P2 — Should fix before merge, lower urgency

# File:line Finding
7 pkg/ux/task_list.go:85–95 (TaskState constants) Warning, Error, Success, etc. have no GoDoc. The Warning semantics just changed silently; document that (Warning, err) is display-only and execution continues. AGENTS.md requires GoDoc on exported types.
8 �xtensions/.../build.go (overall) �zd x build with warnings now silently exits 0, undocumented, no --strict/--warnings-as-errors flag. CI scripts get no signal. Either document explicitly in the command's Long help, or add a flag.
9 �xtensions/.../resources/languages/go/internal/cmd/root.go.tmpl:13–14 Template Use: and Name: changed from full {{.Metadata.Namespace}} to {{.LeafNamespace}}. Breaking change for any generated extension that referenced its own name (telemetry/log scopes). At minimum, expose both LeafNamespace and FullNamespace and call out the change in the changelog.
10 �xtensions/.../init.go collectExtensionMetadataFromFlags (--no-prompt path) No validation of namespace shape. Values like "a..b" or empty produce
amespaceCommandPath == "a b" and LeafNamespace == "", generating Name: "" in
oot.go.tmpl which cobra rejects at runtime. Validate ^[a-z][a-z0-9](.[a-z][a-z0-9])*$ in both interactive and scripted paths.
11 �xtensions/.../init.go (deleted "Local extension source already exists" notice) The post-run output.WithWarningFormat(...) notice that fired when localRegistryExists was removed. The Skipped row still appears but the explicit follow-up is gone — UX regression. Restore or route through writeCollectedWarnings.
12 init.go writeCollectedWarnings vs pkg/ux/task_list.go:43 vs �uild.go validationWarningsMessage Inconsistent warning text formatting across three sites: "(!) Warning " (TaskList), "WARNING:" (writeCollectedWarnings, ALL CAPS), "validation warnings:" (build.go, lowercase + colon), "%d warning(s) — see details below" (init.go, em-dash). Pick one.
13 �uild.go:56–72 ↔ init.go:196–214 Duplicated validation-result handling. Both call �alidateExtensionMetadata, format errors with slightly different prefixes, wrap with common.NewDetailedError("Validation failed", …), and format warnings differently. Extract a shared helper.
14 init.go buildExtensionAction (~line 226) cmd.CombinedOutput() captured to �uildCommandOutput only when �rr != nil. If �zd x build succeeds but emits warnings to stdout/stderr (now possible because warnings are non-fatal), the user never sees them. Always retain subprocess output.
15 init.go buildExtensionAction (~lines 249–292) PATH-dependent guarantee. Shells out to whichever �zd is on PATH. The "warnings are non-fatal" promise only holds when the spawned binary contains this PR. With an older �zd installed, the subprocess still aborts on warnings. Document the runtime dependency.
16 init.go (tags prompt) Tags now optional but no length/control-char sanitization. Malformed tags break the YAML and the new schema-header line. Add a cap and reject control chars.
17 �uild.go:~73 �alidateExtensionMetadata GoDoc Comment says warnings "flag recommended but optional fields", but missing
amespace (with custom-commands capability) is now reported as an error, not a warning. Update doc.
18 init_test.go:464–526 (TestValidateExtensionMetadata) Pins exact long multi-sentence error/warning strings. These are tunable user-facing copy and will break on every wording tweak without catching real regressions. Use �ssert.Len + �ssert.Contains on stable key prefixes.
19 pkg/ux/task_list.go:373–376 (shouldCollectTaskError) New helper has no direct unit test; only covered transitively. Add a table test covering each TaskState ×
il/non-nil �rr.
20 �xtensions/.../init.go writeCollectedWarnings, writeFailedCommandOutput Both write to mt.Println/ mt.Print directly, making them untestable. Refactor to accept an io.Writer.

🟢 P3 — Nice to have

# File:line Finding
21 pkg/ux/task_list.go:307, 166 Pre-existing data race:
unSyncTasks reads len(t.errors) without �rrorMutex; Run() reads .errors after Wait() without the lock. Safe today via happens-before from waitGroup.Wait(), but the new indirection makes it easier to introduce a real race later. Tighten now or document the synchronization contract.
22 pkg/ux/task_list.go:230–244 (Render) Render reads ask.State/ ask.Error/ ask.endTime from the render goroutine while runners mutate them unsynchronized. Warning rendering now exposes ask.Error via statusDescription, giving readers a new path to observe a torn interface value. Per-task mutex or snapshot under �rrorMutex.
23
oot.go.tmpl namespace template injection LeafNamespace/Description are user-supplied values dropped into Go string literals via ext/template with no escaping. Low impact (self-scaffold), but a namespace containing ", , or newline produces broken/attacker-controlled Go. Validate input format.
24 init.go writeFailedCommandOutput Subprocess CombinedOutput() may contain ANSI sequences; printing verbatim ignores parent's NO_COLOR. Strip ANSI or set NO_COLOR=1 in the child env.
25 init.go (confirm prompt default flip from "no" → "yes") Pressing Enter now confirms creation. Reasonable for happy path but combined with "directory exists → continue to create/update files" can silently overwrite user files. Consider warning if target dir is non-empty.
26 init.go:~209–213 Manual pluralization + em-dash literal in code is unusual for this codebase (rest uses ASCII hyphens). Minor.
27 init_test.go imports Single import group mixes external ( estify) and internal (github.com/azure/azure-dev/...). Split per AGENTS.md import order.
28 �uild.go:~58 Error string starts with capital "Extension contains validation failures..."; parallel init.go:~201 uses lowercase. Pick one.
29 ExtensionTemplate struct (init.go) Lacks GoDoc on the type itself (only the new LeafNamespace field has it).
30 New tests don't call .Parallel(); sub-test with empty namespace produces blank .Run name.

Multi-reviewer consensus: Findings #1, #2, #3, #4, #8 were each flagged independently by 2+ focus-area reviewers, giving them high confidence.

Not flagged anywhere: No command-injection issues, no permissive file mode regressions, no performance concerns, copyright headers all intact, no interface{} regressions, no Go 1.26 modernization misses.

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 @ bd94cbb

Thanks for the iteration. The "Address comments" commit is a well-reasoned, narrowly-scoped fix:

What the delta does well

  • Promotes namespace-missing-with-custom-commands from warning → fatal error
  • Inline comment clearly explains why it's fatal (bindExtension uses the last .-segment as the cobra command name → empty namespace silently installs an unreachable command)
  • Inline comment explains why providers-missing stays a warning (init wizard doesn't yet prompt for providers — promoting would block every service-target-provider scaffold)
  • Test case renamed and expectation moved from wantWarningswantErrors consistently

🆕 New findings introduced by this delta

Priority File:line Finding
P2 build.go validateExtensionMetadata GoDoc (function-level comment) The promotion of namespace-missing from warning → error makes the existing GoDoc more inaccurate. The function now has two reasons to return errors (structural Missing required field: X and capability-conditional fatal misuse), but the doc still frames errors as the structural-only category. The new inline comments compensate at the call site but the public-facing doc is now more misleading than before.
P2 build.go validateExtensionMetadata (new error path itself) The warning→error promotion is a breaking validation change for hand-edited extension.yaml files that previously built successfully. The inline comment acknowledges this ("only triggers on hand-edited files") — a reasonable risk assessment, but exactly the kind of change that needs a CHANGELOG entry (see open #5 below).
P3 init_test.go:102–124 Renamed test still pins the exact long error string verbatim — same brittleness flagged previously. Worth refactoring to assert.Contains on a stable key prefix alongside this rename, rather than as a separate cleanup.

📋 Open from prior review (not addressed in this commit)

Still outstanding from the previous review — flagging here so they don't get lost:

P1 (worth fixing before merge):

  • #1 cmd/tool.go backward-compat regression — azd tool install/uninstall silently exits 0 on failure because (ux.Warning, err) returns are now dropped by shouldCollectTaskError. (Highest-impact finding — affects an unrelated command.)
  • #2 Multi-line validationWarningsMessage corrupts the live TaskList canvas when rendered inline as (%s) with embedded \n - bullets.
  • #3 validateExtensionAction runs after createExtensionDirectoryAction — schema validation should precede the filesystem mutation.
  • #4 writeCollectedWarnings is skipped on the early-return path when a later task (build/package/publish) fails — warnings dropped exactly when users need them. defer writeCollectedWarnings(buildWarnings) fixes it.
  • #5 No CHANGELOG.md entry in cli/azd/extensions/microsoft.azd.extensions/ for a user-visible behavior change (now compounded by the warning→error promotion in this commit).
  • #6 The literal visual fix (WithErrorFormatWithWarningFormat, red → yellow) is untested — neither TestTaskList_Render_warning nor TestTaskList_Run_warningContinues asserts the format used.

P2 (still relevant):

  • #7 TaskState.Warning constant lacks GoDoc explaining the new (Warning, err) display-only semantics.
  • #8 azd x build exiting 0 on validation warnings is undocumented; consider --strict / --warnings-as-errors for CI.
  • #9 root.go.tmpl Name: field changed from full to leaf namespace — breaking for downstream extensions that referenced their own name.
  • #10 --no-prompt path still doesn't validate namespace shape (e.g. "a..b", leading/trailing dot) — only the custom-commands + empty case is now caught.
  • #11 Deleted "Local extension source already exists" post-run notice is a UX regression.
  • #17 validateExtensionMetadata GoDoc — see new P2 above; the prior staleness is now worse.

Full prior review with all P3 items: #8197 (review)

@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/8197/uninstall-azd.sh | bash;
curl -fsSL https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/8197/install-azd.sh | bash -s -- --base-url https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/8197 --version '' --verbose --skip-verify

pwsh:

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

Windows

PowerShell install

powershell -c "Set-ExecutionPolicy Bypass Process; irm 'https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/8197/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/8197/install-azd.ps1' > install-azd.ps1; ./install-azd.ps1 -BaseUrl 'https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/8197' -Version '' -SkipVerify -Verbose;"

MSI install

powershell -c "irm 'https://azuresdkartifacts.z5.web.core.windows.net/azd/standalone/pr/8197/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/18/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

JeffreyCA and others added 4 commits May 18, 2026 21:48
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address self-review nits on top of the prior commit:
- Replace the duplicated success/failure flushes in runInitAction with a single
  named-return defer so warnings are always printed and subprocess output is
  surfaced only on failure (avoids dumping the full build transcript on success).
- Replace the duplicated flush in runBuildAction with a defer for the same
  reason; restores the simple 'return taskList.Run()' shape.
- Reorder runInitAction tasks so metadata validation runs before any filesystem
  side-effects, including the local extension source creation.
- Drop the redundant '(!) Warning' prefix from the post-run warnings header;
  the TaskList row already shows that marker.
- Add a boundary test asserting exactly maxExtensionTags parses successfully.
- Wrap the long assert.True lines in TestValidateExtensionMetadata to satisfy
  the 125-char lll lint cap.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JeffreyCA
Copy link
Copy Markdown
Contributor

**** pkg/ux/task_list.go:373–376 (shouldCollectTaskError) + cmd/tool.go:~1241,1296,1303–1310 Silent backward-compat break in unrelated consumer. Pre-PR, any task returning (ux.Warning, err) had its error joined into Run()'s aggregated return. Existing �zd tool install/uninstall already returns (ux.Warning, fmt.Errorf("%s did not succeed", …)) when a tool fails. Post-PR that error is silently dropped → the "Some tools could not be installed…" notice never fires and �zd tool install/uninstall exits 0 even when tools fail. The Warning semantics flip wasn't audited against existing call sites. Fix: either (a) audit and migrate cmd/tool.go to return Error for real failures (preferred — its current "Warning + err" was always semantically muddled), or (b) keep collecting Warning errors but branch on Warning only at the "skip remaining" gate.

Thanks for the thorough review - addressed the following:

Review feedback

Severity Status Items
P1 ✅ All fixed tool.go returns (Error, err) with regression test · single-line inline warning summary + post-run bullets (no canvas corruption) · validation runs before any filesystem side effect (incl. local registry creation) · deferred writeCollectedWarnings flush so no return path drops warnings · tests assert warning format and empty tl.errors
P2 ✅ Fixed TaskState GoDoc on every constant · single namespace-shape regex applied to both interactive and --no-prompt paths · unified warning text across all sites · shared validationFailureError / validationWarningSummary between init and build · tag count/length/control-char limits with boundary test · validateExtensionMetadata GoDoc updated for warning→error promotion
P2 ◐ Documented azd x build non-fatal-warning behavior called out in Long help; held off on --strict flag pending UX discussion · PATH caveat documented in init help
P2 ✅ Resolved differently Child subprocess output: rather than retain on success, we now extract the first ERROR: line (ANSI-stripped) and inline it into Details:, and never dump the raw canvas. See "New" below.
P2 ⏭ Intentional root.go.tmpl Name: stays as leaf (azd dot-splits before dispatch) · "Local extension source already exists" notice — the skipped-task row already conveys this
P3 ✅ Fixed Substring-based test assertions (not pinned to long copy strings) · direct shouldCollectTaskError table test · io.Writer parameter for warning output · goString/strconv.Quote for Description in root.go.tmpl with injection-attempt test · ANSI stripped in subprocessErrorTail · dir-exists prompt warns on non-empty, defaults to no · em-dash replaced · imports split per AGENTS.md · lowercased extension contains validation failures copy · ExtensionTemplate GoDoc · named subtests + t.Parallel() in TestValidateExtensionNamespace
P3 ⏭ Deferred Pre-existing pkg/ux TaskList data races — better as a focused follow-up

Other changes

  • runSubprocess + subprocessErrorTailazd x init build/package/publish/install previously showed only exit status 1 in Details: and replayed the child's TaskList canvas. Now CombinedOutput is captured, ANSI stripped, and the first ERROR:/Error: line (fallback: last non-empty line) is inlined into the wrapped error. Covered by TestSubprocessErrorTail.
  • Task order — validate → local source → directory → build → package → publish → install. Extends the "validate before FS side effects" fix to the local registry step.
  • Deferred warning flush in both init and build so no return path drops warnings.
  • Non-empty directory prompt ends with Continue? and adds a HelpMessage explaining overwrite semantics; isDirNonEmpty uses os.Open + Readdirnames(1) per AGENTS.md.
  • Dropped redundant (!) Warning prefix from the post-run header (the line is already warning-colored).
  • TestParseTags boundary case at exactly maxExtensionTags.

@JeffreyCA JeffreyCA added the ext-x microsoft.azd.extensions developer extension (azd x) label May 18, 2026
Copy link
Copy Markdown
Contributor

@hemarina hemarina 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 @ 9cc6d11

Follow-up after the prior review on bd94cbb. The 5 new commits (25e770df9cc6d11) resolve every P1 item and almost all P2/P3 items from that review — net result is a substantially cleaner change. Calling out two small net-new findings I caught in the runSubprocess/subprocessErrorTail helpers and a couple of items that remain open from the prior review. Not posting blockers; the PR is in good shape.

✅ Resolved from prior review

  • P1 #1 cmd/tool.go (Warning, err) regression — now returns ux.Error, covered by TestRunToolOperationUnsuccessfulResultReturnsError
  • P1 #2 Multi-line warning corrupting the canvas — inline message is now a single-line summary; details flushed after via writeCollectedWarnings
  • P1 #3 Validation running after the filesystem mutation — validateExtensionAction is now the first task
  • P1 #4 Collected warnings dropped on early-return — defer writeCollectedWarnings(os.Stdout, buildWarnings) in both build.go and init.go
  • P1 #5 Missing CHANGELOG entry — new 0.11.0 section
  • P1 #6 Color-format fix untested — assert.Contains(output, outputpkg.WithWarningFormat("(partial failure)")) + NotContains(WithErrorFormat(...))
  • P2 #7 TaskState constants — GoDoc added
  • P2 #8 azd x build silent exit 0 — documented in the new Long: help text (no --strict flag, but the behavior is now discoverable)
  • P2 #10 --no-prompt namespace shape — validateExtensionNamespace enforces ^[a-z][a-z0-9]*(\.[a-z][a-z0-9]*)*$ in both interactive and scripted paths
  • P2 #16 Tag sanitization — parseTags enforces maxExtensionTags=10, maxExtensionTagLength=64, rejects control characters
  • P2 #17 validateExtensionMetadata GoDoc updated to reflect the warning→error promotion
  • P2 #18 Tests no longer pin exact long strings — assert.Len + slicesContainSubstring on stable prefixes
  • P2 #19 shouldCollectTaskError — direct table test added
  • P2 #20 writeCollectedWarnings now takes io.Writer; writeFailedCommandOutput replaced by subprocessErrorTail
  • P3 #23 Template injection — goString = strconv.Quote template helper + TestTemplateGoStringQuotesDescription
  • P3 #24 ANSI in subprocess output — stripped via ansiEscapeRegex
  • P3 #25 Overwrite warning — isDirNonEmpty + amended confirm prompt with HelpMessage
  • P3 #28/29 Capitalization + ExtensionTemplate GoDoc

🆕 New nits (P3)

# File:line Finding
1 init.go:312-317 (runSubprocess) Title duplicated in the wrapped error. common.NewDetailedError(description, fmt.Errorf("%s: %w%s", description, err, ...)) puts description in both the title and the inner message prefix. The live TaskList row uses Description() only so the canvas is fine, but when the error propagates up through taskList.Run() and the CLI error middleware prints it, the final output renders as Build failed\n\nDetails:\nBuild failed: exit status 1: <tail>"Build failed" appears twice. Drop description from the inner Errorf.
2 init.go:905-908 (subprocessErrorTail) Bare ERROR:/Error: line yields a trailing ": " artifact. Input "ERROR:\n" produces ": " because TrimSpace(TrimPrefix(...)) returns "" but the function still prepends ": ". Wrapped error becomes "Build failed: exit status 1: ". azd subcommands today always emit "ERROR: <message>" so this is defensive, but the fix is one line — if the post-trim string is empty, fall through to fallback instead of returning. Add a test row {name: "bare ERROR", in: "ERROR:\n", want: ""} to TestSubprocessErrorTail.

📋 Still open from prior review

  • P2 #11 Removed "Local extension source already exists" notice — users now see (-) Skipped against Create local azd extension source with no follow-up explanation. The deferred warnings flush only handles validation warnings, not the registry-skipped case. Minor UX regression; either restore the post-run notice or move it into a HelpMessage-style hint on the task title.
  • P2 #14 When the spawned subprocess succeeds but emits warnings to stdout, those are still discarded — only the parent''s in-memory validation feeds writeCollectedWarnings. Documented as PATH-dependent in the new Long: help, so this is acceptable, but worth a one-line note in the help text that nested-build warnings from a different azd version may not surface.
  • P3 #12 Warning wording still drifts slightly across sites: (!) Warning (TaskList), Validation warnings: (deferred flush), N validation warning(s); see details below (inline summary). Lower priority than before but not fully harmonized.
  • P3 #22 Race on Task.State/Task.Error reads from the render goroutine — unaddressed (pre-existing).

Other observations (P3 / informational)

  • runSubprocess''s /* #nosec G204 */ waiver covers all four call sites, but three of them pass only hardcoded literals ("x build --skip-install", etc.); only the install action passes user-controlled extensionMetadata.Id. Moving the comment to the install closure would be more precise.
  • runInitAction is now (err error) named return, but inner scopes reuse err via := (e.g. line 220 nonEmpty, err := isDirNonEmpty(...)). Every early return is explicit so it works today, but named-return + heavy := reuse is a known foot-gun. Either name it something distinctive (result error) or skip the named return and pass buildWarnings to a small helper that does the flush.
  • promptExtensionNamespace loops indefinitely until validateExtensionNamespace passes. Relies on Prompt() propagating Ctrl+C as an error, which it does today. Worth a one-line comment documenting that assumption.
  • ansiEscapeRegex only matches CSI sequences; OSC hyperlinks (\x1b]8;;…\x07) would leak through. Low impact — fatih/color only emits CSI today.
  • CHANGELOG.md is dated 2026-05-19; verify against the actual release date.

Verdict

Looks good to me. The two runSubprocess nits are the only items I''d actually want to see fixed before merge, and even those are P3-level. Recommend comment-only; happy to re-review once the nits land if you want.

"Package failed",
fmt.Errorf("failed to package extension: %w", err),
description,
fmt.Errorf("%s: %w%s", description, err, subprocessErrorTail(result)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor: description is passed as both the NewDetailedError title and the prefix of the inner Errorf. When this error propagates up through taskList.Run() and prints via the CLI error middleware, the final output is:

Build failed

Details:
Build failed: exit status 1: <tail>

"Build failed" ends up doubled. The live canvas is fine (uses Description() only), but the printed error duplicates the title. Suggested fix:

return ux.Error, common.NewDetailedError(
    description,
    fmt.Errorf("%w%s", err, subprocessErrorTail(result)),
)

While here: subprocessErrorTail returns ": " for a bare "ERROR:\n" line because TrimSpace(TrimPrefix(...)) collapses to "" but ": " is still prepended. Unlikely in practice (azd always emits text after ERROR:) but a one-line guard + test row would close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-x microsoft.azd.extensions developer extension (azd x)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azd x init confusing handling for namespace azd x init treats extension metadata warnings as build failures

6 participants