Skip to content

Commit

Permalink
[Compute] Powershell changes for RunCommand, VMSS Scale In Policy (Az…
Browse files Browse the repository at this point in the history
…ure#18186)

* Changes

* adding test

* changelog

* help changes

* Update ChangeLog.md

Co-authored-by: Yunchi Wang <[email protected]>
  • Loading branch information
haagha and wyunchi-ms authored May 18, 2022
1 parent 5fc3fa1 commit 6a55c50
Show file tree
Hide file tree
Showing 8 changed files with 772 additions and 1,420 deletions.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
- `New-AzSnapshotUpdateConfig`
- `New-AzGalleryImageDefinition`
* Added `-InstanceView` parameter to `Get-AzRestorePoint`
* Added parameter `-ScriptString` to `Invoke-AzvmRunCommand` and `Invoke-AzvmssRunCommand`
* Added parameter `-ScaleInPolicyForceDeletion` to `Update-Azvmss`

## Version 4.26.0
* Added `-ImageReferenceId` parameter to following cmdlets: `New-AzVm`, `New-AzVmConfig`, `New-AzVmss`, `Set-AzVmssStorageProfile`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public override void ExecuteCmdlet()
string fileContent = Commands.Common.Authentication.Abstractions.FileUtilities.DataStore.ReadFileAsText(filePath.FullName);
parameters.Script = fileContent.Split(new string[] { "\r\n", "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries);
}
else if (this.ScriptString != null)
{
parameters.Script = new List<string>() { this.ScriptString };
}
if (this.Parameter != null)
{
var vParameter = new List<RunCommandInputParameter>();
Expand Down Expand Up @@ -118,6 +122,10 @@ public override void ExecuteCmdlet()
[AllowNull]
public string ScriptPath { get; set; }

[Parameter(
Mandatory = false)]
public string ScriptString { get; set; }

[Parameter(
Mandatory = false)]
[AllowNull]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ public override void ExecuteCmdlet()
Mandatory = false)]
public bool Overprovision { get; set; }

[Parameter(
Mandatory = false)]
public bool ScaleInPolicyForceDeletion { get; set; }

[Parameter(
Mandatory = false)]
[ValidateNotNullOrEmpty]
Expand Down Expand Up @@ -956,6 +960,19 @@ private void BuildPatchObject()
this.VirtualMachineScaleSetUpdate.ScaleInPolicy.Rules = this.ScaleInPolicy;
}

if (this.IsParameterBound(c => c.ScaleInPolicyForceDeletion))
{
if (this.VirtualMachineScaleSetUpdate == null)
{
this.VirtualMachineScaleSetUpdate = new VirtualMachineScaleSetUpdate();
}
if (this.VirtualMachineScaleSetUpdate.ScaleInPolicy == null)
{
this.VirtualMachineScaleSetUpdate.ScaleInPolicy = new ScaleInPolicy();
}
this.VirtualMachineScaleSetUpdate.ScaleInPolicy.ForceDeletion = this.ScaleInPolicyForceDeletion;
}

if (this.IsParameterBound(c => c.SinglePlacementGroup))
{
if (this.VirtualMachineScaleSetUpdate == null)
Expand Down Expand Up @@ -1677,6 +1694,15 @@ private void BuildPutObject()
this.VirtualMachineScaleSet.ScaleInPolicy.Rules = this.ScaleInPolicy;
}

if (this.IsParameterBound(c => c.ScaleInPolicyForceDeletion))
{
if (this.VirtualMachineScaleSet.ScaleInPolicy == null)
{
this.VirtualMachineScaleSet.ScaleInPolicy = new ScaleInPolicy();
}
this.VirtualMachineScaleSet.ScaleInPolicy.ForceDeletion = this.ScaleInPolicyForceDeletion;
}

