From debb5ca2c4dbc88090c19c3fe38bf178d10a613f Mon Sep 17 00:00:00 2001 From: wyunchi-ms Date: Wed, 26 May 2021 09:53:33 +0800 Subject: [PATCH 1/2] Fix the issue Aks cannot be update in Automation Runbook. --- src/Aks/Aks/Commands/SetAzureRmAks.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Aks/Aks/Commands/SetAzureRmAks.cs b/src/Aks/Aks/Commands/SetAzureRmAks.cs index d9cf59dc5d56..baeddedb24a6 100644 --- a/src/Aks/Aks/Commands/SetAzureRmAks.cs +++ b/src/Aks/Aks/Commands/SetAzureRmAks.cs @@ -289,14 +289,18 @@ public override void ExecuteCmdlet() cluster = BuildNewCluster(); } - acsServicePrincipal = EnsureServicePrincipal(ServicePrincipalIdAndSecret?.UserName, ServicePrincipalIdAndSecret?.Password?.ConvertToString()); - if (this.IsParameterBound(c => c.AcrNameToAttach)) + if (this.IsParameterBound(c => c.AcrNameToAttach) || + this.IsParameterBound(c => c.AcrNameToDetach)) { - AddAcrRoleAssignment(AcrNameToAttach, nameof(AcrNameToAttach), acsServicePrincipal); - } - if (this.IsParameterBound(c => c.AcrNameToDetach)) - { - RemoveAcrRoleAssignment(AcrNameToDetach, nameof(AcrNameToDetach), acsServicePrincipal); + acsServicePrincipal = EnsureServicePrincipal(ServicePrincipalIdAndSecret?.UserName, ServicePrincipalIdAndSecret?.Password?.ConvertToString()); + if (this.IsParameterBound(c => c.AcrNameToAttach)) + { + AddAcrRoleAssignment(AcrNameToAttach, nameof(AcrNameToAttach), acsServicePrincipal); + } + if (this.IsParameterBound(c => c.AcrNameToDetach)) + { + RemoveAcrRoleAssignment(AcrNameToDetach, nameof(AcrNameToDetach), acsServicePrincipal); + } } var kubeCluster = Client.ManagedClusters.CreateOrUpdate(ResourceGroupName, Name, cluster); From 8e528f5e9546dddaa3af60563b55648a1c68dff5 Mon Sep 17 00:00:00 2001 From: wyunchi-ms Date: Wed, 26 May 2021 09:56:49 +0800 Subject: [PATCH 2/2] Fix the issue Aks cannot be update in Automation Runbook. --- src/Aks/Aks/ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Aks/Aks/ChangeLog.md b/src/Aks/Aks/ChangeLog.md index 8538122ffd7e..26dcff8af842 100644 --- a/src/Aks/Aks/ChangeLog.md +++ b/src/Aks/Aks/ChangeLog.md @@ -18,6 +18,7 @@ - Additional information about change #1 --> ## Upcoming Release +* Fixed the issue that `Set-AzAks` will fail in Automation Runbook. [#15006] ## Version 2.1.0 * Added support `AcrNameToAttach` in `Set-AzAksCluster`. [#14692]