Skip to content

Add Dedicated Host redeploy support #27764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,12 @@ public void TestDedicatedHostUpdateAndSize()
{
TestRunner.RunTestScript("Test-DedicatedHostUpdateAndSize");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void testgenupdateazhost()
{
TestRunner.RunTestScript("TestGen-updateazhost");
}
}
}
41 changes: 41 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/DedicatedHostTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,47 @@ function Test-DedicatedHostUpdateAndSize
$dHUpdate = Update-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName -AutoReplaceOnFailure $false;
Assert-AreEqual $dHUpdate.AutoReplaceOnFailure $False ;

}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Test Update-AzHost with Redeploy parameter.
#>
function TestGen-updateazhost
{
# Setup
$rgname = Get-ComputeTestResourceName

try
{
# Common
[string]$loc = Get-Location "Microsoft.Resources" "resourceGroups" "East US 2 EUAP";
$loc = $loc.Replace(' ', '');

New-AzResourceGroup -Name $rgname -Location $loc -Force;

$hostGroupName = $rgname + 'hostgroup';
New-AzHostGroup -ResourceGroupName $rgname -Name $hostGroupName -Location $loc -PlatformFaultDomain 1 -Zone "2" -Tag @{key1 = "val1"};

$hostName = $rgname + 'host';
New-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName -Location $loc -Sku "Dadsv5-Type1" -Tag @{key1 = "val2"};

# Test Update-AzHost with Redeploy parameter
$updateHost = Update-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName -Redeploy;
Assert-IsNotNull $updateHost.Redeploy;

# Verify the host is updated
$dedicatedHost = Get-AzHost -ResourceGroupName $rgname -HostGroupName $hostGroupName -Name $hostName;
Assert-AreEqual $hostName $dedicatedHost.Name;
Assert-AreEqual $rgname $dedicatedHost.ResourceGroupName;
Assert-AreEqual $loc $dedicatedHost.Location;

}
finally
{
Expand Down
1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Added new properties `Architecture`, `HyperVGeneration`, and `ImageDeprecationStatus` to be returned in `Get-AzVMImage` ListVMImage parameter set.
* Deprecated `Get-AzVMSize` 'List Virtual Machine Size' parameter set.
* Added new parameters `EnableAutomaticZoneRebalance`, `AutomaticZoneRebalanceStrategy` and `AutomaticZoneRebalanceBehavior` to `New-AzVmssConfig` and `Update-AzVmss` cmdlets for VMSS Automatic Zone Rebalancing.
* Added `-Redeploy` parameter as an optional boolean for `Update-AzHost` cmdlet to enhance host management capabilities.

## Version 9.3.0
* Added new cmdlets `Add-AzVmssSkuProfileVMSize` and `Remove-AzVmssSkuProfileVMSize` to add and remove VM sizes to and from the VMSS SkuProfile.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,19 @@ public override void ExecuteCmdlet()
parameters.Sku = new Sku(this.Sku, null, null);
}

if (this.Redeploy.IsPresent)
{
var redeployResult = DedicatedHostsClient.Redeploy(resourceGroupName, hostGroupName, Name);
WriteObject(redeployResult);
}
else
{
var result = DedicatedHostsClient.Update(resourceGroupName, hostGroupName, Name, parameters);

var result = DedicatedHostsClient.Update(resourceGroupName, hostGroupName, Name, parameters);
var psObject = new PSHost();
ComputeAutomationAutoMapperProfile.Mapper.Map<DedicatedHost, PSHost>(result, psObject);
WriteObject(psObject);
var psObject = new PSHost();
ComputeAutomationAutoMapperProfile.Mapper.Map<DedicatedHost, PSHost>(result, psObject);
WriteObject(psObject);
}
}
});
}
Expand Down Expand Up @@ -123,6 +131,11 @@ public override void ExecuteCmdlet()
Mandatory = false)]
public DedicatedHostLicenseTypes LicenseType { get; set; }

[Parameter(
Mandatory = false,
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.")]
public SwitchParameter Redeploy { get; set; }

[Parameter(
ParameterSetName = "ResourceIdParameter",
Position = 0,
Expand All @@ -131,4 +144,4 @@ public override void ExecuteCmdlet()
public string ResourceId { get; set; }

}
}
}
3 changes: 1 addition & 2 deletions src/Compute/Compute/Generated/Models/PSHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,5 @@ public string ResourceGroupName
public string Type { get; set; }
public string Location { get; set; }
public IDictionary<string, string> Tags { get; set; }

}
}
}
72 changes: 43 additions & 29 deletions src/Compute/Compute/help/Update-AzHost.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ Updates the Dedicated Host.
### DefaultParameter (Default)
```
Update-AzHost [-ResourceGroupName] <String> [-HostGroupName] <String> [-Name] <String> [-Sku <String>]
[-AutoReplaceOnFailure <Boolean>] [-LicenseType <DedicatedHostLicenseTypes>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-AutoReplaceOnFailure <Boolean>] [-LicenseType <DedicatedHostLicenseTypes>] [-Redeploy <Boolean>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### ResourceIdParameter
```
Update-AzHost [-Sku <String>] [-AutoReplaceOnFailure <Boolean>] [-LicenseType <DedicatedHostLicenseTypes>]
[-ResourceId] <String> [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
[-Redeploy <Boolean>] [-ResourceId] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -60,7 +59,7 @@ This command updates the given Sku of a host.
Specifies whether the host should be replaced automatically in case of a failure.

```yaml
Type: System.Boolean
Type: Boolean
Parameter Sets: (All)
Aliases:

Expand All @@ -71,11 +70,26 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Confirm
Prompts you for confirmation before running the cmdlet.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.

```yaml
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Type: IAzureContextContainer
Parameter Sets: (All)
Aliases: AzContext, AzureRmContext, AzureCredential

Expand All @@ -90,7 +104,7 @@ Accept wildcard characters: False
Name of the Host Group.

```yaml
Type: System.String
Type: String
Parameter Sets: DefaultParameter
Aliases:

Expand All @@ -105,7 +119,7 @@ Accept wildcard characters: False
Specifies the software license type that will be applied to the VMs deployed on the host. Possible values are: None, Windows_Server_Hybrid, and Windows_Server_Perpetual. Default value is None.

```yaml
Type: Microsoft.Azure.Management.Compute.Models.DedicatedHostLicenseTypes
Type: DedicatedHostLicenseTypes
Parameter Sets: (All)
Aliases:
Accepted values: None, WindowsServerHybrid, WindowsServerPerpetual
Expand All @@ -121,7 +135,7 @@ Accept wildcard characters: False
Specifies the name of the Host to be updated.

```yaml
Type: System.String
Type: String
Parameter Sets: DefaultParameter
Aliases: HostName

Expand All @@ -132,11 +146,26 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -Redeploy
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.

```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ResourceGroupName
The name of the resource group.

```yaml
Type: System.String
Type: String
Parameter Sets: DefaultParameter
Aliases:

Expand All @@ -151,7 +180,7 @@ Accept wildcard characters: False
Resource Id of the Host to be updated.

```yaml
Type: System.String
Type: String
Parameter Sets: ResourceIdParameter
Aliases:

Expand All @@ -166,7 +195,7 @@ Accept wildcard characters: False
The Sku Name that needs to be updated.

```yaml
Type: System.String
Type: String
Parameter Sets: (All)
Aliases:

Expand All @@ -177,27 +206,12 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Confirm
Prompts you for confirmation before running the cmdlet.

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.

```yaml
Type: System.Management.Automation.SwitchParameter
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Expand Down
Loading