Skip to content
16 changes: 16 additions & 0 deletions src/machinelearningservices/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 2025-11-04

### Azure Machine Learning CLI (v2) v 2.40.0
- `az ml deployment-template create`
- Create a new deployment template from a YAML file.
- `az ml deployment-template list`
- List deployment templates in a registry
- `az ml deployment-template get`
- Get a specific deployment template by name and version.
- `az ml deployment-template update`
- Update specific fields of an existing deployment template.
- `az ml deployment-template archive`
- Archive a deployment template.
- `az ml deployment-template restore`
- Restore an archived deployment template.

## 2025-08-27

### Azure Machine Learning CLI (v2) v 2.39.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from ._connection_help import get_connection_help
from ._data_help import get_data_help
from ._datastore_help import get_datastore_help
from ._deployment_template_help import get_deployment_template_help
from ._environment_help import get_environment_help
from ._feature_set_help import get_feature_set_help
from ._feature_store_entity_help import get_feature_store_entity_help
Expand Down Expand Up @@ -50,6 +51,7 @@
get_workspace_help()
get_workspace_outbound_rule_help()
get_datastore_help()
get_deployment_template_help()
get_component_help()
get_connection_help()
get_schedule_help()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------

from knack.help_files import helps


def get_deployment_template_help():
"""Load deployment template help content."""


helps['ml deployment-template'] = """
type: group
short-summary: Manage Azure ML deployment templates.
long-summary: |
Deployment templates are reusable templates that define deployment configurations for Azure ML.
They support registry-based operations only (not workspace-based) and provide a way to
standardize and share deployment configurations across teams and projects.
"""

helps['ml deployment-template list'] = """
type: command
short-summary: List deployment templates in a registry.
long-summary: |
List all deployment templates available in the specified registry. This command
returns all templates along with their metadata including name, version, description, and tags.
examples:
- name: List all deployment templates in a registry
text: az ml deployment-template list --registry-name myregistry
- name: List deployment templates with specific output format
text: az ml deployment-template list --registry-name myregistry --output table
"""

helps['ml deployment-template get'] = """
type: command
short-summary: Get a specific deployment template by name and version.
long-summary: |
Retrieve detailed information about a specific deployment template. If version is not
specified, the latest version will be returned.
examples:
- name: Get a specific version of a deployment template
text: az ml deployment-template get --name my-template --version 1 --registry-name myregistry
"""

helps['ml deployment-template create'] = """
type: command
short-summary: Create a new deployment template from a YAML file.
long-summary: |
Create a new deployment template using a YAML configuration file. The YAML file should
contain the complete deployment template definition including endpoints, parameters, and metadata.
You can override specific values using command-line parameters.
examples:
- name: Create a deployment template from a YAML file
text: az ml deployment-template create --file template.yml --registry-name myregistry
- name: Create with name and version overrides
text: az ml deployment-template create --file template.yml --name custom-template --version 2 --registry-name myregistry
- name: Create without waiting for completion
text: az ml deployment-template create --file template.yml --registry-name myregistry --no-wait
"""

helps['ml deployment-template update'] = """
type: command
short-summary: Update specific fields of an existing deployment template.
long-summary: |
Update metadata fields (description and tags) of an existing deployment template without
requiring a YAML file. This command follows Azure CLI conventions and only accepts specific
field updates. Tags are merged with existing tags rather than replaced.

For structural changes to the deployment template (endpoints, deployment configuration, etc.),
use the 'create' command with a YAML file.
examples:
- name: Update deployment template description
text: az ml deployment-template update --name my-template --version 1 --registry-name myregistry --set "description=Updated description"
- name: Update deployment template tags
text: az ml deployment-template update --name my-template --version 1 --registry-name myregistry --set "tags=environment=production owner=ml-team"
- name: Update both description and tags
text: az ml deployment-template update --name my-template --version 1 --registry-name myregistry --set "description=Production template" --set "tags=status=active"
"""

helps['ml deployment-template archive'] = """
type: command
short-summary: Archive a deployment template.
long-summary: |
Archive a deployment template to mark it as inactive. Archived templates are not
returned in list operations by default. You can archive a specific version or all
versions of a template.
examples:
- name: Archive a specific version
text: az ml deployment-template archive --name my-template --version 1 --registry-name myregistry
- name: Archive without waiting for completion
text: az ml deployment-template archive --name my-template --version 1 --registry-name myregistry --no-wait
"""

helps['ml deployment-template restore'] = """
type: command
short-summary: Restore an archived deployment template.
long-summary: |
Restore a previously archived deployment template to make it active again. Restored
templates will appear in list operations. You can restore a specific version or all
versions of a template.
examples:
- name: Restore a specific version
text: az ml deployment-template restore --name my-template --version 1 --registry-name myregistry
- name: Restore without waiting for completion
text: az ml deployment-template restore --name my-template --version 1 --registry-name myregistry --no-wait
"""
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ._connection_params import load_connection_params
from ._data_params import load_data_params
from ._datastore_params import load_datastore_params
from ._deployment_template_params import load_deployment_template_params
from ._environment_params import load_environment_params
from ._feature_set_params import load_feature_set_params
from ._feature_store_entity_params import load_feature_store_entity_params
Expand Down Expand Up @@ -44,6 +45,7 @@ def load_arguments(self, _):
load_batch_endpoint_params(self)
load_online_deployment_params(self)
load_batch_deployment_params(self)
load_deployment_template_params(self)
load_environment_params(self)
load_compute_params(self)
load_workspace_params(self)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------

from ._common_params import (
add_common_params,
add_description_param,
add_file_param,
add_lro_param,
add_override_param,
add_tags_param,
)


def add_deployment_template_common_param(
c,
name_help_message="Name of the deployment template.",
version_help_message="Version of the deployment template.",
name_required=True,
version_required=True,
):
c.argument("name", options_list=["--name", "-n"], help=name_help_message, required=name_required)
c.argument("version", options_list=["--version", "-v"], help=version_help_message, required=version_required)


def load_deployment_template_params(self):
with self.argument_context("ml deployment-template list") as c:
add_common_params(c)
c.argument(
"registry_name",
options_list=["--registry-name", "-r"],
required=True,
help=(
"Name of the registry. This is required since deployment templates "
"only support registry-name and not workspace."
),
)

with self.argument_context("ml deployment-template get") as c:
add_common_params(c)
add_deployment_template_common_param(c, name_required=True, version_required=True)
c.argument(
"registry_name",
options_list=["--registry-name", "-r"],
required=True,
help=(
"Name of the registry. This is required since deployment templates "
"only support registry-name and not workspace."
),
)

with self.argument_context("ml deployment-template create") as c:
add_common_params(c)
# Optional for create since they can come from file
add_deployment_template_common_param(c, name_required=False, version_required=False)
add_lro_param(c)
add_file_param(c, "deployment-template", "https://aka.ms/ml-cli-v2-deployment-template-yaml")
add_override_param(c)
c.argument(
"registry_name",
options_list=["--registry-name", "-r"],
required=True,
help=(
"Name of the registry. This is required since deployment templates "
"only support registry-name and not workspace."
),
)

with self.argument_context("ml deployment-template update") as c:
add_common_params(c)
add_deployment_template_common_param(c, name_required=True, version_required=True)
add_override_param(c)
add_description_param(c, help_message="Description of the deployment template.")
add_tags_param(c)
c.argument(
"registry_name",
options_list=["--registry-name", "-r"],
required=True,
help=(
"Name of the registry. This is required since deployment templates "
"only support registry-name and not workspace."
),
)

with self.argument_context("ml deployment-template archive") as c:
add_common_params(c)
add_deployment_template_common_param(c, name_required=True, version_required=True)
add_lro_param(c)
c.argument(
"registry_name",
options_list=["--registry-name", "-r"],
required=True,
help=(
"Name of the registry. This is required since deployment templates "
"only support registry-name and not workspace."
),
)

with self.argument_context("ml deployment-template restore") as c:
add_common_params(c)
add_deployment_template_common_param(c, name_required=True, version_required=True)
add_lro_param(c)
c.argument(
"registry_name",
options_list=["--registry-name", "-r"],
required=True,
help=(
"Name of the registry. This is required since deployment templates "
"only support registry-name and not workspace."
),
)
19 changes: 19 additions & 0 deletions src/machinelearningservices/azext_mlv2/manual/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,25 @@ def load_command_table(self, _):
supports_no_wait=True,
)

with self.command_group("ml deployment-template", client_factory=cf_ml_cl) as g:
custom_tmpl = "azext_mlv2.manual.custom.deployment_template#{}"
custom_deployment_template = CliCommandType(operations_tmpl=custom_tmpl)
g.custom_command("list", "ml_deployment_template_list", command_type=custom_deployment_template)
g.custom_command("get", "ml_deployment_template_get", command_type=custom_deployment_template)
g.custom_command("create", "ml_deployment_template_create", supports_no_wait=True,
command_type=custom_deployment_template)
g.generic_update_command(
"update",
getter_name="ml_deployment_template_get",
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

The getter function name should be _ml_deployment_template_show to match the generic_update_command pattern used elsewhere in this file. The function _ml_deployment_template_show is defined in deployment_template.py (line 162) but ml_deployment_template_get is referenced here as the getter, which will cause the update command to fail.

Suggested change
getter_name="ml_deployment_template_get",
getter_name="_ml_deployment_template_show",

Copilot uses AI. Check for mistakes.
getter_type=custom_deployment_template,
setter_name="_ml_deployment_template_update",
setter_type=custom_deployment_template,
)
g.custom_command("archive", "ml_deployment_template_archive", supports_no_wait=True,
command_type=custom_deployment_template)
g.custom_command("restore", "ml_deployment_template_restore", supports_no_wait=True,
command_type=custom_deployment_template)

with self.command_group("ml compute", client_factory=cf_ml_cl) as g:
custom_tmpl = "azext_mlv2.manual.custom.compute#{}"
custom_compute = CliCommandType(operations_tmpl=custom_tmpl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from .connection import * # pylint: disable=wrong-import-position
from .data import * # pylint: disable=wrong-import-position
from .datastore import * # pylint: disable=wrong-import-position
from .deployment_template import * # pylint: disable=wrong-import-position
from .environment import * # pylint: disable=wrong-import-position
from .feature_set import * # pylint: disable=wrong-import-position
from .feature_store import * # pylint: disable=wrong-import-position,unused-wildcard-import
Expand Down
Loading
Loading