From c0e0a4e4d15b2487817834d6dfb1494273308735 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 May 2026 04:44:47 +0000 Subject: [PATCH 1/3] Initial plan From 84840997329c059ec5143ed71b1327ad715fd916 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 May 2026 04:49:34 +0000 Subject: [PATCH 2/3] fix(aks): improve outbound type update error for managed vnet clusters Agent-Logs-Url: https://github.com/Azure/azure-cli/sessions/89434938-59be-4bd2-8316-b23911d26c91 Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com> --- .../acs/managed_cluster_decorator.py | 14 ++++++++++++-- .../latest/test_managed_cluster_decorator.py | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py b/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py index 6efebb3201c..c347c9ecc28 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py +++ b/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py @@ -2366,13 +2366,23 @@ def get_sku_name(self) -> str: skuName = CONST_MANAGED_CLUSTER_SKU_NAME_BASE return skuName - @staticmethod - def _raise_missing_vnet_subnet_for_outbound_type(outbound_type: str, sku_name: str) -> None: + def _raise_missing_vnet_subnet_for_outbound_type(self, outbound_type: str, sku_name: str) -> None: if outbound_type == CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING: subnet_requirement = "a route table with egress rules" else: subnet_requirement = "a NAT gateway with outbound ips" + if self.decorator_mode == DecoratorMode.UPDATE: + raise InvalidArgumentValueError( + "Updating outbound type to {outbound_type} is only supported for clusters created with " + "--vnet-subnet-id. Clusters using an AKS-managed VNet can't be updated to this outbound type. " + "Please refer to " + "https://learn.microsoft.com/en-us/azure/aks/egress-outboundtype#updating-outboundtype-after-cluster-creation " # pylint:disable=line-too-long + "for more details.".format( + outbound_type=outbound_type, + ) + ) + if sku_name == CONST_MANAGED_CLUSTER_SKU_NAME_AUTOMATIC: raise RequiredArgumentMissingError( "--vnet-subnet-id must be specified for {outbound_type}. For an Automatic cluster " diff --git a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py index be04d278208..ab6a217e15a 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py +++ b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py @@ -2020,6 +2020,24 @@ def test_get_outbound_type(self): ctx_1.attach_mc(mc) self.assertEqual(ctx_1.get_outbound_type(), "test_outbound_type") + ctx_1_1 = AKSManagedClusterContext( + self.cmd, + AKSManagedClusterParamDict( + { + "outbound_type": CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING, + } + ), + self.models, + DecoratorMode.UPDATE, + ) + ctx_1_1.agentpool_context = mock.MagicMock() + ctx_1_1.agentpool_context.get_vnet_subnet_id.return_value = None + with self.assertRaisesRegex( + InvalidArgumentValueError, + "only supported for clusters created with --vnet-subnet-id", + ): + ctx_1_1.get_outbound_type() + # invalid parameter ctx_2 = AKSManagedClusterContext( self.cmd, From 3638afdec2e0524138682b7225ea36b598e308ac Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 May 2026 04:50:25 +0000 Subject: [PATCH 3/3] chore(aks): refine outbound type update error string formatting Agent-Logs-Url: https://github.com/Azure/azure-cli/sessions/89434938-59be-4bd2-8316-b23911d26c91 Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com> --- .../cli/command_modules/acs/managed_cluster_decorator.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py b/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py index c347c9ecc28..e46511f1097 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py +++ b/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py @@ -2374,13 +2374,11 @@ def _raise_missing_vnet_subnet_for_outbound_type(self, outbound_type: str, sku_n if self.decorator_mode == DecoratorMode.UPDATE: raise InvalidArgumentValueError( - "Updating outbound type to {outbound_type} is only supported for clusters created with " + f"Updating outbound type to {outbound_type} is only supported for clusters created with " "--vnet-subnet-id. Clusters using an AKS-managed VNet can't be updated to this outbound type. " "Please refer to " "https://learn.microsoft.com/en-us/azure/aks/egress-outboundtype#updating-outboundtype-after-cluster-creation " # pylint:disable=line-too-long - "for more details.".format( - outbound_type=outbound_type, - ) + "for more details." ) if sku_name == CONST_MANAGED_CLUSTER_SKU_NAME_AUTOMATIC: