Skip to content
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

PowerShell Support for ResiliencyPolicy (including ResilientVMCreationPolicy, ResilientVMDeletionPolicy) on VMSS #25928

Merged
merged 10 commits into from
Aug 30, 2024

Conversation

haagha
Copy link
Member

@haagha haagha commented Aug 23, 2024

Description

Introduced EnableResilientVMCreate and EnableResilientVMDelete parameters to Update-AzVmss and New-AzVmssConfig cmdlets for enhanced VM resilience options.

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • For SDK-based development mode, update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • For autorest-based development mode, include the changelog in the PR description.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

Copy link

azure-client-tools-bot-prd bot commented Aug 23, 2024

️✔️Az.Accounts
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
⚠️Az.Compute
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Breaking Change Check
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Signature Check
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
⚠️Help Example Check
⚠️PowerShell Core - Windows
Type Cmdlet Example Line RuleName Description Extent Remediation
⚠️ New-AzVmssConfig 1 1 Unassigned_Variable New-AzVmssConfig -Location $Loc is a null-valued parameter value. -Location Assign value for $Loc.
⚠️ New-AzVmssConfig 1 1 Unassigned_Variable New-AzVmssConfig -NetworkInterfaceConfiguration $NetCfg is a null-valued parameter value. -NetworkInterfaceConfiguration Assign value for $NetCfg.
⚠️ New-AzVmssConfig 1 2 Unassigned_Variable Add-AzVmssNetworkInterfaceConfiguration -IPConfiguration $IPCfg is a null-valued parameter value. -IPConfiguration Assign value for $IPCfg.
⚠️ New-AzVmssConfig 1 3 Unassigned_Variable Set-AzVmssOsProfile -AdminUsername $adminUsername is a null-valued parameter value. -AdminUsername Assign value for $adminUsername.
⚠️ New-AzVmssConfig 1 3 Unassigned_Variable Set-AzVmssOsProfile -AdminPassword $AdminPassword is a null-valued parameter value. -AdminPassword Assign value for $AdminPassword.
⚠️ New-AzVmssConfig 1 5 Unassigned_Variable Set-AzVmssStorageProfile -ImageReferenceOffer $ImgRef.Offer is a null-valued parameter value. -ImageReferenceOffer Assign value for $ImgRef.Offer.
⚠️ New-AzVmssConfig 1 5 Unassigned_Variable Set-AzVmssStorageProfile -ImageReferenceSku $ImgRef.Skus is a null-valued parameter value. -ImageReferenceSku Assign value for $ImgRef.Skus.
⚠️ New-AzVmssConfig 1 5 Unassigned_Variable Set-AzVmssStorageProfile -ImageReferenceVersion $ImgRef.Version is a null-valued parameter value. -ImageReferenceVersion Assign value for $ImgRef.Version.
⚠️ New-AzVmssConfig 1 6 Unassigned_Variable Set-AzVmssStorageProfile -ImageReferencePublisher $ImgRef.PublisherName is a null-valued parameter value. -ImageReferencePublisher Assign value for $ImgRef.PublisherName.
⚠️ New-AzVmssConfig 1 6 Unassigned_Variable Set-AzVmssStorageProfile -VhdContainer $VHDContainer is a null-valued parameter value. -VhdContainer Assign value for $VHDContainer.
⚠️ New-AzVmssConfig 1 7 Unassigned_Variable Add-AzVmssAdditionalUnattendContent -ComponentName $AUCComponentName is a null-valued parameter value. -ComponentName Assign value for $AUCComponentName.
⚠️ New-AzVmssConfig 1 7 Unassigned_Variable Add-AzVmssAdditionalUnattendContent -Content $AUCContent is a null-valued parameter value. -Content Assign value for $AUCContent.
⚠️ New-AzVmssConfig 1 7 Unassigned_Variable Add-AzVmssAdditionalUnattendContent -PassName $AUCPassName is a null-valued parameter value. -PassName Assign value for $AUCPassName.
⚠️ New-AzVmssConfig 1 7 Unassigned_Variable Add-AzVmssAdditionalUnattendContent -SettingName $AUCSetting is a null-valued parameter value. -SettingName Assign value for $AUCSetting.
⚠️ New-AzVmssConfig 1 9 Unassigned_Variable New-AzVmss -ResourceGroupName $RGName is a null-valued parameter value. -ResourceGroupName Assign value for $RGName.
⚠️ New-AzVmssConfig 1 9 Unassigned_Variable New-AzVmss -Name $VMSSName is a null-valued parameter value. -Name Assign value for $VMSSName.
⚠️ New-AzVmssConfig 4 18 Unassigned_Variable New-AzStorageAccount -ResourceGroupName $rgname is a null-valued parameter value. -ResourceGroupName Assign value for $rgname.
⚠️ New-AzVmssConfig 4 18 Unassigned_Variable New-AzStorageAccount -Location $loc is a null-valued parameter value. -Location Assign value for $loc.
⚠️ New-AzVmssConfig 4 19 Unassigned_Variable Get-AzStorageAccount -ResourceGroupName $rgname is a null-valued parameter value. -ResourceGroupName Assign value for $rgname.
⚠️ New-AzVmssConfig 4 23 Unassigned_Variable New-AzVirtualNetwork -ResourceGroupName $rgname is a null-valued parameter value. -ResourceGroupName Assign value for $rgname.
⚠️ New-AzVmssConfig 4 23 Unassigned_Variable New-AzVirtualNetwork -Location $loc is a null-valued parameter value. -Location Assign value for $loc.
⚠️ New-AzVmssConfig 4 24 Unassigned_Variable Get-AzVirtualNetwork -ResourceGroupName $rgname is a null-valued parameter value. -ResourceGroupName Assign value for $rgname.
⚠️ New-AzVmssConfig 4 30 Unassigned_Variable New-AzVmssConfig -Location $loc is a null-valued parameter value. -Location Assign value for $loc.
⚠️ New-AzVmssConfig 4 32 Unassigned_Variable Set-AzVmssOsProfile -AdminPassword $password is a null-valued parameter value. -AdminPassword Assign value for $password.
⚠️ New-AzVmssConfig 4 37 Unassigned_Variable New-AzVmss -ResourceGroupName $rgname is a null-valued parameter value. -ResourceGroupName Assign value for $rgname.
⚠️ New-AzVmssConfig 4 39 Unassigned_Variable Get-AzVmss -ResourceGroupName $rgname is a null-valued parameter value. -ResourceGroupName Assign value for $rgname.
⚠️ New-AzVmssConfig 5 36 Mismatched_Parameter_Value_Type Set-AzVmssOsProfile -AdminPassword $adminPassword is not an expected parameter value type. -AdminPassword Use correct parameter value type. Expected Type is string. Now the type is securestring.(Command).
⚠️ Update-AzVmss 1 1 Unassigned_Variable Update-AzVmss -VirtualMachineScaleSet $LocalVMSS is a null-valued parameter value. -VirtualMachineScaleSet Assign value for $LocalVMSS.
⚠️Windows PowerShell - Windows
Type Cmdlet Example Line RuleName Description Extent Remediation
⚠️ New-AzVmssConfig 1 1 Unassigned_Variable New-AzVmssConfig -Location $Loc is a null-valued parameter value. -Location Assign value for $Loc.
⚠️ New-AzVmssConfig 1 1 Unassigned_Variable New-AzVmssConfig -NetworkInterfaceConfiguration $NetCfg is a null-valued parameter value. -NetworkInterfaceConfiguration Assign value for $NetCfg.
⚠️ New-AzVmssConfig 1 2 Unassigned_Variable Add-AzVmssNetworkInterfaceConfiguration -IPConfiguration $IPCfg is a null-valued parameter value. -IPConfiguration Assign value for $IPCfg.
⚠️ New-AzVmssConfig 1 3 Unassigned_Variable Set-AzVmssOsProfile -AdminUsername $adminUsername is a null-valued parameter value. -AdminUsername Assign value for $adminUsername.
⚠️ New-AzVmssConfig 1 3 Unassigned_Variable Set-AzVmssOsProfile -AdminPassword $AdminPassword is a null-valued parameter value. -AdminPassword Assign value for $AdminPassword.
⚠️ New-AzVmssConfig 1 5 Unassigned_Variable Set-AzVmssStorageProfile -ImageReferenceOffer $ImgRef.Offer is a null-valued parameter value. -ImageReferenceOffer Assign value for $ImgRef.Offer.
⚠️ New-AzVmssConfig 1 5 Unassigned_Variable Set-AzVmssStorageProfile -ImageReferenceSku $ImgRef.Skus is a null-valued parameter value. -ImageReferenceSku Assign value for $ImgRef.Skus.
⚠️ New-AzVmssConfig 1 5 Unassigned_Variable Set-AzVmssStorageProfile -ImageReferenceVersion $ImgRef.Version is a null-valued parameter value. -ImageReferenceVersion Assign value for $ImgRef.Version.
⚠️ New-AzVmssConfig 1 6 Unassigned_Variable Set-AzVmssStorageProfile -ImageReferencePublisher $ImgRef.PublisherName is a null-valued parameter value. -ImageReferencePublisher Assign value for $ImgRef.PublisherName.
⚠️ New-AzVmssConfig 1 6 Unassigned_Variable Set-AzVmssStorageProfile -VhdContainer $VHDContainer is a null-valued parameter value. -VhdContainer Assign value for $VHDContainer.
⚠️ New-AzVmssConfig 1 7 Unassigned_Variable Add-AzVmssAdditionalUnattendContent -ComponentName $AUCComponentName is a null-valued parameter value. -ComponentName Assign value for $AUCComponentName.
⚠️ New-AzVmssConfig 1 7 Unassigned_Variable Add-AzVmssAdditionalUnattendContent -Content $AUCContent is a null-valued parameter value. -Content Assign value for $AUCContent.
⚠️ New-AzVmssConfig 1 7 Unassigned_Variable Add-AzVmssAdditionalUnattendContent -PassName $AUCPassName is a null-valued parameter value. -PassName Assign value for $AUCPassName.
⚠️ New-AzVmssConfig 1 7 Unassigned_Variable Add-AzVmssAdditionalUnattendContent -SettingName $AUCSetting is a null-valued parameter value. -SettingName Assign value for $AUCSetting.
⚠️ New-AzVmssConfig 1 9 Unassigned_Variable New-AzVmss -ResourceGroupName $RGName is a null-valued parameter value. -ResourceGroupName Assign value for $RGName.
⚠️ New-AzVmssConfig 1 9 Unassigned_Variable New-AzVmss -Name $VMSSName is a null-valued parameter value. -Name Assign value for $VMSSName.
⚠️ New-AzVmssConfig 4 18 Unassigned_Variable New-AzStorageAccount -ResourceGroupName $rgname is a null-valued parameter value. -ResourceGroupName Assign value for $rgname.
⚠️ New-AzVmssConfig 4 18 Unassigned_Variable New-AzStorageAccount -Location $loc is a null-valued parameter value. -Location Assign value for $loc.
⚠️ New-AzVmssConfig 4 19 Unassigned_Variable Get-AzStorageAccount -ResourceGroupName $rgname is a null-valued parameter value. -ResourceGroupName Assign value for $rgname.
⚠️ New-AzVmssConfig 4 23 Unassigned_Variable New-AzVirtualNetwork -ResourceGroupName $rgname is a null-valued parameter value. -ResourceGroupName Assign value for $rgname.
⚠️ New-AzVmssConfig 4 23 Unassigned_Variable New-AzVirtualNetwork -Location $loc is a null-valued parameter value. -Location Assign value for $loc.
⚠️ New-AzVmssConfig 4 24 Unassigned_Variable Get-AzVirtualNetwork -ResourceGroupName $rgname is a null-valued parameter value. -ResourceGroupName Assign value for $rgname.
⚠️ New-AzVmssConfig 4 30 Unassigned_Variable New-AzVmssConfig -Location $loc is a null-valued parameter value. -Location Assign value for $loc.
⚠️ New-AzVmssConfig 4 32 Unassigned_Variable Set-AzVmssOsProfile -AdminPassword $password is a null-valued parameter value. -AdminPassword Assign value for $password.
⚠️ New-AzVmssConfig 4 37 Unassigned_Variable New-AzVmss -ResourceGroupName $rgname is a null-valued parameter value. -ResourceGroupName Assign value for $rgname.
⚠️ New-AzVmssConfig 4 39 Unassigned_Variable Get-AzVmss -ResourceGroupName $rgname is a null-valued parameter value. -ResourceGroupName Assign value for $rgname.
⚠️ New-AzVmssConfig 5 36 Mismatched_Parameter_Value_Type Set-AzVmssOsProfile -AdminPassword $adminPassword is not an expected parameter value type. -AdminPassword Use correct parameter value type. Expected Type is string. Now the type is securestring.(Command).
⚠️ Update-AzVmss 1 1 Unassigned_Variable Update-AzVmss -VirtualMachineScaleSet $LocalVMSS is a null-valued parameter value. -VirtualMachineScaleSet Assign value for $LocalVMSS.
️✔️Help File Existence Check
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️File Change Check
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️UX Metadata Check
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️PowerShell Core - Linux
️✔️PowerShell Core - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.KeyVault
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.ManagedServiceIdentity
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.Monitor
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.Network
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️PowerShell Core - Linux
️✔️PowerShell Core - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.OperationalInsights
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.PrivateDns
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.RecoveryServices
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️PowerShell Core - Linux
️✔️PowerShell Core - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.Security
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️PowerShell Core - Linux
️✔️PowerShell Core - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.Sql
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.Ssh
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Test
️✔️PowerShell Core - Linux
️✔️PowerShell Core - MacOS
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows
️✔️Az.Storage
️✔️Build
️✔️PowerShell Core - Windows
️✔️Windows PowerShell - Windows

