Skip to content

Migrate 1P extensions to azdext.NewExtensionRootCommand and remove reserved-flag conflicts#7955

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/migrate-1p-extensions-to-new-command
Draft

Migrate 1P extensions to azdext.NewExtensionRootCommand and remove reserved-flag conflicts#7955
Copilot wants to merge 2 commits intomainfrom
copilot/migrate-1p-extensions-to-new-command

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

Audits the remaining first-party extensions in cli/azd/extensions/ and migrates them to azdext.NewExtensionRootCommand, removing flags that collide with azd's reserved global flag set (--debug, --no-prompt, --cwd, -e/--environment, -o/--output, etc.). Mirrors the work already done for azure.ai.agents (#7947); microsoft.azd.extensions is intentionally out of scope (tracked in #7951).

Per-extension changes

  • azure.ai.finetune — SDK root; init --environment/-n removed (reads extCtx.Environment); jobs show and jobs list swap their local -o/--output for azdext.RegisterFlagOptions (default table, allowed table,json[,yaml]).
  • azure.ai.models — SDK root; init --environment/-n removed; custom show / custom list use RegisterFlagOptions for --output; custom delete reads --no-prompt from extCtx.
  • azure.appservice — SDK root; swap reads --no-prompt from extCtx instead of the dropped rootFlagsDefinition.
  • azure.coding-agent — SDK root; also drops the conflicting config --debug (the issue lists only the root flag, but the same --debug is re-registered on the subcommand and would still fail ValidateNoReservedFlagConflicts). Reads from extCtx.Debug.
  • microsoft.azd.concurx — SDK root; duplicate up --debug removed (reads extCtx.Debug).
  • microsoft.azd.demo — adopts NewExtensionRootCommand for consistency (no flag conflicts).

SDK version

azure.ai.finetune and azure.ai.models go.mod bumped to a cli/azd revision that includes RegisterFlagOptions (#7826). The other four extensions only depend on NewExtensionRootCommand (already in cli/azd v1.23.13) so their go.mod is unchanged. microsoft.azd.demo builds against the in-tree cli/azd module.

Migration shape

// Before
rootCmd := &cobra.Command{Use: "appservice <command> [options]", ...}
rootCmd.PersistentFlags().BoolVar(&rootFlags.Debug, "debug", false, "Enable debug mode")
rootCmd.PersistentFlags().BoolVar(&rootFlags.NoPrompt, "no-prompt", false, "...")
rootCmd.AddCommand(newSwapCommand(rootFlags))

// After
rootCmd, extCtx := azdext.NewExtensionRootCommand(azdext.ExtensionCommandOptions{
    Name:  "appservice",
    Use:   "appservice <command> [options]",
    Short: "Extension for managing Azure App Service resources.",
})
rootCmd.SilenceUsage = true
rootCmd.SilenceErrors = true
rootCmd.CompletionOptions.DisableDefaultCmd = true
rootCmd.AddCommand(newSwapCommand(extCtx))
// Per-subcommand --output via RegisterFlagOptions instead of a local -o flag
azdext.RegisterFlagOptions(cmd, azdext.FlagOptions{
    Name:          "output",
    AllowedValues: []string{"table", "json", "yaml"},
    Default:       "table",
})

Copilot AI changed the title [WIP] Migrate 1P extensions to use azdext.NewExtensionRootCommand Migrate 1P extensions to azdext.NewExtensionRootCommand and remove reserved-flag conflicts Apr 29, 2026
Copilot AI requested a review from JeffreyCA April 29, 2026 00:19
Copy link
Copy Markdown
Member

@jongio jongio left a comment

Choose a reason for hiding this comment

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

The migration to NewExtensionRootCommand is a solid direction - centralizes flag management in the SDK and removes duplicated registration across extensions. CI is green.

Two things to address:

1. Breaking shorthand: -n removed for --environment

Both azure.ai.finetune and azure.ai.models init commands previously used -n as shorthand for --environment. The SDK uses -e. Users who relied on init -n myenv will get an error. Worth a CHANGELOG entry noting this change.

2. Pseudo-version dependency

Both finetune and models pin to a pseudo-version (v1.24.3-0.20260428202310-4d8945f915d8). Per AGENTS.md, extensions should use semver tags. Is there a planned SDK release before this merges, or is this intentionally temporary?

The updated SDK dependency also pulls in ~40 new indirect deps (Azure RM packages for cosmos, container registry, keyvault, machine learning, etc., plus copilot-sdk and azure-devops-go-api). None are used directly by these extensions. The comment in extension_command.go already notes the CLI helpers are candidates for extraction into an azdext/cobra sub-package - that'd help here.

github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cognitiveservices/armcognitiveservices v1.8.0
github.com/azure/azure-dev/cli/azd v1.23.13
github.com/azure/azure-dev/cli/azd v1.24.3-0.20260428202310-4d8945f915d8
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This pseudo-version replaces the semver v1.23.13 tag. Per AGENTS.md convention, extensions should pin to semver tags (cli/azd/vX.Y.Z). If the SDK features this PR needs (RegisterFlagOptions, NewExtensionRootCommand) aren't in a released tag yet, consider coordinating the SDK release first, or add a TODO comment here noting it should be updated to the next stable tag.

Short: fmt.Sprintf("Initialize a new AI Fine-tuning project. %s", color.YellowString("(Preview)")),
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if extCtx != nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This reads environment from extCtx.Environment (populated by the SDK's -e/--environment flag). Previously this command had -n as the shorthand for --environment. Users who relied on init -n myenv will break silently - they'll get an unknown shorthand flag error.

Aligning to -e is the right call long-term (matches azd convention), but this should be documented as a breaking change in the release notes.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the no-recent-activity identity issues with no activity label May 6, 2026
@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

Hi @@copilot. Thank you for your interest in helping to improve the Azure Developer CLI experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

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

Labels

no-recent-activity identity issues with no activity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1P extensions: migrate to azdext.NewExtensionRootCommand and remove reserved flag conflicts

3 participants