Skip to content

Commit c8dcd4c

Browse files
Migrate ConnectedKubernetes from generation to main (#26675)
* Move ConnectedKubernetes to main * Update ChangeLog.md --------- Co-authored-by: Yabo Hu <[email protected]>
1 parent 691d74a commit c8dcd4c

11 files changed

+179
-64
lines changed

src/ConnectedKubernetes/ConnectedKubernetes.Autorest/custom/New-AzConnectedKubernetes.ps1

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ function New-AzConnectedKubernetes {
411411
catch {
412412
# This is attempting to delete Azure Arc resources that are orphaned.
413413
# We are catching and ignoring any messages here.
414-
$null = helm delete azure-arc --ignore-not-found --namespace $ReleaseNamespace --kubeconfig $KubeConfig --kube-context $KubeContext
414+
$null = helm delete azure-arc --ignore-not-found --namespace $ReleaseNamespace --kubeconfig $KubeConfig --kube-context $KubeContext | Out-Null
415415
}
416416
}
417417

@@ -622,11 +622,11 @@ function New-AzConnectedKubernetes {
622622

623623
$PSBoundParameters.Add('ArcAgentryConfiguration', $arcAgentryConfigs)
624624

625-
Write-Output "Creating 'Kubernetes - Azure Arc' object in Azure"
625+
Write-Verbose "Creating 'Kubernetes - Azure Arc' object in Azure"
626626
Write-Debug "PSBoundParameters: $PSBoundParameters"
627-
$Response = Az.ConnectedKubernetes.internal\New-AzConnectedKubernetes @PSBoundParameters
627+
$CCResponse = Az.ConnectedKubernetes.internal\New-AzConnectedKubernetes @PSBoundParameters
628628

629-
if ((-not $WhatIfPreference) -and (-not $Response)) {
629+
if ((-not $WhatIfPreference) -and (-not $CCResponse)) {
630630
Write-Error "Failed to create the 'Kubernetes - Azure Arc' resource."
631631
return
632632
}
@@ -639,8 +639,8 @@ function New-AzConnectedKubernetes {
639639
-Debug:($PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent -eq $true)
640640

641641
# Convert the $Response object into a nested hashtable.
642-
Write-Debug "PUT response: $Response"
643-
$Response = ConvertFrom-Json "$Response"
642+
Write-Debug "PUT response: $CCResponse"
643+
$Response = ConvertFrom-Json "$CCResponse"
644644
$Response = ConvertTo-Hashtable $Response
645645

646646
# What-If processing does not create a full response so we might have
@@ -716,7 +716,7 @@ function New-AzConnectedKubernetes {
716716
$options += " --debug"
717717
}
718718
if ($PSCmdlet.ShouldProcess($ClusterName, "Update Kubernetes cluster with Azure Arc")) {
719-
Write-Output "Executing helm upgrade command, this can take a few minutes...."
719+
Write-Verbose "Executing helm upgrade command, this can take a few minutes...."
720720
try {
721721
helm upgrade `
722722
--install azure-arc `
@@ -733,7 +733,7 @@ function New-AzConnectedKubernetes {
733733
--set global.azureEnvironment=AZUREPUBLICCLOUD `
734734
--set systemDefaultValues.clusterconnect-agent.enabled=true `
735735
--set global.kubernetesDistro=$Distribution `
736-
--set global.kubernetesInfra=$Infrastructure (-split $options)
736+
--set global.kubernetesInfra=$Infrastructure (-split $options) | Out-Null
737737
}
738738
catch {
739739
throw "Unable to install helm chart at $ChartPath"
@@ -744,7 +744,7 @@ function New-AzConnectedKubernetes {
744744
if ($PSBoundParameters.ContainsKey('OidcIssuerProfileEnabled') -or $PSBoundParameters.ContainsKey('WorkloadIdentityEnabled') ) {
745745
$ExistConnectedKubernetes = Get-AzConnectedKubernetes -ResourceGroupName $ResourceGroupName -ClusterName $ClusterName @CommonPSBoundParameters
746746

747-
Write-Output "Cluster configuration is in progress..."
747+
Write-Verbose "Cluster configuration is in progress..."
748748
$timeout = [datetime]::Now.AddMinutes(60)
749749

750750
while (($ExistConnectedKubernetes.ArcAgentProfileAgentState -ne "Succeeded") -and ($ExistConnectedKubernetes.ArcAgentProfileAgentState -ne "Failed") -and ([datetime]::Now -lt $timeout)) {
@@ -753,7 +753,7 @@ function New-AzConnectedKubernetes {
753753
}
754754

755755
if ($ExistConnectedKubernetes.ArcAgentProfileAgentState -eq "Succeeded") {
756-
Write-Output "Cluster configuration succeeded."
756+
Write-Verbose "Cluster configuration succeeded."
757757
}
758758
elseif ($ExistConnectedKubernetes.ArcAgentProfileAgentState -eq "Failed") {
759759
Write-Error "Cluster configuration failed."
@@ -763,6 +763,6 @@ function New-AzConnectedKubernetes {
763763
}
764764
}
765765
}
766-
Return $Response
766+
Return $CCResponse
767767
}
768768
}

src/ConnectedKubernetes/ConnectedKubernetes.Autorest/custom/Set-AzConnectedKubernetes.ps1

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -675,12 +675,46 @@ function Set-AzConnectedKubernetes {
675675

676676
$PSBoundParameters.Add('ArcAgentryConfiguration', $arcAgentryConfigs)
677677

678-
Write-Output "Updating the connected cluster resource...."
679-
$Response = Az.ConnectedKubernetes.internal\Set-AzConnectedKubernetes @PSBoundParameters
680-
if ((-not $WhatIfPreference) -and (-not $Response)) {
678+
Write-Verbose "Updating the connected cluster resource...."
679+
$CCResponse = Az.ConnectedKubernetes.internal\Set-AzConnectedKubernetes @PSBoundParameters
680+
if ((-not $WhatIfPreference) -and (-not $CCResponse)) {
681681
Write-Error "Failed to update the 'Kubernetes - Azure Arc' resource"
682682
return
683683
}
684+
685+
# Wait for the agent state to settle before proceeding. If it doesn't,
686+
# we'll continue anyway - but remember and throw an error at the end.
687+
$agentsInTerminalState = $true
688+
if ($PSCmdlet.ShouldProcess($ClusterName, "Check agent state of the connected cluster")) {
689+
690+
$timeout = [datetime]::Now.AddMinutes(60)
691+
692+
for (;;) {
693+
$CCResponse = Get-AzConnectedKubernetes -ResourceGroupName $ResourceGroupName -ClusterName $ClusterName @CommonPSBoundParameters
694+
695+
if ($null -eq $CCResponse.ArcAgentProfileAgentState) {
696+
Write-Verbose "No agent configuration in progress."
697+
break
698+
}
699+
if ($CCResponse.ArcAgentProfileAgentState -eq "Succeeded") {
700+
Write-Verbose "Cluster agent configuration succeeded."
701+
break
702+
}
703+
if ($CCResponse.ArcAgentProfileAgentState -eq "Failed") {
704+
Write-Error "Cluster agent configuration failed."
705+
break
706+
}
707+
if ([datetime]::Now -ge $timeout) {
708+
Write-Error "Cluster agent configuration timed out after 60 minutes."
709+
$agentsInTerminalState = $false
710+
break
711+
}
712+
713+
Write-Verbose "Cluster agent configuration is in progress..."
714+
Start-Sleep -Seconds 30
715+
}
716+
}
717+
684718
$arcAgentryConfigs = ConvertTo-ArcAgentryConfiguration `
685719
-ConfigurationSetting $ConfigurationSetting `
686720
-RedactedProtectedConfiguration $RedactedProtectedConfiguration `
@@ -690,8 +724,8 @@ function Set-AzConnectedKubernetes {
690724

691725

692726
# Convert the $Response object into a nested hashtable.
693-
Write-Debug "PUT response: $Response"
694-
$Response = ConvertFrom-Json "$Response"
727+
Write-Debug "PUT response: $CCResponse"
728+
$Response = ConvertFrom-Json "$CCResponse"
695729
$Response = ConvertTo-Hashtable $Response
696730

697731
# Whatif may return empty response
@@ -709,7 +743,7 @@ function Set-AzConnectedKubernetes {
709743
$ResponseStr = $Response | ConvertTo-Json -Depth 10
710744
Write-Debug "PUT response: $ResponseStr"
711745

712-
Write-Output "Preparing helm ...."
746+
Write-Verbose "Preparing helm ...."
713747

714748
if ($PSCmdlet.ShouldProcess('configDP', 'get helm values from config DP')) {
715749
$helmValuesDp = Get-HelmValuesFromConfigDP `
@@ -774,7 +808,7 @@ function Set-AzConnectedKubernetes {
774808
-Debug:($PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent -eq $true)
775809
}
776810

777-
Write-Output "Executing helm upgrade, this can take a few minutes ...."
811+
Write-Verbose "Executing helm upgrade, this can take a few minutes ...."
778812
Write-Debug $options -ErrorAction Continue
779813
if ($DebugPreference -eq "Continue") {
780814
$options += " --debug"
@@ -786,37 +820,18 @@ function Set-AzConnectedKubernetes {
786820
$ChartPath `
787821
--namespace $ReleaseInstallNamespace `
788822
-f $userValuesLocation `
789-
--wait (-split $options)
823+
--wait (-split $options) | Out-Null
790824
}
791825
catch {
792826
throw "Unable to install helm release"
793827
}
794-
Return $Response
795828
}
796829

797-
if ($PSCmdlet.ShouldProcess($ClusterName, "Check agent state of the connected cluster")) {
798-
if ($PSBoundParameters.ContainsKey('OidcIssuerProfileEnabled') -or $PSBoundParameters.ContainsKey('WorkloadIdentityEnabled') ) {
799-
$ExistConnectedKubernetes = Get-AzConnectedKubernetes -ResourceGroupName $ResourceGroupName -ClusterName $ClusterName @CommonPSBoundParameters
800-
801-
Write-Output "Cluster configuration is in progress..."
802-
$timeout = [datetime]::Now.AddMinutes(60)
803-
804-
while (($ExistConnectedKubernetes.ArcAgentProfileAgentState -ne "Succeeded") -and ($ExistConnectedKubernetes.ArcAgentProfileAgentState -ne "Failed") -and ([datetime]::Now -lt $timeout)) {
805-
Start-Sleep -Seconds 30
806-
$ExistConnectedKubernetes = Get-AzConnectedKubernetes -ResourceGroupName $ResourceGroupName -ClusterName $ClusterName @CommonPSBoundParameters
807-
}
808-
809-
if ($ExistConnectedKubernetes.ArcAgentProfileAgentState -eq "Succeeded") {
810-
Write-Output "Cluster configuration succeeded."
811-
}
812-
elseif ($ExistConnectedKubernetes.ArcAgentProfileAgentState -eq "Failed") {
813-
Write-Error "Cluster configuration failed."
814-
}
815-
else {
816-
Write-Error "Cluster configuration timed out after 60 minutes."
817-
}
818-
}
830+
# If there was a problem with agent state, throw the error now.
831+
if ($agentsInTerminalState -eq $false) {
832+
throw "Timed out waiting for Agent State to reach terminal state."
819833
}
834+
Return $CCResponse
820835
}
821836
}
822837

src/ConnectedKubernetes/ConnectedKubernetes.Autorest/generate-portal-ux.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,16 @@ function New-MetadataForParameterSet()
248248
$cmdletName = Get-MappedCmdletFromFunctionName $ParameterSetInfo.Name
249249
$description = (Get-CmdletAttribute -CmdletInfo $ParameterSetInfo -AttributeName "DescriptionAttribute").Description
250250
[object[]]$example = New-ExampleForParameterSet $ParameterSetInfo
251+
if ($Null -eq $example)
252+
{
253+
$example = @()
254+
}
255+
251256
[string[]]$signature = New-ParameterArrayInParameterSet $ParameterSetInfo
257+
if ($Null -eq $signature)
258+
{
259+
$signature = @()
260+
}
252261

253262
return @{
254263
Path = $httpPath

src/ConnectedKubernetes/ConnectedKubernetes/Az.ConnectedKubernetes.psd1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 11/8/2024
6+
# Generated on: 11/13/2024
77
#
88

99
@{
@@ -58,10 +58,10 @@ RequiredAssemblies =
5858
'ConnectedKubernetes.Autorest/bin/Az.ConnectedKubernetes.private.dll'
5959

6060
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
61-
# ScriptsToProcess = @()
61+
ScriptsToProcess = @()
6262

6363
# Type files (.ps1xml) to be loaded when importing this module
64-
# TypesToProcess = @()
64+
TypesToProcess = @()
6565

6666
# Format files (.ps1xml) to be loaded when importing this module
6767
FormatsToProcess =
@@ -100,7 +100,7 @@ PrivateData = @{
100100
PSData = @{
101101

102102
# Tags applied to this module. These help with module discovery in online galleries.
103-
Tags = 'Azure','ResourceManager','ARM','PSModule','ConnectedKubernetes'
103+
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'ConnectedKubernetes'
104104

105105
# A URL to the license for this module.
106106
LicenseUri = 'https://aka.ms/azps-license'
@@ -126,7 +126,7 @@ PrivateData = @{
126126

127127
} # End of PSData hashtable
128128

129-
} # End of PrivateData hashtable
129+
} # End of PrivateData hashtable
130130

131131
# HelpInfo URI of this module
132132
# HelpInfoURI = ''

src/ConnectedKubernetes/ConnectedKubernetes/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 output type of cmdlet
2122

2223
## Version 0.12.0
2324
* Corrected function that only worked on Windows.

src/ConnectedKubernetes/ConnectedKubernetes/help/Get-AzConnectedKubernetes.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ Returns the properties of the specified connected cluster, including name, ident
1515
### List1 (Default)
1616
```
1717
Get-AzConnectedKubernetes [-SubscriptionId <String[]>] [-DefaultProfile <PSObject>]
18-
[<CommonParameters>]
18+
[-ProgressAction <ActionPreference>] [<CommonParameters>]
1919
```
2020

2121
### Get
2222
```
2323
Get-AzConnectedKubernetes -ClusterName <String> -ResourceGroupName <String> [-SubscriptionId <String[]>]
24-
[-DefaultProfile <PSObject>] [<CommonParameters>]
24+
[-DefaultProfile <PSObject>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
2525
```
2626

2727
### List
2828
```
2929
Get-AzConnectedKubernetes -ResourceGroupName <String> [-SubscriptionId <String[]>] [-DefaultProfile <PSObject>]
30-
[<CommonParameters>]
30+
[-ProgressAction <ActionPreference>] [<CommonParameters>]
3131
```
3232

3333
### GetViaIdentity
3434
```
3535
Get-AzConnectedKubernetes -InputObject <IConnectedKubernetesIdentity> [-DefaultProfile <PSObject>]
36-
[<CommonParameters>]
36+
[-ProgressAction <ActionPreference>] [<CommonParameters>]
3737
```
3838

3939
## DESCRIPTION
@@ -145,6 +145,21 @@ Accept pipeline input: True (ByValue)
145145
Accept wildcard characters: False
146146
```
147147
148+
### -ProgressAction
149+
{{ Fill ProgressAction Description }}
150+
151+
```yaml
152+
Type: System.Management.Automation.ActionPreference
153+
Parameter Sets: (All)
154+
Aliases: proga
155+
156+
Required: False
157+
Position: Named
158+
Default value: None
159+
Accept pipeline input: False
160+
Accept wildcard characters: False
161+
```
162+
148163
### -ResourceGroupName
149164
The name of the resource group.
150165
The name is case insensitive.

src/ConnectedKubernetes/ConnectedKubernetes/help/Get-AzConnectedKubernetesUserCredential.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ Gets cluster user credentials of the connected cluster with a specified resource
1616
```
1717
Get-AzConnectedKubernetesUserCredential -ClusterName <String> -ResourceGroupName <String>
1818
[-SubscriptionId <String[]>] -AuthenticationMethod <AuthenticationMethod> [-ClientProxy]
19-
[-DefaultProfile <PSObject>] [-WhatIf] [-Confirm] [<CommonParameters>]
19+
[-DefaultProfile <PSObject>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2020
```
2121

2222
### List
2323
```
2424
Get-AzConnectedKubernetesUserCredential -ClusterName <String> -ResourceGroupName <String>
2525
[-SubscriptionId <String[]>] -Property <IListClusterUserCredentialProperties> [-DefaultProfile <PSObject>]
26-
[-WhatIf] [-Confirm] [<CommonParameters>]
26+
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2727
```
2828

2929
## DESCRIPTION
@@ -130,6 +130,21 @@ Accept pipeline input: False
130130
Accept wildcard characters: False
131131
```
132132
133+
### -ProgressAction
134+
{{ Fill ProgressAction Description }}
135+
136+
```yaml
137+
Type: System.Management.Automation.ActionPreference
138+
Parameter Sets: (All)
139+
Aliases: proga
140+
141+
Required: False
142+
Position: Named
143+
Default value: None
144+
Accept pipeline input: False
145+
Accept wildcard characters: False
146+
```
147+
133148
### -Property
134149
.
135150
To construct, see NOTES section for PROPERTY properties and create a hash table.

src/ConnectedKubernetes/ConnectedKubernetes/help/New-AzConnectedKubernetes.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ New-AzConnectedKubernetes -ClusterName <String> -ResourceGroupName <String> [-Su
2222
[-CustomLocationsOid <String>] [-OidcIssuerProfileEnabled] [-OidcIssuerProfileSelfHostedIssuerUrl <String>]
2323
[-WorkloadIdentityEnabled] [-AcceptEULA] [-DefaultProfile <PSObject>] [-AsJob] [-NoWait]
2424
[-ConfigurationSetting <Hashtable>] [-ConfigurationProtectedSetting <Hashtable>] [-GatewayResourceId <String>]
25-
[-WhatIf] [-Confirm] [<CommonParameters>]
25+
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2626
```
2727

2828
## DESCRIPTION
@@ -531,6 +531,21 @@ Accept pipeline input: False
531531
Accept wildcard characters: False
532532
```
533533
534+
### -ProgressAction
535+
{{ Fill ProgressAction Description }}
536+
537+
```yaml
538+
Type: System.Management.Automation.ActionPreference
539+
Parameter Sets: (All)
540+
Aliases: proga
541+
542+
Required: False
543+
Position: Named
544+
Default value: None
545+
Accept pipeline input: False
546+
Accept wildcard characters: False
547+
```
548+
534549
### -ProvisioningState
535550
Provisioning state of the connected cluster resource.
536551

0 commit comments

Comments
 (0)