-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
New Start-AzVmssRollingExtensionUpgrade cmdlet #13479
Merged
Merged
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
065fde6
start initial setup
Sandido d6fac98
initial file
Sandido a4bfce4
begin dev, cmdlet framework
Sandido 599a5df
dev, no compile errors
Sandido c5dc6e3
completed dev
Sandido cc8646f
completed dev final
Sandido 7946c25
weird test failure when calling API
Sandido a236b16
this manual setup test works fine after 50mins runtime
Sandido f59a202
help doc
Sandido c87f5e6
default parameter set
Sandido a7b86d6
removing unneeded usings
Sandido 4e827df
cleaning up test
Sandido dd7fcca
Merge branch 'master' into SandidoVMSSRollUp
Sandido 8a42a5c
test cleanup and re-record
Sandido 57ca7eb
re-recorded test file
Sandido 40b8b90
test cleanup
Sandido d8e0bd1
checkin test
Sandido 50537b7
Revert "test cleanup and re-record"
Sandido 5642ccb
Merge branch 'SandidoVMSSRollUp' of https://github.com/Azure/azure-po…
Sandido af32b59
defaultparameterset string
Sandido 6a600be
recorded test file
Sandido 559a38a
removed incorrectly located test file
Sandido File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2650,3 +2650,35 @@ function Test-VirtualMachineScaleSetAssignedHost | |
Clean-ResourceGroup $rgname | ||
} | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Test the VMSS Extension rolling upgrade cmdlet. | ||
This is a LiveOnly test and requires some manual setup due to test resources deleting themselves | ||
before the extension upgrade can complete. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test requires some manual setup because the test framework does not create healthy VMs when creating a VMSS. The VMs start deleting themselves immediately, and the upgrade will fail. |
||
#> | ||
function Test-VirtualMachineScaleSetExtRollingUpgrade | ||
{ | ||
|
||
try | ||
{ | ||
# create a VM scale set manually in Azure Portal, use its default values. | ||
# Provide the Location, ResourceGroupName, and VM scale set name below. | ||
|
||
# Common | ||
[string]$loc = "eastus"; | ||
$rgname = "adamvmssupdate"; | ||
$vmssname = "windowsvmss"; | ||
$vmss = Get-Azvmss -ResourceGroupName $rgname -VMScaleSetName $vmssname; | ||
|
||
Add-AzVmssExtension -VirtualMachineScaleSet $vmss -Name "testExtension" -Publisher Microsoft.CPlat.Core -Type "NullWindows" -TypeHandlerVersion "3.0" -AutoUpgradeMinorVersion $True -Setting ""; | ||
|
||
$job = Start-AzVmssRollingExtensionUpgrade -ResourceGroupName $rgname -VMScaleSetName $vmssname -AsJob; | ||
$result = $job | Wait-Job; | ||
Assert-AreEqual "Completed" $result.State; | ||
} | ||
finally | ||
{ | ||
|
||
} | ||
} |
6,306 changes: 6,306 additions & 0 deletions
6,306
...e.Test.ScenarioTests.VirtualMachineTests/TestVirtualMachineScaleSetExtRollingUpgrade.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...irtualMachineScaleSetRollingUpgrade/VirtualMachineScaleSetRollingExtensionStartUpgrade.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
using System; | ||
using System.Management.Automation; | ||
using Microsoft.Azure.Commands.Compute.Automation.Models; | ||
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; | ||
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; | ||
|
||
namespace Microsoft.Azure.Commands.Compute.Automation | ||
{ | ||
[Cmdlet(VerbsLifecycle.Start, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VmssRollingExtensionUpgrade", DefaultParameterSetName = "DefaultParameter", SupportsShouldProcess = true)] | ||
[OutputType(typeof(PSOperationStatusResponse))] | ||
public partial class VirtualMachineScaleSetRollingExtensionStartUpgrade : ComputeAutomationBaseCmdlet | ||
{ | ||
private const string ByResourceIdParamSet = "ByResourceId", | ||
ByInputObjectParamSet = "ByInputObject", DefaultParameterSetName = "DefaultParameter"; | ||
Sandido marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[Parameter( | ||
ParameterSetName = DefaultParameterSetName, | ||
Mandatory = true, | ||
ValueFromPipelineByPropertyName = true)] | ||
[ResourceGroupCompleter] | ||
public string ResourceGroupName { get; set; } | ||
|
||
[Parameter( | ||
ParameterSetName = DefaultParameterSetName, | ||
Mandatory = true, | ||
ValueFromPipelineByPropertyName = true)] | ||
[ResourceNameCompleter("Microsoft.Compute/virtualMachineScaleSets", "ResourceGroupName")] | ||
[Alias("Name")] | ||
public string VMScaleSetName { get; set; } | ||
|
||
[Parameter( | ||
ParameterSetName = ByInputObjectParamSet, | ||
Mandatory = true, | ||
ValueFromPipeline = true)] | ||
public PSVirtualMachineScaleSet VirtualMachineScaleSet { get; set; } | ||
|
||
[Parameter( | ||
ParameterSetName = ByResourceIdParamSet, | ||
Mandatory = true, | ||
ValueFromPipeline = true)] | ||
public string ResourceId { get; set; } | ||
|
||
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] | ||
public SwitchParameter AsJob { get; set; } | ||
|
||
public override void ExecuteCmdlet() | ||
{ | ||
|
||
base.ExecuteCmdlet(); | ||
switch (ParameterSetName) | ||
{ | ||
|
||
case ByInputObjectParamSet: | ||
ExecuteClientAction(() => | ||
{ | ||
this.StartRollingUpdate(this.VirtualMachineScaleSet.ResourceGroupName, this.VirtualMachineScaleSet.Name); | ||
}); | ||
break; | ||
|
||
case ByResourceIdParamSet: | ||
|
||
ResourceIdentifier identifier = new ResourceIdentifier(this.ResourceId); | ||
|
||
ExecuteClientAction(() => | ||
{ | ||
this.StartRollingUpdate(identifier.ResourceGroupName, identifier.ResourceName); | ||
}); | ||
|
||
break; | ||
|
||
default: | ||
|
||
ExecuteClientAction(() => | ||
{ | ||
this.StartRollingUpdate(this.ResourceGroupName, this.VMScaleSetName); | ||
}); | ||
break; | ||
} | ||
} | ||
|
||
private void StartRollingUpdate(string ResourceGroup, string vmssName) | ||
{ | ||
if (ShouldProcess(vmssName, VerbsLifecycle.Start)) | ||
{ | ||
|
||
var result = VirtualMachineScaleSetRollingUpgradesClient.StartExtensionUpgradeWithHttpMessagesAsync(ResourceGroup, vmssName).GetAwaiter().GetResult(); | ||
PSOperationStatusResponse output = new PSOperationStatusResponse | ||
{ | ||
StartTime = this.StartTime, | ||
EndTime = DateTime.Now | ||
}; | ||
|
||
if (result != null && result.Request != null && result.Request.RequestUri != null) | ||
{ | ||
output.Name = GetOperationIdFromUrlString(result.Request.RequestUri.ToString()); | ||
} | ||
|
||
|
||
WriteObject(output); | ||
} | ||
} | ||
} | ||
} |
186 changes: 186 additions & 0 deletions
186
src/Compute/Compute/help/Start-AzVmssRollingExtensionUpgrade.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
--- | ||
external help file: Microsoft.Azure.PowerShell.Cmdlets.Compute.dll-Help.xml | ||
Module Name: Az.Compute | ||
online version: https://docs.microsoft.com/en-us/powershell/module/az.compute/start-azvmssrollingextensionupgrade | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Start-AzVmssRollingExtensionUpgrade | ||
|
||
## SYNOPSIS | ||
This cmdlet starts a rolling upgrade for all extensions on the given Virtual Machine Scale Set to the latest available version. | ||
|
||
## SYNTAX | ||
|
||
### DefaultParameter | ||
``` | ||
Start-AzVmssRollingExtensionUpgrade -ResourceGroupName <String> -VMScaleSetName <String> [-AsJob] | ||
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>] | ||
``` | ||
|
||
### ByInputObject | ||
``` | ||
Start-AzVmssRollingExtensionUpgrade -VirtualMachineScaleSet <PSVirtualMachineScaleSet> [-AsJob] | ||
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>] | ||
``` | ||
|
||
### ByResourceId | ||
``` | ||
Start-AzVmssRollingExtensionUpgrade -ResourceId <String> [-AsJob] [-DefaultProfile <IAzureContextContainer>] | ||
[-WhatIf] [-Confirm] [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
Starts a rolling upgrade to move all extensions on this virtual machine scale set to the latest available version. | ||
Extensions which are already running the latest available version are not affected. | ||
|
||
## EXAMPLES | ||
|
||
### Example 1 | ||
```powershell | ||
PS C:\> $vmss = Get-AzVM -ResourceGroupName "MyResourceGroupName" -VMScaleSetName "MyVmssName"; | ||
PS C:\> Add-AzVmssExtension -VirtualMachineScaleSet $vmss -Name "testExtension" -Publisher Microsoft.CPlat.Core -Type "NullWindows" -TypeHandlerVersion "3.0" -AutoUpgradeMinorVersion $True -Setting ""; | ||
PS C:\> Start-AzVmssRollingExtensionUpgrade -ResourceGroupName "MyResourceGroupName" -VMScaleSetName "MyVmssName"; | ||
``` | ||
|
||
This example gets the existing VM scale set "MyVmssName", and adds an extension to it. The final command runs the extension rolling upgrade process. | ||
|
||
## PARAMETERS | ||
|
||
### -AsJob | ||
Run cmdlet in the background | ||
|
||
```yaml | ||
Type: System.Management.Automation.SwitchParameter | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
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 | ||
Parameter Sets: (All) | ||
Aliases: AzContext, AzureRmContext, AzureCredential | ||
|
||
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 | ||
Parameter Sets: DefaultParameter | ||
Aliases: | ||
|
||
Required: True | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: True (ByPropertyName) | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -ResourceId | ||
The resource Id of the VM scale set object. | ||
|
||
```yaml | ||
Type: System.String | ||
Parameter Sets: ByResourceId | ||
Aliases: | ||
|
||
Required: True | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: True (ByValue) | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -VirtualMachineScaleSet | ||
The VM scale set object. | ||
|
||
```yaml | ||
Type: Microsoft.Azure.Commands.Compute.Automation.Models.PSVirtualMachineScaleSet | ||
Parameter Sets: ByInputObject | ||
Aliases: | ||
|
||
Required: True | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: True (ByValue) | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -VMScaleSetName | ||
The name of the VM scale set. | ||
|
||
```yaml | ||
Type: System.String | ||
Parameter Sets: DefaultParameter | ||
Aliases: Name | ||
|
||
Required: True | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: True (ByPropertyName) | ||
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 | ||
Parameter Sets: (All) | ||
Aliases: wi | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). | ||
|
||
## INPUTS | ||
|
||
### System.String | ||
|
||
### Microsoft.Azure.Commands.Compute.Automation.Models.PSVirtualMachineScaleSet | ||
|
||
## OUTPUTS | ||
|
||
### Microsoft.Azure.Commands.Compute.Automation.Models.PSOperationStatusResponse | ||
|
||
## NOTES | ||
|
||
## RELATED LINKS |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is LiveOnly because it requires some manual setup.