@@ -20,6 +20,7 @@

-->
## Upcoming Release
* Introduced `EnableResilientVMCreate` and `EnableResilientVMDelete` parameters to `Update-AzVmss` and `New-AzVmssConfig` cmdlets for enhanced VM resilience options.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep this consistent with other lines.
Ex: * Added parameter -ResourceIdsOnly to Get-AzCapacityReservationGroup cmdlet.

Copy link
Member Author

@haagha haagha Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is AI generated, so I've marked it as improvements to make on ps cmd assistant. and also fixed this

@@ -776,6 +806,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -ProgressAction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be removed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

[Parameter(
Mandatory = false,
HelpMessage = "Enable or disable resilient VM creation.")]
public SwitchParameter EnableResilientVMCreate { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a bool as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed with design author and changed, Switch is for New-Azvmssconfig and Update is for Update-Azvmss

[Parameter(
Mandatory = false,
HelpMessage = "Enable or disable resilient VM deletion.")]
public bool EnableResilientVMDelete { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the other one Switch and this one bool ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed with design author and changed, Switch is for New-Azvmssconfig and Update is for Update-Azvmss

.SYNOPSIS
Create a VMSS
Test ResilientVMCreationPolicy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve the test description.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few descriptors

$vmssName = 'vmssResiliencyPolicy' + $rgname;

$adminUsername = 'Foo12';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use Get-ComputeTestResourceName here instead. Might be better security wise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is it better security wise? The resource will be deleted after the test is ran.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then there's no established pattern or hardcoded string to learn our username from. The cleanup should happen, but this would further obfuscate the credentials and make them non-deterministic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

{
vResiliencyPolicy = new ResiliencyPolicy();
}
vResiliencyPolicy.ResilientVMCreationPolicy = new ResilientVMCreationPolicy(this.EnableResilientVMCreate.IsPresent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't use IsPResent even on SwitchParameters because users can pass switchParameters as false as -Parameter:$false. It's rare but it does happen so you should check to see if it is $true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see interesting, corrected.

{
this.VirtualMachineScaleSetUpdate.ResiliencyPolicy = new ResiliencyPolicy();
}
this.VirtualMachineScaleSetUpdate.ResiliencyPolicy.ResilientVMCreationPolicy = new ResilientVMCreationPolicy(this.EnableResilientVMCreate.IsPresent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same ispresent concern here as above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

{
this.VirtualMachineScaleSet.ResiliencyPolicy = new ResiliencyPolicy();
}
this.VirtualMachineScaleSet.ResiliencyPolicy.ResilientVMCreationPolicy = new ResilientVMCreationPolicy(this.EnableResilientVMCreate.IsPresent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same ispresent concern

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

src/Compute/Compute/help/New-AzVmssConfig.md Outdated Show resolved Hide resolved
src/Compute/Compute/help/New-AzVmssConfig.md Outdated Show resolved Hide resolved
@dolauli dolauli self-assigned this Aug 27, 2024
$vmssName = 'vmssResiliencyPolicy' + $rgname;

$adminUsername = 'Foo12';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then there's no established pattern or hardcoded string to learn our username from. The cleanup should happen, but this would further obfuscate the credentials and make them non-deterministic.

Sandido
Sandido previously approved these changes Aug 28, 2024
@dolauli dolauli merged commit ec4f0e8 into Azure:main Aug 30, 2024
12 checks passed
github-actions bot pushed a commit that referenced this pull request Aug 30, 2024
…nPolicy, ResilientVMDeletionPolicy) on VMSS (#25928)

* Autogen code

* Update ChangeLog.md

* fixing autogenerated changes

* adding test and help

* More changes

* changing help

* changes with help

* fixed test case

* Adding static analysis suppression

---------

Co-authored-by: PSCmdAssistant <[email protected]>
Co-authored-by: Xiaogang <[email protected]>
VeryEarly added a commit that referenced this pull request Sep 2, 2024
…nPolicy, ResilientVMDeletionPolicy) on VMSS (#25928) (#25987)

* Autogen code

* Update ChangeLog.md

* fixing autogenerated changes

* adding test and help

* More changes

* changing help

* changes with help

* fixed test case

* Adding static analysis suppression

---------

Co-authored-by: Haider Agha <[email protected]>
Co-authored-by: PSCmdAssistant <[email protected]>
Co-authored-by: Xiaogang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants