Skip to content

Commit 8949ee5

Browse files
authored
[Aks]Fix the issue Aks cannot be update in Automation Runbook. (#15109)
* Fix the issue Aks cannot be update in Automation Runbook. * Fix the issue Aks cannot be update in Automation Runbook. Co-authored-by: wyunchi-ms <[email protected]>
1 parent 6d85b80 commit 8949ee5

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/Aks/Aks/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Fixed the issue that `Set-AzAks` will fail in Automation Runbook. [#15006]
2122

2223
## Version 2.1.0
2324
* Added support `AcrNameToAttach` in `Set-AzAksCluster`. [#14692]

src/Aks/Aks/Commands/SetAzureRmAks.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,18 @@ public override void ExecuteCmdlet()
289289
cluster = BuildNewCluster();
290290
}
291291

292-
acsServicePrincipal = EnsureServicePrincipal(ServicePrincipalIdAndSecret?.UserName, ServicePrincipalIdAndSecret?.Password?.ConvertToString());
293-
if (this.IsParameterBound(c => c.AcrNameToAttach))
292+
if (this.IsParameterBound(c => c.AcrNameToAttach) ||
293+
this.IsParameterBound(c => c.AcrNameToDetach))
294294
{
295-
AddAcrRoleAssignment(AcrNameToAttach, nameof(AcrNameToAttach), acsServicePrincipal);
296-
}
297-
if (this.IsParameterBound(c => c.AcrNameToDetach))
298-
{
299-
RemoveAcrRoleAssignment(AcrNameToDetach, nameof(AcrNameToDetach), acsServicePrincipal);
295+
acsServicePrincipal = EnsureServicePrincipal(ServicePrincipalIdAndSecret?.UserName, ServicePrincipalIdAndSecret?.Password?.ConvertToString());
296+
if (this.IsParameterBound(c => c.AcrNameToAttach))
297+
{
298+
AddAcrRoleAssignment(AcrNameToAttach, nameof(AcrNameToAttach), acsServicePrincipal);
299+
}
300+
if (this.IsParameterBound(c => c.AcrNameToDetach))
301+
{
302+
RemoveAcrRoleAssignment(AcrNameToDetach, nameof(AcrNameToDetach), acsServicePrincipal);
303+
}
300304
}
301305

302306
var kubeCluster = Client.ManagedClusters.CreateOrUpdate(ResourceGroupName, Name, cluster);

0 commit comments

Comments
 (0)