Skip to content

Commit 17780d0

Browse files
Deployment templates - CLI (#9320)
* deployment templates - CLI * Update command modify * make reg and version mandatory * update documentation * adding changelog
1 parent 73d1a91 commit 17780d0

File tree

12 files changed

+1044
-0
lines changed

12 files changed

+1044
-0
lines changed

src/machinelearningservices/CHANGELOG.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## 2025-11-04
2+
3+
### Azure Machine Learning CLI (v2) v 2.40.0
4+
- `az ml deployment-template create`
5+
- Create a new deployment template from a YAML file.
6+
- `az ml deployment-template list`
7+
- List deployment templates in a registry
8+
- `az ml deployment-template get`
9+
- Get a specific deployment template by name and version.
10+
- `az ml deployment-template update`
11+
- Update specific fields of an existing deployment template.
12+
- `az ml deployment-template archive`
13+
- Archive a deployment template.
14+
- `az ml deployment-template restore`
15+
- Restore an archived deployment template.
16+
117
## 2025-08-27
218

319
### Azure Machine Learning CLI (v2) v 2.39.0

src/machinelearningservices/azext_mlv2/manual/_help/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from ._connection_help import get_connection_help
2020
from ._data_help import get_data_help
2121
from ._datastore_help import get_datastore_help
22+
from ._deployment_template_help import get_deployment_template_help
2223
from ._environment_help import get_environment_help
2324
from ._feature_set_help import get_feature_set_help
2425
from ._feature_store_entity_help import get_feature_store_entity_help
@@ -50,6 +51,7 @@
5051
get_workspace_help()
5152
get_workspace_outbound_rule_help()
5253
get_datastore_help()
54+
get_deployment_template_help()
5355
get_component_help()
5456
get_connection_help()
5557
get_schedule_help()
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# ---------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# ---------------------------------------------------------
4+
5+
from knack.help_files import helps
6+
7+
8+
def get_deployment_template_help():
9+
"""Load deployment template help content."""
10+
pass # Help content is defined below using helps dictionary
11+
12+
helps['ml deployment-template'] = """
13+
type: group
14+
short-summary: Manage Azure ML deployment templates.
15+
long-summary: |
16+
Deployment templates are reusable templates that define deployment configurations for Azure ML.
17+
They support registry-based operations only (not workspace-based) and provide a way to
18+
standardize and share deployment configurations across teams and projects.
19+
"""
20+
21+
helps['ml deployment-template list'] = """
22+
type: command
23+
short-summary: List deployment templates in a registry.
24+
long-summary: |
25+
List all deployment templates available in the specified registry. This command
26+
returns all templates along with their metadata including name, version, description, and tags.
27+
examples:
28+
- name: List all deployment templates in a registry
29+
text: az ml deployment-template list --registry-name myregistry
30+
- name: List deployment templates with specific output format
31+
text: az ml deployment-template list --registry-name myregistry --output table
32+
"""
33+
34+
helps['ml deployment-template get'] = """
35+
type: command
36+
short-summary: Get a specific deployment template by name and version.
37+
long-summary: |
38+
Retrieve detailed information about a specific deployment template. If version is not
39+
specified, the latest version will be returned.
40+
examples:
41+
- name: Get a specific version of a deployment template
42+
text: az ml deployment-template get --name my-template --version 1 --registry-name myregistry
43+
"""
44+
45+
helps['ml deployment-template create'] = """
46+
type: command
47+
short-summary: Create a new deployment template from a YAML file.
48+
long-summary: |
49+
Create a new deployment template using a YAML configuration file. The YAML file should
50+
contain the complete deployment template definition including endpoints, parameters, and metadata.
51+
You can override specific values using command-line parameters.
52+
examples:
53+
- name: Create a deployment template from a YAML file
54+
text: az ml deployment-template create --file template.yml --registry-name myregistry
55+
- name: Create with name and version overrides
56+
text: az ml deployment-template create --file template.yml --name custom-template --version 2 --registry-name myregistry
57+
- name: Create without waiting for completion
58+
text: az ml deployment-template create --file template.yml --registry-name myregistry --no-wait
59+
"""
60+
61+
helps['ml deployment-template update'] = """
62+
type: command
63+
short-summary: Update specific fields of an existing deployment template.
64+
long-summary: |
65+
Update metadata fields (description and tags) of an existing deployment template without
66+
requiring a YAML file. This command follows Azure CLI conventions and only accepts specific
67+
field updates. Tags are merged with existing tags rather than replaced.
68+
69+
For structural changes to the deployment template (endpoints, deployment configuration, etc.),
70+
use the 'create' command with a YAML file.
71+
examples:
72+
- name: Update deployment template description
73+
text: az ml deployment-template update --name my-template --version 1 --registry-name myregistry --set "description=Updated description"
74+
- name: Update deployment template tags
75+
text: az ml deployment-template update --name my-template --version 1 --registry-name myregistry --set "tags=environment=production owner=ml-team"
76+
- name: Update both description and tags
77+
text: az ml deployment-template update --name my-template --version 1 --registry-name myregistry --set "description=Production template" --set "tags=status=active"
78+
"""
79+
80+
helps['ml deployment-template archive'] = """
81+
type: command
82+
short-summary: Archive a deployment template.
83+
long-summary: |
84+
Archive a deployment template to mark it as inactive. Archived templates are not
85+
returned in list operations by default. You can archive a specific version or all
86+
versions of a template.
87+
examples:
88+
- name: Archive a specific version
89+
text: az ml deployment-template archive --name my-template --version 1 --registry-name myregistry
90+
- name: Archive without waiting for completion
91+
text: az ml deployment-template archive --name my-template --version 1 --registry-name myregistry --no-wait
92+
"""
93+
94+
helps['ml deployment-template restore'] = """
95+
type: command
96+
short-summary: Restore an archived deployment template.
97+
long-summary: |
98+
Restore a previously archived deployment template to make it active again. Restored
99+
templates will appear in list operations. You can restore a specific version or all
100+
versions of a template.
101+
examples:
102+
- name: Restore a specific version
103+
text: az ml deployment-template restore --name my-template --version 1 --registry-name myregistry
104+
- name: Restore without waiting for completion
105+
text: az ml deployment-template restore --name my-template --version 1 --registry-name myregistry --no-wait
106+
"""

src/machinelearningservices/azext_mlv2/manual/_params/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from ._connection_params import load_connection_params
1717
from ._data_params import load_data_params
1818
from ._datastore_params import load_datastore_params
19+
from ._deployment_template_params import load_deployment_template_params
1920
from ._environment_params import load_environment_params
2021
from ._feature_set_params import load_feature_set_params
2122
from ._feature_store_entity_params import load_feature_store_entity_params
@@ -44,6 +45,7 @@ def load_arguments(self, _):
4445
load_batch_endpoint_params(self)
4546
load_online_deployment_params(self)
4647
load_batch_deployment_params(self)
48+
load_deployment_template_params(self)
4749
load_environment_params(self)
4850
load_compute_params(self)
4951
load_workspace_params(self)
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# ---------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# ---------------------------------------------------------
4+
5+
from ._common_params import add_common_params, add_description_param, add_file_param, add_lro_param, add_override_param, add_tags_param
6+
7+
8+
def add_deployment_template_common_param(
9+
c,
10+
name_help_message="Name of the deployment template.",
11+
version_help_message="Version of the deployment template.",
12+
name_required=True,
13+
version_required=True,
14+
):
15+
c.argument("name", options_list=["--name", "-n"], help=name_help_message, required=name_required)
16+
c.argument("version", options_list=["--version", "-v"], help=version_help_message, required=version_required)
17+
18+
19+
def load_deployment_template_params(self):
20+
with self.argument_context("ml deployment-template list") as c:
21+
add_common_params(c)
22+
c.argument(
23+
"registry_name",
24+
options_list=["--registry-name", "-r"],
25+
required=True,
26+
help="Name of the registry. This is required since deployment templates only support registry-name and not workspace.",
27+
)
28+
29+
with self.argument_context("ml deployment-template get") as c:
30+
add_common_params(c)
31+
add_deployment_template_common_param(c, name_required=True, version_required=True)
32+
c.argument(
33+
"registry_name",
34+
options_list=["--registry-name", "-r"],
35+
required=True,
36+
help="Name of the registry. This is required since deployment templates only support registry-name and not workspace.",
37+
)
38+
39+
with self.argument_context("ml deployment-template create") as c:
40+
add_common_params(c)
41+
add_deployment_template_common_param(c, name_required=False, version_required=False) # Optional for create since they can come from file
42+
add_lro_param(c)
43+
add_file_param(c, "deployment-template", "https://aka.ms/ml-cli-v2-deployment-template-yaml")
44+
add_override_param(c)
45+
c.argument(
46+
"registry_name",
47+
options_list=["--registry-name", "-r"],
48+
required=True,
49+
help="Name of the registry. This is required since deployment templates only support registry-name and not workspace.",
50+
)
51+
52+
with self.argument_context("ml deployment-template update") as c:
53+
add_common_params(c)
54+
add_deployment_template_common_param(c, name_required=True, version_required=True)
55+
add_override_param(c)
56+
add_description_param(c, help_message="Description of the deployment template.")
57+
add_tags_param(c)
58+
c.argument(
59+
"registry_name",
60+
options_list=["--registry-name", "-r"],
61+
required=True,
62+
help="Name of the registry. This is required since deployment templates only support registry-name and not workspace.",
63+
)
64+
65+
with self.argument_context("ml deployment-template archive") as c:
66+
add_common_params(c)
67+
add_deployment_template_common_param(c, name_required=True, version_required=True)
68+
add_lro_param(c)
69+
c.argument(
70+
"registry_name",
71+
options_list=["--registry-name", "-r"],
72+
required=True,
73+
help="Name of the registry. This is required since deployment templates only support registry-name and not workspace.",
74+
)
75+
76+
with self.argument_context("ml deployment-template restore") as c:
77+
add_common_params(c)
78+
add_deployment_template_common_param(c, name_required=True, version_required=True)
79+
add_lro_param(c)
80+
c.argument(
81+
"registry_name",
82+
options_list=["--registry-name", "-r"],
83+
required=True,
84+
help="Name of the registry. This is required since deployment templates only support registry-name and not workspace.",
85+
)

src/machinelearningservices/azext_mlv2/manual/commands.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,22 @@ def load_command_table(self, _):
226226
supports_no_wait=True,
227227
)
228228

229+
with self.command_group("ml deployment-template", client_factory=cf_ml_cl) as g:
230+
custom_tmpl = "azext_mlv2.manual.custom.deployment_template#{}"
231+
custom_deployment_template = CliCommandType(operations_tmpl=custom_tmpl)
232+
g.custom_command("list", "ml_deployment_template_list", command_type=custom_deployment_template)
233+
g.custom_command("get", "ml_deployment_template_get", command_type=custom_deployment_template)
234+
g.custom_command("create", "ml_deployment_template_create", supports_no_wait=True, command_type=custom_deployment_template)
235+
g.generic_update_command(
236+
"update",
237+
getter_name="ml_deployment_template_get",
238+
getter_type=custom_deployment_template,
239+
setter_name="_ml_deployment_template_update",
240+
setter_type=custom_deployment_template,
241+
)
242+
g.custom_command("archive", "ml_deployment_template_archive", supports_no_wait=True, command_type=custom_deployment_template)
243+
g.custom_command("restore", "ml_deployment_template_restore", supports_no_wait=True, command_type=custom_deployment_template)
244+
229245
with self.command_group("ml compute", client_factory=cf_ml_cl) as g:
230246
custom_tmpl = "azext_mlv2.manual.custom.compute#{}"
231247
custom_compute = CliCommandType(operations_tmpl=custom_tmpl)

src/machinelearningservices/azext_mlv2/manual/custom/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from .connection import * # pylint: disable=wrong-import-position
3737
from .data import * # pylint: disable=wrong-import-position
3838
from .datastore import * # pylint: disable=wrong-import-position
39+
from .deployment_template import * # pylint: disable=wrong-import-position
3940
from .environment import * # pylint: disable=wrong-import-position
4041
from .feature_set import * # pylint: disable=wrong-import-position
4142
from .feature_store import * # pylint: disable=wrong-import-position,unused-wildcard-import

0 commit comments

Comments
 (0)