Skip to content

Conversation

@audreyttt
Copy link
Member

Description

Adding four new parameters to New-AzVmssConfig and Update-AzVmss, as requested in this design: https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/1510

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • 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.
    • 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

@azure-client-tools-bot-prd
Copy link

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copilot AI review requested due to automatic review settings December 1, 2025 19:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds Automatic Zone Placement functionality for Virtual Machine Scale Sets (VMSS) by introducing four new parameters to New-AzVmssConfig, Update-AzVmss, and New-AzVmss cmdlets. The feature enables automatic distribution of VMSS instances across availability zones with configurable constraints, addressing the requirements outlined in the linked design document.

Key changes:

  • Added ZonePlacementPolicy parameter to control automatic zone selection (values: "Any" for VMs, "Auto" for VMSS)
  • Added MaxZoneCount parameter to limit the maximum number of zones used when policy is "Auto"
  • Added EnableMaxInstancePercentPerZone switch and ValueMaxInstancePercentPerZone to control the percentage distribution of VMs per zone
  • Implemented validation to ensure Overprovision is false when ZonePlacementPolicy is specified

Reviewed changes

Copilot reviewed 9 out of 14 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/Compute/Compute/ChangeLog.md Added changelog entry documenting the new parameters, but with incorrect casing
src/Compute/Compute/help/New-AzVmss.md Added documentation for ZonePlacementPolicy parameter in New-AzVmss cmdlet
src/Compute/Compute/help/New-AzVmssConfig.md Added documentation for all four new parameters in New-AzVmssConfig cmdlet
src/Compute/Compute/help/Update-AzVmss.md Added documentation for all four new parameters in Update-AzVmss cmdlet
src/Compute/Compute/Generated/VirtualMachineScaleSet/Config/NewAzureRmVmssConfigCommand.cs Implemented parameter definitions and zone placement logic for config cmdlet, with nested value parameter handling
src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetUpdateMethod.cs Implemented parameter definitions and zone placement logic for update cmdlet with critical bugs in parameter type and object assignment
src/Compute/Compute/Generated/Models/PSVirtualMachineScaleSet.cs Added Placement property to the PowerShell model object
src/Compute/Compute/Manual/PSVirtualMachineScaleSet.cs Added convenience ZonePlacementPolicy string property for simple parameter set
src/Compute/Compute/Manual/VirtualMachineScaleSetCreateOrUpdateMethod.cs Added ZonePlacementPolicy parameter to New-AzVmss simple parameter set
src/Compute/Compute/Strategies/ComputeRp/VirtualMachineScaleSetStrategy.cs Updated VMSS creation strategy to include Placement object with ZonePlacementPolicy
src/Compute/Compute.Management.Sdk/Generated/Models/VirtualMachineScaleSetUpdate.cs Added Placement property to SDK update model
src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1 Added comprehensive test covering creation and update scenarios with zone placement parameters
src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.cs Added test entry point for new zone placement test

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Copilot AI review requested due to automatic review settings December 11, 2025 21:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 14 changed files in this pull request and generated 9 comments.

```
### -MaxInstancePercentPerZoneValue
The configuration parameters used to limit the number of virtual machines per availability zone in the virtual machine scale set.
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The help message for MaxInstancePercentPerZoneValue in Update-AzVmss documentation (line 668) uses the same generic description as New-AzVmssConfig. It should match the detailed help message from the code implementation: "Limit on the number of instances in each availability zone as a percentage of the total capacity of the virtual machine scale set. For example: if set to 50, this means that at any time, no more than 50% of the VMs in your scale set can be allocated to a single zone." The current description "The configuration parameters used to limit the number of virtual machines per availability zone in the virtual machine scale set" is too generic and doesn't explain how the parameter works.

Suggested change
The configuration parameters used to limit the number of virtual machines per availability zone in the virtual machine scale set.
Limit on the number of instances in each availability zone as a percentage of the total capacity of the virtual machine scale set. For example: if set to 50, this means that at any time, no more than 50% of the VMs in your scale set can be allocated to a single zone.

Copilot uses AI. Check for mistakes.
$vmssUpdate = Update-AzVmss -ResourceGroupName $rgname -Name $vmssName2 -MaxInstancePercentPerZoneValue 60;

Assert-AreEqual $vmssUpdate.ResiliencyPolicy.ZoneAllocationPolicy.MaxInstancePercentPerZonePolicy.Value 60;
#>
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The test function Test-VirtualMachineScaleSetAutomaticZonePlacement has a multi-line comment starting marker on line 6267 without a proper ending. The marker "#>" should be removed as it appears to be leftover from commenting out code. This will cause a syntax error in PowerShell.

Suggested change
#>

Copilot uses AI. Check for mistakes.
Comment on lines +208 to +213
Placement = new Placement
{
ZonePlacementPolicy = zonePlacementPolicy,
IncludeZones = includeZone,
ExcludeZones = excludeZone
}
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The Placement object is always created even when all its properties (zonePlacementPolicy, includeZone, excludeZone) are null. This could result in an empty Placement object being sent to the API. Consider only creating the Placement object if at least one of the properties has a non-null value, similar to how other optional properties like ScaleInPolicy and SkuProfile are handled on lines 197-205.

Copilot uses AI. Check for mistakes.
Comment on lines +369 to +374
Placement = new Placement
{
ZonePlacementPolicy = zonePlacementPolicy,
IncludeZones = includeZone,
ExcludeZones = excludeZone
}
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The Placement object is always created even when all its properties (zonePlacementPolicy, includeZone, excludeZone) are null. This could result in an empty Placement object being sent to the API. Consider only creating the Placement object if at least one of the properties has a non-null value, similar to how other optional properties like ScaleInPolicy and SkuProfile are handled on lines 358-366.

Suggested change
Placement = new Placement
{
ZonePlacementPolicy = zonePlacementPolicy,
IncludeZones = includeZone,
ExcludeZones = excludeZone
}
Placement = (zonePlacementPolicy != null || includeZone != null || excludeZone != null) ? new Placement
{
ZonePlacementPolicy = zonePlacementPolicy,
IncludeZones = includeZone,
ExcludeZones = excludeZone
} : null

Copilot uses AI. Check for mistakes.
```yaml
Type: System.String
Parameter Sets: (All)
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The ZonePlacementPolicy parameter documentation incorrectly lists "Parameter Sets: (All)" but the implementation shows it should be "Parameter Sets: SimpleParameterSet" to match the code on line 304 of VirtualMachineScaleSetCreateOrUpdateMethod.cs. This should be corrected to accurately reflect which parameter sets support this parameter.

