Skip to content

Commit 4a949a3

Browse files
thomascoatsCopilot
andauthored
Add Dedicated Host redeploy support (#27764)
Co-authored-by: Copilot <[email protected]>
1 parent 7d37d0d commit 4a949a3

File tree

7 files changed

+6154
-11
lines changed

7 files changed

+6154
-11
lines changed

src/Compute/Compute.Test/ScenarioTests/DedicatedHostTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,12 @@ public void TestDedicatedHostUpdateAndSize()
5151
{
5252
TestRunner.RunTestScript("Test-DedicatedHostUpdateAndSize");
5353
}
54+
55+
[Fact]
56+
[Trait(Category.AcceptanceType, Category.CheckIn)]
57+
public void TestDedicatedHostRedeploy()
58+
{
59+
TestRunner.RunTestScript("Test-DedicatedHostRedeploy");
60+
}
5461
}
5562
}

src/Compute/Compute.Test/ScenarioTests/DedicatedHostTests.ps1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,4 +333,40 @@ function Test-DedicatedHostUpdateAndSize
333333
# Cleanup
334334
Clean-ResourceGroup $rgname
335335
}
336+
}
337+
338+
<#
339+
.SYNOPSIS
340+
Test Update-AzHost with Redeploy parameter.
341+
#>
342+
function Test-DedicatedHostRedeploy
343+
{
344+
# Setup
345+
$rgname = Get-ComputeTestResourceName
346+
347+
try
348+
{
349+
# Common
350+
[string]$loc = Get-Location "Microsoft.Resources" "resourceGroups" "East US 2 EUAP";
351+
$loc = $loc.Replace(' ', '');
352+
353+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
354+
355+
$hostGroupName = $rgname + 'hostgroup';
356+
New-AzHostGroup -ResourceGroupName $rgname -Name $hostGroupName -Location $loc -PlatformFaultDomain 1 -Zone "2" -Tag @{key1 = "val1"};
357+
358+
$hostName = $rgname + 'host';
359+
New-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName -Location $loc -Sku "DSv3-Type3" -Tag @{key1 = "val2"};
360+
361+
$dedicatedHost = Get-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName;
362+
Assert-NotNull $dedicatedHost;
363+
364+
# Test Update-AzHost with Redeploy parameter
365+
$updateHost = Update-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName -Redeploy;
366+
}
367+
finally
368+
{
369+
# Cleanup
370+
Clean-ResourceGroup $rgname
371+
}
336372
}

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DedicatedHostTests/TestDedicatedHostRedeploy.json

Lines changed: 6057 additions & 0 deletions
Large diffs are not rendered by default.

src/Compute/Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
2121
-->
2222
## Upcoming Release
23+
* Added `-Redeploy` switch parameter for `Update-AzHost` cmdlet to enable dedicated host redeployment.
2324
* Added `-InstantAccessDurationMinutes` parameter to New-AzSnapshotConfig.
2425
* Added `SecureVMGuestStateSAS` parameter to `Grant-AzSnapshotAccess`.
2526

src/Compute/Compute/Generated/DedicatedHost/DedicatedHostUpdateMethod.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,19 @@ public override void ExecuteCmdlet()
7878
parameters.Sku = new Sku(this.Sku, null, null);
7979
}
8080

81+
if (this.Redeploy.IsPresent)
82+
{
83+
var redeployResult = DedicatedHostsClient.Redeploy(resourceGroupName, hostGroupName, Name);
84+
WriteObject(redeployResult);
85+
}
86+
else
87+
{
88+
var result = DedicatedHostsClient.Update(resourceGroupName, hostGroupName, Name, parameters);
8189

82-
var result = DedicatedHostsClient.Update(resourceGroupName, hostGroupName, Name, parameters);
83-
var psObject = new PSHost();
84-
ComputeAutomationAutoMapperProfile.Mapper.Map<DedicatedHost, PSHost>(result, psObject);
85-
WriteObject(psObject);
90+
var psObject = new PSHost();
91+
ComputeAutomationAutoMapperProfile.Mapper.Map<DedicatedHost, PSHost>(result, psObject);
92+
WriteObject(psObject);
93+
}
8694
}
8795
});
8896
}
@@ -123,6 +131,11 @@ public override void ExecuteCmdlet()
123131
Mandatory = false)]
124132
public DedicatedHostLicenseTypes LicenseType { get; set; }
125133

