Skip to content

Commit 93f3d90

Browse files
Updated Set-AzStackHCI to use PATCH for updating cluster resource instead of PUT and to only send changed properties (#24158)
1 parent 856b090 commit 93f3d90

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

src/StackHCI/StackHCI.Autorest/custom/stackhci.ps1

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4723,7 +4723,6 @@ param(
47234723
$nodeSessionParams = @{}
47244724
$subscriptionId = [string]::Empty
47254725
$armResourceId = [string]::Empty
4726-
$armResource = $null
47274726

47284727
$successMessage = New-Object -TypeName System.Text.StringBuilder
47294728

@@ -4845,50 +4844,36 @@ param(
48454844
$TenantId = Azure-Login @azureLoginParameters
48464845
}
48474846

4848-
$armResource = Get-AzResource -ResourceId $armResourceId -ExpandProperties -ApiVersion $RPAPIVersion -ErrorAction Stop
4849-
48504847
$properties = [PSCustomObject]@{
4851-
desiredProperties = $armResource.Properties.desiredProperties
4852-
aadClientId = $armResource.Properties.aadClientId
4853-
aadTenantId = $armResource.Properties.aadTenantId
4854-
aadServicePrincipalObjectId = $armResource.Properties.aadServicePrincipalObjectId
4855-
aadApplicationObjectId = $armResource.Properties.aadApplicationObjectId
4856-
}
4857-
4858-
if ($properties.desiredProperties -eq $null)
4859-
{
4860-
#
4861-
# Create desiredProperties object with default values
4862-
#
4863-
$desiredProperties = New-Object -TypeName PSObject
4864-
$desiredProperties | Add-Member -MemberType NoteProperty -Name 'windowsServerSubscription' -Value 'Disabled'
4865-
$desiredProperties | Add-Member -MemberType NoteProperty -Name 'diagnosticLevel' -Value 'Basic'
4866-
4867-
$properties | Add-Member -MemberType NoteProperty -Name 'desiredProperties' -Value $desiredProperties
4848+
desiredProperties = New-Object -TypeName PSObject
48684849
}
48694850

48704851
if ($PSBoundParameters.ContainsKey('EnableWSSubscription'))
48714852
{
4853+
$windowsServerSubscriptionValue = $Null
4854+
48724855
if ($EnableWSSubscription -eq $true)
48734856
{
4874-
$properties.desiredProperties.windowsServerSubscription = 'Enabled';
4857+
$windowsServerSubscriptionValue = 'Enabled';
48754858

48764859
$successMessage.Append($SetAzResourceSuccessWSSE) | Out-Null;
48774860
}
48784861
else
48794862
{
4880-
$properties.desiredProperties.windowsServerSubscription = 'Disabled';
4863+
$windowsServerSubscriptionValue = 'Disabled';
48814864

48824865
$successMessage.Append($SetAzResourceSuccessWSSD) | Out-Null;
48834866
}
48844867

4868+
$properties.desiredProperties | Add-Member -MemberType NoteProperty -Name 'windowsServerSubscription' -Value $windowsServerSubscriptionValue
4869+
48854870
$doSetResource = $true
48864871
$needShouldContinue = $true
48874872
}
48884873

48894874
if ($PSBoundParameters.ContainsKey('DiagnosticLevel'))
48904875
{
4891-
$properties.desiredProperties.diagnosticLevel = $DiagnosticLevel.ToString()
4876+
$properties.desiredProperties | Add-Member -MemberType NoteProperty -Name 'diagnosticLevel' -Value $($DiagnosticLevel.ToString())
48924877

48934878
if ($successMessage.Length -gt 0)
48944879
{
@@ -4917,12 +4902,12 @@ param(
49174902
Write-Progress -Id $MainProgressBarId -Activity $SetProgressActivityName -Status $SetProgressStatusUpdatingProps -PercentComplete 60
49184903

49194904
$setAzResourceParameters = @{
4920-
'ResourceId' = $armResource.Id;
4905+
'ResourceId' = $armResourceId;
49214906
'Properties' = $properties;
49224907
'ApiVersion' = $RPAPIVersion
49234908
}
49244909

4925-
$localResult = Set-AzResource @setAzResourceParameters -Confirm:$false -Force -ErrorAction Stop
4910+
$localResult = Set-AzResource @setAzResourceParameters -UsePatchSemantics -Confirm:$false -Force -ErrorAction Stop
49264911

49274912
if ($PSBoundParameters.ContainsKey('EnableWSSubscription') -and ($EnableWSSubscription -eq $false))
49284913
{

0 commit comments

Comments
 (0)