-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Adding Automatic Zone Placement #28882
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
base: main
Are you sure you want to change the base?
Conversation
| Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
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.
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
ZonePlacementPolicyparameter to control automatic zone selection (values: "Any" for VMs, "Auto" for VMSS) - Added
MaxZoneCountparameter to limit the maximum number of zones used when policy is "Auto" - Added
EnableMaxInstancePercentPerZoneswitch andValueMaxInstancePercentPerZoneto control the percentage distribution of VMs per zone - Implemented validation to ensure
Overprovisionis false whenZonePlacementPolicyis 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.
src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetUpdateMethod.cs
Show resolved
Hide resolved
src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetUpdateMethod.cs
Outdated
Show resolved
Hide resolved
src/Compute/Compute/Generated/VirtualMachineScaleSet/Config/NewAzureRmVmssConfigCommand.cs
Outdated
Show resolved
Hide resolved
src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1
Outdated
Show resolved
Hide resolved
src/Compute/Compute/Generated/VirtualMachineScaleSet/Config/NewAzureRmVmssConfigCommand.cs
Show resolved
Hide resolved
src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetUpdateMethod.cs
Outdated
Show resolved
Hide resolved
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.
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. |
Copilot
AI
Dec 11, 2025
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.
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.
| 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. |
| $vmssUpdate = Update-AzVmss -ResourceGroupName $rgname -Name $vmssName2 -MaxInstancePercentPerZoneValue 60; | ||
|
|
||
| Assert-AreEqual $vmssUpdate.ResiliencyPolicy.ZoneAllocationPolicy.MaxInstancePercentPerZonePolicy.Value 60; | ||
| #> |
Copilot
AI
Dec 11, 2025
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.
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.
| #> |
| Placement = new Placement | ||
| { | ||
| ZonePlacementPolicy = zonePlacementPolicy, | ||
| IncludeZones = includeZone, | ||
| ExcludeZones = excludeZone | ||
| } |
Copilot
AI
Dec 11, 2025
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.
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.
| Placement = new Placement | ||
| { | ||
| ZonePlacementPolicy = zonePlacementPolicy, | ||
| IncludeZones = includeZone, | ||
| ExcludeZones = excludeZone | ||
| } |
Copilot
AI
Dec 11, 2025
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.
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.
| 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 |
| ```yaml | ||
| Type: System.String | ||
| Parameter Sets: (All) |
Copilot
AI
Dec 11, 2025
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.
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.
| Parameter Sets: (All) | |
| Parameter Sets: SimpleParameterSet |
| /// <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
AI
Dec 11, 2025
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.
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.
| /// <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; } |
| * 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. |
Copilot
AI
Dec 11, 2025
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.
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.
| * 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. |
| ``` | ||
| ### -MaxInstancePercentPerZoneValue | ||
| The configuration parameters used to limit the number of virtual machines per availability zone in the virtual machine scale set. |
Copilot
AI
Dec 11, 2025
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.
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.
| 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. |
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
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.mdand reviewed the following information:ChangeLog.mdfile(s) appropriatelysrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.## Upcoming Releaseheader in the past tense.ChangeLog.mdif no new release is required, such as fixing test case only.