@@ -25,7 +25,7 @@ API to set properties of the connected cluster resource
25
25
. Description
26
26
API to set properties of the connected cluster resource
27
27
. Example
28
- Set-AzConnectedKubernetes -ClusterName azps_test_cluster -ResourceGroupName azps_test_group -Location eastus -EnableGateway - GatewayResourceId $gatewayResourceId
28
+ Set-AzConnectedKubernetes -ClusterName azps_test_cluster -ResourceGroupName azps_test_group -Location eastus -GatewayResourceId $gatewayResourceId
29
29
. Example
30
30
Set-AzConnectedKubernetes -ClusterName azps_test_cluster1 -ResourceGroupName azps_test_group -Location eastus -KubeConfig $HOME\.kube\config -KubeContext azps_aks_t01 -DisableGateway
31
31
@@ -87,7 +87,6 @@ function Set-AzConnectedKubernetes {
87
87
Justification = ' Code published before this issue was identified' )]
88
88
param (
89
89
[Parameter (ParameterSetName = ' SetExpanded' , Mandatory )]
90
- [Parameter (ParameterSetName = ' SetExpandedEnableGateway' , Mandatory )]
91
90
[Parameter (ParameterSetName = ' SetExpandedDisableGateway' , Mandatory )]
92
91
[Alias (' Name' )]
93
92
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category (' Path' )]
@@ -96,7 +95,6 @@ function Set-AzConnectedKubernetes {
96
95
${ClusterName} ,
97
96
98
97
[Parameter (ParameterSetName = ' SetExpanded' , Mandatory )]
99
- [Parameter (ParameterSetName = ' SetExpandedEnableGateway' , Mandatory )]
100
98
[Parameter (ParameterSetName = ' SetExpandedDisableGateway' , Mandatory )]
101
99
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category (' Path' )]
102
100
[System.String ]
@@ -105,15 +103,13 @@ function Set-AzConnectedKubernetes {
105
103
${ResourceGroupName} ,
106
104
107
105
[Parameter (ParameterSetName = ' SetExpanded' , Mandatory )]
108
- [Parameter (ParameterSetName = ' SetExpandedEnableGateway' , Mandatory )]
109
106
[Parameter (ParameterSetName = ' SetExpandedDisableGateway' , Mandatory )]
110
107
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category (' Body' )]
111
108
[System.String ]
112
109
# The geo-location where the resource lives
113
110
${Location} ,
114
111
115
112
[Parameter (ParameterSetName = ' Set' , Mandatory )]
116
- [Parameter (ParameterSetName = ' SetEnableGateway' , Mandatory )]
117
113
[Parameter (ParameterSetName = ' SetDisableGateway' , Mandatory )]
118
114
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category (' Body' )]
119
115
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Models.Api20240715Preview.IConnectedCluster ]
@@ -326,12 +322,6 @@ function Set-AzConnectedKubernetes {
326
322
# Arc Agentry System Protected Configuration
327
323
${ConfigurationProtectedSetting} ,
328
324
329
- [Parameter (ParameterSetName = ' SetEnableGateway' , Mandatory )]
330
- [Parameter (ParameterSetName = ' SetExpandedEnableGateway' , Mandatory )]
331
- [Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category (' body' )]
332
- [System.Management.Automation.SwitchParameter ]
333
- ${EnableGateway} ,
334
-
335
325
[Parameter (ParameterSetName = ' SetDisableGateway' , Mandatory )]
336
326
[Parameter (ParameterSetName = ' SetExpandedDisableGateway' , Mandatory )]
337
327
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category (' body' )]
@@ -341,7 +331,7 @@ function Set-AzConnectedKubernetes {
341
331
[Parameter ()]
342
332
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category (' body' )]
343
333
[System.String ]
344
- # Arc Gateway resource Id
334
+ # Arc Gateway resource Id, providing this will enable the gateway
345
335
${GatewayResourceId}
346
336
)
347
337
@@ -415,10 +405,7 @@ function Set-AzConnectedKubernetes {
415
405
$ResourceGroupName = $InputObject.ResourceGroupName
416
406
$PSBoundParameters.Add (' ResourceGroupName' , $ResourceGroupName )
417
407
418
- if ((-not $PSBoundParameters.ContainsKey (' EnableGateway' )) -and (-not $PSBoundParameters.ContainsKey (' DisableGateway' ))) {
419
- if ($InputObject.GatewayEnabled ) {
420
- $EnableGateway = $InputObject.GatewayEnabled
421
- }
408
+ if (-not $PSBoundParameters.ContainsKey (' DisableGateway' )) {
422
409
if (-not $InputObject.GatewayEnabled ) {
423
410
$DisableGateway = -not $InputObject.GatewayEnabled
424
411
}
@@ -427,11 +414,14 @@ function Set-AzConnectedKubernetes {
427
414
$GatewayResourceId = $InputObject.GatewayResourceId
428
415
$PSBoundParameters.Add (' GatewayResourceId' , $GatewayResourceId )
429
416
}
417
+
418
+ if (-not $PSBoundParameters.ContainsKey (' DisableAutoUpgrade' )) {
419
+ $DisableAutoUpgrade = ($InputObject.ArcAgentProfileAgentAutoUpgrade -eq ' Disabled' )
420
+ }
430
421
}
431
422
432
- if ($EnableGateway ) {
423
+ if (-not [ String ]::IsNullOrEmpty( $GatewayResourceId ) -and -not $DisableGateway ) {
433
424
Write-Debug " Gateway enabled"
434
- $Null = $PSBoundParameters.Remove (' EnableGateway' )
435
425
$PSBoundParameters.Add (' GatewayEnabled' , $true )
436
426
}
437
427
# If DisableGateway is provided then set the gateway as disabled and remove gateway resourceId from parameters
@@ -472,7 +462,6 @@ function Set-AzConnectedKubernetes {
472
462
$ReleaseNamespace = $ReleaseNamespaces [' ReleaseNamespace' ]
473
463
$ReleaseInstallNamespace = $ReleaseNamespaces [' ReleaseInstallNamespace' ]
474
464
475
-
476
465
# Endregion
477
466
478
467
# Region validate release namespace
@@ -511,9 +500,9 @@ function Set-AzConnectedKubernetes {
511
500
512
501
$options = " "
513
502
514
- if ($DisableAutoUpgrade ) {
515
- $options += " --set systemDefaultValues.azureArcAgents.autoUpdate=false"
503
+ if ($DisableAutoUpgrade -or ($ExistConnectedKubernetes.ArcAgentProfileAgentAutoUpgrade -eq ' Disabled' )) {
516
504
$Null = $PSBoundParameters.Remove (' DisableAutoUpgrade' )
505
+ $PSBoundParameters.Add (' ArcAgentProfileAgentAutoUpgrade' , ' Disabled' )
517
506
}
518
507
if (-not ([string ]::IsNullOrEmpty($ContainerLogPath ))) {
519
508
$options += " --set systemDefaultValues.fluent-bit.containerLogPath=$ContainerLogPath "
@@ -549,6 +538,17 @@ function Set-AzConnectedKubernetes {
549
538
# Endregion
550
539
551
540
# Region Deal with configuration settings and protected settings
541
+
542
+ # If the user does not provide proxy settings, or configuration settings, we shall use arc config of existing object
543
+ $userProvidedArcConfiguration = (
544
+ ($null -ne $InputObject ) -and ($InputObject.ArcAgentryConfiguration.Length > 0 ) `
545
+ -and (-not ([string ]::IsNullOrEmpty($HttpProxy ))) `
546
+ -and (-not ([string ]::IsNullOrEmpty($HttpsProxy ))) `
547
+ -and (-not ([string ]::IsNullOrEmpty($NoProxy ))) `
548
+ -and ((-not ([string ]::IsNullOrEmpty($ProxyCert )))) `
549
+ -and ($PSBoundParameters.ContainsKey (' ConfigurationSetting' )) `
550
+ -and ($PSBoundParameters.ContainsKey (' ConfigurationProtectedSetting' )))
551
+
552
552
if ($null -eq $ConfigurationSetting ) {
553
553
$ConfigurationSetting = @ {}
554
554
}
@@ -654,9 +654,18 @@ function Set-AzConnectedKubernetes {
654
654
$PSBoundParameters.Remove (' ConfigurationProtectedSetting' )
655
655
}
656
656
657
- $PSBoundParameters.Add (' ArcAgentryConfiguration' , $arcAgentryConfigs )
657
+ if ($userProvidedArcConfiguration ) {
658
+ $PSBoundParameters.Add (' ArcAgentryConfiguration' , $arcAgentryConfigs )
659
+ } else {
660
+ $PSBoundParameters.Add (' ArcAgentryConfiguration' , $ExistConnectedKubernetes.ArcAgentryConfiguration )
661
+ }
658
662
663
+ Write-Output " Updating the connected cluster resource...."
659
664
$Response = Az.ConnectedKubernetes.internal\Set-AzConnectedKubernetes @PSBoundParameters
665
+ if ((-not $WhatIfPreference ) -and (-not $Response )) {
666
+ Write-Error " Failed to update the 'Kubernetes - Azure Arc' resource"
667
+ return
668
+ }
660
669
$arcAgentryConfigs = ConvertTo-ArcAgentryConfiguration - ConfigurationSetting $ConfigurationSetting - RedactedProtectedConfiguration $RedactedProtectedConfiguration - CCRP $false
661
670
662
671
# Convert the $Response object into a nested hashtable.
@@ -671,13 +680,20 @@ function Set-AzConnectedKubernetes {
671
680
$Response [' properties' ] = @ {}
672
681
}
673
682
674
- $Response [' properties' ][' arcAgentryConfigurations' ] = $arcAgentryConfigs
683
+ if ($userProvidedArcConfiguration ) {
684
+ $Response [' properties' ][' arcAgentryConfigurations' ] = $arcAgentryConfigs
685
+ } else {
686
+ $Response [' properties' ][' arcAgentryConfigurations' ] = $ExistConnectedKubernetes.ArcAgentryConfiguration
687
+ }
688
+
675
689
676
690
# Retrieving Helm chart OCI (Open Container Initiative) Artifact location
677
691
Write-Debug " Retrieving Helm chart OCI (Open Container Initiative) Artifact location."
678
692
$ResponseStr = $Response | ConvertTo-Json - Depth 10
679
693
Write-Debug " PUT response: $ResponseStr "
680
694
695
+ Write-Output " Preparing helm ...."
696
+
681
697
if ($PSCmdlet.ShouldProcess (' configDP' , ' get helm values from config DP' )) {
682
698
$helmValuesDp = Get-HelmValuesFromConfigDP `
683
699
- configDPEndpoint $configDPEndpoint `
@@ -741,6 +757,7 @@ function Set-AzConnectedKubernetes {
741
757
}
742
758
}
743
759
760
+ Write-Output " Executing helm upgrade, this can take a few minutes ...."
744
761
Write-Debug $options - ErrorAction Continue
745
762
if ($DebugPreference -eq " Continue" ) {
746
763
$options += " --debug"
@@ -765,7 +782,7 @@ function Set-AzConnectedKubernetes {
765
782
if ($PSBoundParameters.ContainsKey (' OidcIssuerProfileEnabled' ) -or $PSBoundParameters.ContainsKey (' WorkloadIdentityEnabled' ) ) {
766
783
$ExistConnectedKubernetes = Get-AzConnectedKubernetes - ResourceGroupName $ResourceGroupName - ClusterName $ClusterName @CommonPSBoundParameters
767
784
768
- Write-Host " Cluster configuration is in progress..."
785
+ Write-Output " Cluster configuration is in progress..."
769
786
$timeout = [datetime ]::Now.AddMinutes(60 )
770
787
771
788
while (($ExistConnectedKubernetes.ArcAgentProfileAgentState -ne " Succeeded" ) -and ($ExistConnectedKubernetes.ArcAgentProfileAgentState -ne " Failed" ) -and ([datetime ]::Now -lt $timeout )) {
@@ -774,7 +791,7 @@ function Set-AzConnectedKubernetes {
774
791
}
775
792
776
793
if ($ExistConnectedKubernetes.ArcAgentProfileAgentState -eq " Succeeded" ) {
777
- Write-Host " Cluster configuration succeeded."
794
+ Write-Output " Cluster configuration succeeded."
778
795
} elseif ($ExistConnectedKubernetes.ArcAgentProfileAgentState -eq " Failed" ) {
779
796
Write-Error " Cluster configuration failed."
780
797
} else {
0 commit comments