134+
[Parameter(
135+
Mandatory = false,
136+
HelpMessage = "Redeploy the dedicated host. The operation will complete successfully once the dedicated host has migrated to a new node and is running. To determine the health of VMs deployed on the dedicated host after the redeploy check the Resource Health Center in the Azure Portal. Please refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more details.")]
137+
public SwitchParameter Redeploy { get; set; }
138+
126139
[Parameter(
127140
ParameterSetName = "ResourceIdParameter",
128141
Position = 0,
@@ -131,4 +144,4 @@ public override void ExecuteCmdlet()
131144
public string ResourceId { get; set; }
132145

133146
}
134-
}
147+
}

src/Compute/Compute/Generated/Models/PSHost.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,5 @@ public string ResourceGroupName
5454
public string Type { get; set; }
5555
public string Location { get; set; }
5656
public IDictionary<string, string> Tags { get; set; }
57-
5857
}
59-
}
58+
}

src/Compute/Compute/help/Update-AzHost.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ Updates the Dedicated Host.
1515
### DefaultParameter (Default)
1616
```
1717
Update-AzHost [-ResourceGroupName] <String> [-HostGroupName] <String> [-Name] <String> [-Sku <String>]
18-
[-AutoReplaceOnFailure <Boolean>] [-LicenseType <DedicatedHostLicenseTypes>]
19-
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
18+
[-AutoReplaceOnFailure <Boolean>] [-LicenseType <DedicatedHostLicenseTypes>] [-Redeploy]
19+
[-DefaultProfile <IAzureContextContainer>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
2020
[<CommonParameters>]
2121
```
2222

2323
### ResourceIdParameter
2424
```
2525
Update-AzHost [-Sku <String>] [-AutoReplaceOnFailure <Boolean>] [-LicenseType <DedicatedHostLicenseTypes>]
26-
[-ResourceId] <String> [-DefaultProfile <IAzureContextContainer>]
27-
[-WhatIf] [-Confirm] [<CommonParameters>]
26+
[-Redeploy] [-ResourceId] <String> [-DefaultProfile <IAzureContextContainer>]
27+
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2828
```
2929

3030
## DESCRIPTION
@@ -132,6 +132,36 @@ Accept pipeline input: True (ByPropertyName)
132132
Accept wildcard characters: False
133133
```
134134
135+
### -ProgressAction
136+
Determines how PowerShell responds to progress updates generated by the cmdlet. You can use this parameter to control whether progress information is displayed, silently ignored, or handled in another way.
137+
138+
```yaml
139+
Type: System.Management.Automation.ActionPreference
140+
Parameter Sets: (All)
141+
Aliases: proga
142+
143+
Required: False
144+
Position: Named
145+
Default value: None
146+
Accept pipeline input: False
147+
Accept wildcard characters: False
148+
```
149+
150+
### -Redeploy
151+
Redeploy the dedicated host. The operation will complete successfully once the dedicated host has migrated to a new node and is running. To determine the health of VMs deployed on the dedicated host after the redeploy check the Resource Health Center in the Azure Portal. Please refer to https://docs.microsoft.com/azure/service-health/resource-health-overview for more details.
152+
153+
```yaml
154+
Type: System.Management.Automation.SwitchParameter
155+
Parameter Sets: (All)
156+
Aliases:
157+
158+
Required: False
159+
Position: Named
160+
Default value: None
161+
Accept pipeline input: False
162+
Accept wildcard characters: False
163+
```
164+
135165
### -ResourceGroupName
136166
The name of the resource group.
137167

0 commit comments

Comments
 (0)