if (this.IsParameterBound(c => c.SinglePlacementGroup))
{
this.VirtualMachineScaleSet.SinglePlacementGroup = this.SinglePlacementGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public override void ExecuteCmdlet()
string fileContent = Commands.Common.Authentication.Abstractions.FileUtilities.DataStore.ReadFileAsText(filePath.FullName);
parameters.Script = fileContent.Split(new string[] { "\r\n", "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries);
}
else if (this.ScriptString != null)
{
parameters.Script = new List<string>() { this.ScriptString };
}
if (this.Parameter != null)
{
var vParameter = new List<RunCommandInputParameter>();
Expand Down Expand Up @@ -129,6 +133,10 @@ public override void ExecuteCmdlet()
[AllowNull]
public string ScriptPath { get; set; }

[Parameter(
Mandatory = false)]
public string ScriptString { get; set; }

[Parameter(
Mandatory = false)]
[AllowNull]
Expand Down
31 changes: 23 additions & 8 deletions src/Compute/Compute/help/Invoke-AzVMRunCommand.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ Run a command on the VM.
### DefaultParameter (Default)
```
Invoke-AzVMRunCommand [-ResourceGroupName] <String> [-VMName] <String> -CommandId <String>
[-ScriptPath <String>] [-Parameter <Hashtable>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
[-ScriptPath <String>] [-ScriptString <String>] [-Parameter <Hashtable>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### ResourceIdParameter
```
Invoke-AzVMRunCommand -CommandId <String> [-ScriptPath <String>] [-Parameter <Hashtable>]
[-ResourceId] <String> [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
Invoke-AzVMRunCommand -CommandId <String> [-ScriptPath <String>] [-ScriptString <String>]
[-Parameter <Hashtable>] [-ResourceId] <String> [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### VMParameter
```
Invoke-AzVMRunCommand -CommandId <String> [-ScriptPath <String>] [-Parameter <Hashtable>]
[-VM] <PSVirtualMachine> [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
Invoke-AzVMRunCommand -CommandId <String> [-ScriptPath <String>] [-ScriptString <String>]
[-Parameter <Hashtable>] [-VM] <PSVirtualMachine> [-AsJob] [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -166,6 +166,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ScriptString
{{ Fill ScriptString Description }}
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VM
The PS virtual machine object.
Expand Down
29 changes: 22 additions & 7 deletions src/Compute/Compute/help/Invoke-AzVmssVMRunCommand.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ Run command on the Virtual Machine Scale Set VM.
### DefaultParameter (Default)
```
Invoke-AzVmssVMRunCommand [-ResourceGroupName] <String> [-VMScaleSetName] <String> [-InstanceId] <String>
-CommandId <String> [-ScriptPath <String>] [-Parameter <Hashtable>] [-AsJob]
-CommandId <String> [-ScriptPath <String>] [-ScriptString <String>] [-Parameter <Hashtable>] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### ResourceIdParameter
```
Invoke-AzVmssVMRunCommand -CommandId <String> [-ScriptPath <String>] [-Parameter <Hashtable>]
[-ResourceId] <String> [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
Invoke-AzVmssVMRunCommand -CommandId <String> [-ScriptPath <String>] [-ScriptString <String>]
[-Parameter <Hashtable>] [-ResourceId] <String> [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### ObjectParameter
```
Invoke-AzVmssVMRunCommand -CommandId <String> [-ScriptPath <String>] [-Parameter <Hashtable>]
[-VirtualMachineScaleSetVM] <PSVirtualMachineScaleSetVM> [-AsJob] [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
Invoke-AzVmssVMRunCommand -CommandId <String> [-ScriptPath <String>] [-ScriptString <String>]
[-Parameter <Hashtable>] [-VirtualMachineScaleSetVM] <PSVirtualMachineScaleSetVM> [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -175,6 +175,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ScriptString
The script as a string.
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VirtualMachineScaleSetVM
The PS Virtual Machine Scale Set VM Object.
Expand Down
43 changes: 29 additions & 14 deletions src/Compute/Compute/help/Update-AzVmss.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ Update-AzVmss [-ResourceGroupName] <String> [-VMScaleSetName] <String>
[-ImageUri <String>] [-LicenseType <String>] [-ManagedDiskStorageAccountType <String>]
[-MaxBatchInstancePercent <Int32>] [-MaxPrice <Double>] [-MaxUnhealthyInstancePercent <Int32>]
[-MaxUnhealthyUpgradedInstancePercent <Int32>] [-OsDiskCaching <CachingTypes>]
[-OsDiskWriteAccelerator <Boolean>] [-Overprovision <Boolean>] [-PauseTimeBetweenBatches <String>]
[-PlanName <String>] [-PlanProduct <String>] [-PlanPromotionCode <String>] [-PlanPublisher <String>]
[-ProvisionVMAgent <Boolean>] [-ProximityPlacementGroupId <String>] [-ScaleInPolicy <String[]>]
[-SinglePlacementGroup <Boolean>] [-SkipExtensionsOnOverprovisionedVMs <Boolean>] [-SkuCapacity <Int32>]
[-SkuName <String>] [-SkuTier <String>] [-Tag <Hashtable>]
[-OsDiskWriteAccelerator <Boolean>] [-Overprovision <Boolean>] [-ScaleInPolicyForceDeletion <Boolean>]
[-PauseTimeBetweenBatches <String>] [-PlanName <String>] [-PlanProduct <String>] [-PlanPromotionCode <String>]
[-PlanPublisher <String>] [-ProvisionVMAgent <Boolean>] [-ProximityPlacementGroupId <String>]
[-ScaleInPolicy <String[]>] [-SinglePlacementGroup <Boolean>] [-SkipExtensionsOnOverprovisionedVMs <Boolean>]
[-SkuCapacity <Int32>] [-SkuName <String>] [-SkuTier <String>] [-Tag <Hashtable>]
[-TerminateScheduledEventNotBeforeTimeoutInMinutes <Int32>] [-TerminateScheduledEvents <Boolean>]
[-TimeZone <String>] [-UltraSSDEnabled <Boolean>] [-UpgradePolicyMode <UpgradeMode>]
[-CapacityReservationGroupId <String>] [-VhdContainer <String[]>] [-AsJob] [-EncryptionAtHost <Boolean>]
Expand All @@ -50,15 +50,15 @@ Update-AzVmss [-ResourceGroupName] <String> [-VMScaleSetName] <String>
[-ManagedDiskStorageAccountType <String>] [-MaxBatchInstancePercent <Int32>] [-MaxPrice <Double>]
[-MaxUnhealthyInstancePercent <Int32>] [-MaxUnhealthyUpgradedInstancePercent <Int32>]
[-OsDiskCaching <CachingTypes>] [-OsDiskWriteAccelerator <Boolean>] [-Overprovision <Boolean>]
[-PauseTimeBetweenBatches <String>] [-PlanName <String>] [-PlanProduct <String>] [-PlanPromotionCode <String>]
[-PlanPublisher <String>] [-ProvisionVMAgent <Boolean>] [-ProximityPlacementGroupId <String>]
[-ScaleInPolicy <String[]>] [-SinglePlacementGroup <Boolean>] [-SkipExtensionsOnOverprovisionedVMs <Boolean>]
[-SkuCapacity <Int32>] [-SkuName <String>] [-SkuTier <String>] [-Tag <Hashtable>]
[-TerminateScheduledEventNotBeforeTimeoutInMinutes <Int32>] [-TerminateScheduledEvents <Boolean>]
[-TimeZone <String>] [-UltraSSDEnabled <Boolean>] [-UpgradePolicyMode <UpgradeMode>]
[-CapacityReservationGroupId <String>] [-VhdContainer <String[]>] [-AsJob] [-EncryptionAtHost <Boolean>]
[-UserData <String>] [-AutomaticRepairAction <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
[-ScaleInPolicyForceDeletion <Boolean>] [-PauseTimeBetweenBatches <String>] [-PlanName <String>]
[-PlanProduct <String>] [-PlanPromotionCode <String>] [-PlanPublisher <String>] [-ProvisionVMAgent <Boolean>]
[-ProximityPlacementGroupId <String>] [-ScaleInPolicy <String[]>] [-SinglePlacementGroup <Boolean>]
[-SkipExtensionsOnOverprovisionedVMs <Boolean>] [-SkuCapacity <Int32>] [-SkuName <String>] [-SkuTier <String>]
[-Tag <Hashtable>] [-TerminateScheduledEventNotBeforeTimeoutInMinutes <Int32>]
[-TerminateScheduledEvents <Boolean>] [-TimeZone <String>] [-UltraSSDEnabled <Boolean>]
[-UpgradePolicyMode <UpgradeMode>] [-CapacityReservationGroupId <String>] [-VhdContainer <String[]>] [-AsJob]
[-EncryptionAtHost <Boolean>] [-UserData <String>] [-AutomaticRepairAction <String>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -723,6 +723,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ScaleInPolicyForceDeletion
Applying Force Deletion when using ScaleIn Policy.
```yaml
Type: System.Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -SinglePlacementGroup
Specifies the single placement group.
Expand Down

0 comments on commit 6a55c50

Please sign in to comment.