Suggested change
Parameter Sets: (All)
Parameter Sets: SimpleParameterSet

Copilot uses AI. Check for mistakes.
Comment on lines +246 to +252
/// <summary>
/// Gets or sets the placement of a vmss. Placement section specifies
/// the user-defined constraints for virtual machine scale set hardware placement.
/// This property cannot be changed once VMSS is provisioned.
/// </summary>
[JsonProperty(PropertyName = "placement")]
public Placement Placement { get; set; }
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The comment on lines 247-249 states "This property cannot be changed once VMSS is provisioned" but the Placement property is being added to VirtualMachineScaleSetUpdate, which is used for updating existing VMSS. If the property truly cannot be changed after provisioning, it should not be in the Update model. If it can be changed, the comment is misleading. Please verify the Azure API behavior and either remove the property from the Update model or update the comment to accurately reflect whether this property is mutable.

Suggested change
/// <summary>
/// Gets or sets the placement of a vmss. Placement section specifies
/// the user-defined constraints for virtual machine scale set hardware placement.
/// This property cannot be changed once VMSS is provisioned.
/// </summary>
[JsonProperty(PropertyName = "placement")]
public Placement Placement { get; set; }

Copilot uses AI. Check for mistakes.
* Added `-InstantAccessDurationMinutes` parameter to New-AzSnapshotConfig.
* Added `SecureVMGuestStateSAS` parameter to `Grant-AzSnapshotAccess`.
* Updated SDK to use 2025-04-01 version of the ComputeRP API for Compute related cmdlets.
* Added new parameters `ZonePlacementPolicy`, `maxZoneCount`, `enableMaxInstancePercentPerZone`, and `maxInstancePercentPerZoneValue` to `New-AzVmssConfig` and `Update-AzVmss` cmdlets for VMSS Automatic Zone Placement.
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The parameter names in the ChangeLog entry on line 50 use inconsistent casing. They use camelCase (maxZoneCount, enableMaxInstancePercentPerZone, maxInstancePercentPerZoneValue) instead of PascalCase used in the actual parameter names (MaxZoneCount, EnableMaxInstancePercentPerZone, MaxInstancePercentPerZoneValue). Parameter names in ChangeLog entries should match the actual parameter names exactly, including casing.

Suggested change
* Added new parameters `ZonePlacementPolicy`, `maxZoneCount`, `enableMaxInstancePercentPerZone`, and `maxInstancePercentPerZoneValue` to `New-AzVmssConfig` and `Update-AzVmss` cmdlets for VMSS Automatic Zone Placement.
* Added new parameters `ZonePlacementPolicy`, `MaxZoneCount`, `EnableMaxInstancePercentPerZone`, and `MaxInstancePercentPerZoneValue` to `New-AzVmssConfig` and `Update-AzVmss` cmdlets for VMSS (Virtual Machine Scale Set) Automatic Zone Placement.

Copilot uses AI. Check for mistakes.
```
### -MaxInstancePercentPerZoneValue
The configuration parameters used to limit the number of virtual machines per availability zone in the virtual machine scale set.
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The help message for MaxInstancePercentPerZoneValue in the generated code (line 431) is more detailed and user-friendly than the help documentation (line 724 in the .md file). The documentation should match the detailed help message from the code: "Limit on the number of instances in each availability zone as a percentage of the total capacity of the virtual machine scale set. For example: if set to 50, this means that at any time, no more than 50% of the VMs in your scale set can be allocated to a single zone." The current documentation description "The configuration parameters used to limit the number of virtual machines per availability zone in the virtual machine scale set" is too generic and doesn't explain how the parameter works.

Suggested change
The configuration parameters used to limit the number of virtual machines per availability zone in the virtual machine scale set.
Limit on the number of instances in each availability zone as a percentage of the total capacity of the virtual machine scale set. For example: if set to 50, this means that at any time, no more than 50% of the VMs in your scale set can be allocated to a single zone.

Copilot uses AI. Check for mistakes.
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.

1 participant