From ebdc33b879f2f46cce64163476fbe7968056ff91 Mon Sep 17 00:00:00 2001 From: Avisikta Patra Date: Mon, 2 Mar 2026 10:21:04 +0530 Subject: [PATCH 1/7] List instances and List revision should use ST Id not name --- .../target/_solution_instance_list.py | 11 +++- .../target/_solution_revision_list.py | 11 +++- .../target/_target_helper.py | 60 +++++++++++++++++++ 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_instance_list.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_instance_list.py index b9b3eb5ec91..c3f51badf41 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_instance_list.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_instance_list.py @@ -9,6 +9,7 @@ # flake8: noqa from azure.cli.core.aaz import * +from ._target_helper import TargetHelper @register_command( @@ -89,6 +90,14 @@ class SolutionInstancesList(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" def __call__(self, *args, **kwargs): + # Resolve solution template name to its uniqueIdentifier + self.unique_identifier = TargetHelper.get_solution_template_unique_identifier( + self.ctx.subscription_id, + self.ctx.args.resource_group, + self.ctx.args.solution_name, + self.client + ) + request = self.make_request() session = self.client.send_request(request=request, stream=False, **kwargs) if session.http_response.status_code in [200]: @@ -127,7 +136,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "solutionName", self.ctx.args.solution_name, + "solutionName", self.unique_identifier, required=True, ), } diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_revision_list.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_revision_list.py index 48bcb2fdc1e..ae13ca619e7 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_revision_list.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_revision_list.py @@ -9,6 +9,7 @@ # flake8: noqa from azure.cli.core.aaz import * +from ._target_helper import TargetHelper @register_command( @@ -92,6 +93,14 @@ class TargetSolutionRevisionsList(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" def __call__(self, *args, **kwargs): + # Resolve solution template name to its uniqueIdentifier + self.unique_identifier = TargetHelper.get_solution_template_unique_identifier( + self.ctx.subscription_id, + self.ctx.args.resource_group, + self.ctx.args.solution_name, + self.client + ) + request = self.make_request() session = self.client.send_request(request=request, stream=False, **kwargs) if session.http_response.status_code in [200]: @@ -122,7 +131,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "solutionName", self.ctx.args.solution_name, + "solutionName", self.unique_identifier, required=True, ), **self.serialize_url_param( diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py new file mode 100644 index 00000000000..d5967a428c4 --- /dev/null +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py @@ -0,0 +1,60 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + + +class TargetHelper: + """Shared helper for target commands.""" + + @staticmethod + def get_solution_template_unique_identifier(subscription_id, resource_group_name, template_name, client): + """Fetch the solution template and return its uniqueIdentifier from properties. + + Args: + subscription_id: The subscription ID + resource_group_name: The resource group name + template_name: The solution template name + client: HTTP client for making the request + + Returns: + str: The uniqueIdentifier from template properties, or template_name as fallback + + Raises: + CLIInternalError: If the template does not exist or the request fails + """ + from azure.cli.core.azclierror import CLIInternalError + import json + + template_url = client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/solutionTemplates/{solutionTemplateName}", + subscriptionId=subscription_id, + resourceGroupName=resource_group_name, + solutionTemplateName=template_name + ) + request = client._request("GET", template_url, { + "api-version": "2025-08-01" + }, { + "Accept": "application/json" + }, None, {}, None) + + response = client.send_request(request=request, stream=False) + + if response.http_response.status_code == 404: + raise CLIInternalError( + f"Solution template '{template_name}' not found in resource group '{resource_group_name}'." + ) + if response.http_response.status_code != 200: + raise CLIInternalError( + f"Failed to get solution template '{template_name}': HTTP {response.http_response.status_code}" + ) + + data = json.loads(response.http_response.text()) + unique_identifier = data.get("properties", {}).get("uniqueIdentifier") + + if unique_identifier and unique_identifier.strip(): + return unique_identifier + return template_name From 9e85d1370478460a5b3fb90f0ae9c73ec6c5fb60 Mon Sep 17 00:00:00 2001 From: Avisikta Patra Date: Mon, 2 Mar 2026 10:27:45 +0530 Subject: [PATCH 2/7] Add history --- src/workload-orchestration/HISTORY.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/workload-orchestration/HISTORY.rst b/src/workload-orchestration/HISTORY.rst index 2b72d000c45..4a748f5b6a4 100644 --- a/src/workload-orchestration/HISTORY.rst +++ b/src/workload-orchestration/HISTORY.rst @@ -3,6 +3,11 @@ Release History =============== +5.2.0 +++++++ +* Resolved solution template name to uniqueIdentifier for ``az workload-orchestration target solution-revision-list`` and ``az workload-orchestration target solution-instance-list`` +* Added shared ``_target_helper.py`` for reusable solution template resolution logic + 5.0.0 ++++++ * November 2025 release From 94c1821918a6df65ab45e2f2f4f4cc5ddf389a69 Mon Sep 17 00:00:00 2001 From: Avisikta Patra Date: Mon, 2 Mar 2026 10:28:38 +0530 Subject: [PATCH 3/7] upgrade version --- src/workload-orchestration/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workload-orchestration/setup.py b/src/workload-orchestration/setup.py index 32448955dc4..732d09b9559 100644 --- a/src/workload-orchestration/setup.py +++ b/src/workload-orchestration/setup.py @@ -10,7 +10,7 @@ # HISTORY.rst entry. -VERSION = '5.1.0' +VERSION = '5.2.0' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers From 82cb3e5e7cf70bc1ae1c83f85bb35901a2a8d2b5 Mon Sep 17 00:00:00 2001 From: Avisikta Patra Date: Mon, 2 Mar 2026 10:29:28 +0530 Subject: [PATCH 4/7] Fix the version sequence in history file --- src/workload-orchestration/HISTORY.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/workload-orchestration/HISTORY.rst b/src/workload-orchestration/HISTORY.rst index 0f9c0d42386..da4a578bb22 100644 --- a/src/workload-orchestration/HISTORY.rst +++ b/src/workload-orchestration/HISTORY.rst @@ -2,17 +2,17 @@ Release History =============== +5.2.0 +++++++ +* Resolved solution template name to uniqueIdentifier for ``az workload-orchestration target solution-revision-list`` and ``az workload-orchestration target solution-instance-list`` +* Added shared ``_target_helper.py`` for reusable solution template resolution logic + 5.1.0 ++++++ * Added new target solution management command: * ``az workload-orchestration target unstage`` - Unstage a solution version from a target * Added double confirmation before ``az workload-orchestration target remove-revision`` to prevent accidental deletions -5.2.0 -++++++ -* Resolved solution template name to uniqueIdentifier for ``az workload-orchestration target solution-revision-list`` and ``az workload-orchestration target solution-instance-list`` -* Added shared ``_target_helper.py`` for reusable solution template resolution logic - 5.0.0 ++++++ * November 2025 release From 2845dd8e4f78f8f54abc005adbca6ac7f0c0e615 Mon Sep 17 00:00:00 2001 From: Avisikta Patra Date: Mon, 2 Mar 2026 10:41:47 +0530 Subject: [PATCH 5/7] fix review comments --- src/workload-orchestration/HISTORY.rst | 2 +- src/workload-orchestration/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/workload-orchestration/HISTORY.rst b/src/workload-orchestration/HISTORY.rst index da4a578bb22..17f30fdae16 100644 --- a/src/workload-orchestration/HISTORY.rst +++ b/src/workload-orchestration/HISTORY.rst @@ -2,7 +2,7 @@ Release History =============== -5.2.0 +5.1.1 ++++++ * Resolved solution template name to uniqueIdentifier for ``az workload-orchestration target solution-revision-list`` and ``az workload-orchestration target solution-instance-list`` * Added shared ``_target_helper.py`` for reusable solution template resolution logic diff --git a/src/workload-orchestration/setup.py b/src/workload-orchestration/setup.py index 732d09b9559..d0abcead415 100644 --- a/src/workload-orchestration/setup.py +++ b/src/workload-orchestration/setup.py @@ -10,7 +10,7 @@ # HISTORY.rst entry. -VERSION = '5.2.0' +VERSION = '5.1.1' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers From 9630b19115773735a789e0c82bda9ca7ab146454 Mon Sep 17 00:00:00 2001 From: Avishikta Date: Mon, 2 Mar 2026 10:45:55 +0530 Subject: [PATCH 6/7] Update src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../aaz/latest/workload_orchestration/target/_target_helper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py index d5967a428c4..3df876fdbc5 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py @@ -2,6 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- +# Code generated by aaz-dev-tools. DO NOT EDIT. # pylint: skip-file # flake8: noqa From dafc862fe8743844896098fa6df99d132a651b96 Mon Sep 17 00:00:00 2001 From: Avishikta Date: Mon, 2 Mar 2026 10:47:32 +0530 Subject: [PATCH 7/7] Update src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../target/_target_helper.py | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py index 3df876fdbc5..91f27810d59 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_target_helper.py @@ -42,20 +42,30 @@ def get_solution_template_unique_identifier(subscription_id, resource_group_name "Accept": "application/json" }, None, {}, None) - response = client.send_request(request=request, stream=False) + try: + response = client.send_request(request=request, stream=False) - if response.http_response.status_code == 404: - raise CLIInternalError( - f"Solution template '{template_name}' not found in resource group '{resource_group_name}'." - ) - if response.http_response.status_code != 200: - raise CLIInternalError( - f"Failed to get solution template '{template_name}': HTTP {response.http_response.status_code}" - ) + if response.http_response.status_code == 404: + raise CLIInternalError( + f"Solution template '{template_name}' not found in resource group '{resource_group_name}'." + ) + if response.http_response.status_code != 200: + raise CLIInternalError( + f"Failed to get solution template '{template_name}': HTTP {response.http_response.status_code}" + ) - data = json.loads(response.http_response.text()) - unique_identifier = data.get("properties", {}).get("uniqueIdentifier") + data = json.loads(response.http_response.text()) + unique_identifier = data.get("properties", {}).get("uniqueIdentifier") - if unique_identifier and unique_identifier.strip(): - return unique_identifier - return template_name + if unique_identifier and unique_identifier.strip(): + return unique_identifier + return template_name + except CLIInternalError: + # Propagate explicitly raised CLIInternalError instances unchanged. + raise + except Exception as exc: + # Wrap unexpected errors (e.g., network issues, JSON parsing failures) + # in CLIInternalError to match the documented behavior. + raise CLIInternalError( + f"Failed to get solution template '{template_name}': {exc}" + ) from exc