[Compute] Adding Scheduledevents to VM and VMSS#29123
Conversation
…zVM, and Update-AzVmss cmdlets - Introduced `-ScheduledEventsApiVersion` to specify the API version for Scheduled Events configuration. - Added `-EnableAllInstancesDown` to auto-approve Scheduled Events when all instances are down. - Updated related help documentation for cmdlets to reflect new parameters. - Enhanced handling of Scheduled Events policy in the cmdlet implementations.
… scheduledevents
| Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
There was a problem hiding this comment.
Pull request overview
Adds Scheduled Events configuration support to Az.Compute VM/VMSS (and Availability Set) cmdlets by introducing two new parameters that populate ScheduledEventsPolicy in the corresponding ARM payloads.
Changes:
- Added
-ScheduledEventsApiVersionand-EnableAllInstancesDownparameters to VM/VMSS/Availability Set create/update cmdlets and wired them into request models. - Updated generated/help markdown to document the new parameters.
- Added new scenario tests (and one new recording) intended to validate the behavior.
Reviewed changes
Copilot reviewed 23 out of 25 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Compute/Compute/help/Update-AzVmss.md | Documents new Scheduled Events parameters for Update-AzVmss (and adds -ProgressAction entry). |
| src/Compute/Compute/help/Update-AzVM.md | Documents new Scheduled Events parameters for Update-AzVM (and adds -ProgressAction entry). |
| src/Compute/Compute/help/Update-AzAvailabilitySet.md | Documents new Scheduled Events parameters for Update-AzAvailabilitySet (and adds -ProgressAction entry). |
| src/Compute/Compute/help/New-AzVmss.md | Documents new Scheduled Events parameters for New-AzVmss and updates syntax block. |
| src/Compute/Compute/help/New-AzVM.md | Documents new Scheduled Events parameters for New-AzVM and updates syntax block. |
| src/Compute/Compute/VirtualMachine/Operation/UpdateAzureVMCommand.cs | Adds parameters and populates ScheduledEventsPolicy for VM update calls. |
| src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs | Adds parameters and passes Scheduled Events inputs through strategy-based VM creation; also forwards ScheduledEventsPolicy from PSVirtualMachine to the SDK model. |
| src/Compute/Compute/Strategies/ComputeRp/VirtualMachineStrategy.cs | Extends strategy VM config builder to construct ScheduledEventsPolicy during VM creation. |
| src/Compute/Compute/Strategies/ComputeRp/VirtualMachineScaleSetStrategy.cs | Extends strategy VMSS config builder to construct ScheduledEventsPolicy during VMSS creation. |
| src/Compute/Compute/Models/PSVirtualMachine.cs | Adds ScheduledEventsPolicy property to the PowerShell VM model. |
| src/Compute/Compute/Manual/VirtualMachineScaleSetCreateOrUpdateMethod.cs | Adds Scheduled Events parameters to VMSS create cmdlet path and passes them into strategy config. |
| src/Compute/Compute/Manual/PSVirtualMachineScaleSet.cs | Adds ScheduledEventsPolicy property to the PowerShell VMSS model. |
| src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetUpdateMethod.cs | Adds Scheduled Events parameters to Update-AzVmss and applies them only in PUT path (not PATCH). |
| src/Compute/Compute/ChangeLog.md | Adds an Upcoming Release note about the new parameters. |
| src/Compute/Compute/AvailabilitySets/UpdateAzureAvailabilitySetCommand.cs | Adds parameters and populates ScheduledEventsPolicy for availability set updates. |
| src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AvailabilitySetTests/TestAvailabilitySetScheduledEventsPolicy.json | Adds a recording for the new availability set Scheduled Events scenario. |
| src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1 | Adds a VM Scheduled Events scenario test script. |
| src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.cs | Registers the new VM Scheduled Events scenario test for check-in runs. |
| src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1 | Adds a VMSS Scheduled Events scenario test script. |
| src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.cs | Registers the new VMSS Scheduled Events scenario test for check-in runs. |
| src/Compute/Compute.Test/ScenarioTests/StrategiesVirtualMachineTests.ps1 | Adds a strategy-based New-AzVM SimpleParameterSet Scheduled Events scenario test script. |
| src/Compute/Compute.Test/ScenarioTests/StrategiesVirtualMachineTests.cs | Registers the new strategy-based Scheduled Events scenario test for check-in runs. |
| src/Compute/Compute.Test/ScenarioTests/AvailabilitySetTests.ps1 | Adds an availability set Scheduled Events scenario test script. |
| src/Compute/Compute.Test/ScenarioTests/AvailabilitySetTests.cs | Registers the new availability set Scheduled Events scenario test for check-in runs. |
Comments suppressed due to low confidence (1)
src/Compute/Compute/help/New-AzVmss.md:651
- The -HighSpeedInterconnectPlacement parameter help no longer lists its accepted values (e.g., None/Trunk). Other cmdlets in this module include an "Accepted values:" line for constrained strings; please restore that here to avoid losing important guidance.
### -HighSpeedInterconnectPlacement
Specifies the high speed interconnect placement for the virtual machine scale set.
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
</details>
src/Compute/Compute/AvailabilitySets/UpdateAzureAvailabilitySetCommand.cs
Show resolved
Hide resolved
src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetUpdateMethod.cs
Show resolved
Hide resolved
src/Compute/Compute.Test/ScenarioTests/AvailabilitySetTests.ps1
Outdated
Show resolved
Hide resolved
src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.cs
Outdated
Show resolved
Hide resolved
src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetUpdateMethod.cs
Show resolved
Hide resolved
src/Compute/Compute.Test/ScenarioTests/AvailabilitySetTests.ps1
Outdated
Show resolved
Hide resolved
isra-fel
left a comment
There was a problem hiding this comment.
Hi, please see the comments inline, and resolve the conflicts. THanks
|
This PR was labeled "needs-revision" because it has unresolved review comments or CI failures. |
...ompute.Test.ScenarioTests.AvailabilitySetTests/TestAvailabilitySetScheduledEventsPolicy.json
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| ### -ProgressAction | ||
| {{ Fill ProgressAction Description }} | ||
|
|
||
| ```yaml | ||
| Type: System.Management.Automation.ActionPreference | ||
| Parameter Sets: (All) | ||
| Aliases: proga | ||
|
|
||
| Required: False | ||
| Position: Named | ||
| Default value: None | ||
| Accept pipeline input: False | ||
| Accept wildcard characters: False | ||
| ``` | ||
|
|
There was a problem hiding this comment.
The help includes a -ProgressAction parameter block with the placeholder text "{{ Fill ProgressAction Description }}". This should not ship as-is; either remove the ProgressAction section entirely (it’s stripped by repo tooling) or replace it with the standard description used elsewhere for common parameters and re-run help generation.
| ### -ProgressAction | |
| {{ Fill ProgressAction Description }} | |
| ```yaml | |
| Type: System.Management.Automation.ActionPreference | |
| Parameter Sets: (All) | |
| Aliases: proga | |
| Required: False | |
| Position: Named | |
| Default value: None | |
| Accept pipeline input: False | |
| Accept wildcard characters: False | |
| ``` |
| ### -HighSpeedInterconnectPlacement | ||
| Specifies the high speed interconnect placement for the virtual machine scale set. | ||
|
|
||
| ```yaml | ||
| Type: System.String | ||
| Parameter Sets: (All) | ||
| Aliases: | ||
| Accepted values: None, Trunk | ||
|
|
||
| Required: False |
There was a problem hiding this comment.
The HighSpeedInterconnectPlacement parameter block no longer lists the accepted values (previously None and Trunk). Since the cmdlet constrains this via an argument completer/validation, the help should include the accepted values to avoid users guessing invalid inputs.
| * Added support for Disk Availability Policy | ||
| - Added `-ActionOnDiskDelay` parameter to `New-AzDiskConfig` cmdlet to configure disk availability behavior | ||
| - Added `-ActionOnDiskDelay` parameter to `New-AzDiskUpdateConfig` cmdlet to update disk availability behavior | ||
| * Added `-ScheduledEventsApiVersion` and `-EnableAllInstancesDown` parameters to `Update-AzAvailabilitySet`, `Update-AzVM`, `Update-AzVmss`, `New-AzVM` (SimpleParameterSet), and `New-AzVmss` cmdlets for configuring Scheduled Events policy for virtual machines and virtual machine scale sets. |
There was a problem hiding this comment.
| IncludeZones = includeZone, | ||
| ExcludeZones = excludeZone | ||
| }, | ||
| ScheduledEventsPolicy = (scheduledEventsApiVersion == null && enableAllInstancesDown == null) ? null : new ScheduledEventsPolicy |
There was a problem hiding this comment.
ScheduledEventsPolicy is created when scheduledEventsApiVersion is a non-null empty string. Because the nested assignment uses string.IsNullOrEmpty, this can produce an empty ScheduledEventsPolicy object (no sub-properties set), which is likely invalid and may cause server-side validation errors. Consider treating empty strings as not provided (use string.IsNullOrEmpty in the outer conditional as well), and/or normalize empty to null before building the model.
| ScheduledEventsPolicy = (scheduledEventsApiVersion == null && enableAllInstancesDown == null) ? null : new ScheduledEventsPolicy | |
| ScheduledEventsPolicy = (string.IsNullOrEmpty(scheduledEventsApiVersion) && enableAllInstancesDown == null) ? null : new ScheduledEventsPolicy |
| } : null, | ||
| HighSpeedInterconnectPlacement = highSpeedInterconnectPlacement | ||
| HighSpeedInterconnectPlacement = highSpeedInterconnectPlacement, | ||
| ScheduledEventsPolicy = (scheduledEventsApiVersion == null && enableAllInstancesDown == null) ? null : new ScheduledEventsPolicy |
There was a problem hiding this comment.
ScheduledEventsPolicy is created when scheduledEventsApiVersion is a non-null empty string. Because the nested assignment uses string.IsNullOrEmpty, this can produce an empty ScheduledEventsPolicy object (no sub-properties set), which is likely invalid and may cause server-side validation errors. Consider treating empty strings as not provided (use string.IsNullOrEmpty in the outer conditional as well), and/or normalize empty to null before building the model.
| ScheduledEventsPolicy = (scheduledEventsApiVersion == null && enableAllInstancesDown == null) ? null : new ScheduledEventsPolicy | |
| ScheduledEventsPolicy = (string.IsNullOrEmpty(scheduledEventsApiVersion) && enableAllInstancesDown == null) ? null : new ScheduledEventsPolicy |
| } : null, | ||
| HighSpeedInterconnectPlacement = highSpeedInterconnectPlacement | ||
| HighSpeedInterconnectPlacement = highSpeedInterconnectPlacement, | ||
| ScheduledEventsPolicy = (scheduledEventsApiVersion == null && enableAllInstancesDown == null) ? null : new ScheduledEventsPolicy |
There was a problem hiding this comment.
ScheduledEventsPolicy is created when scheduledEventsApiVersion is a non-null empty string. Because the nested assignment uses string.IsNullOrEmpty, this can produce an empty ScheduledEventsPolicy object (no sub-properties set), which is likely invalid and may cause server-side validation errors. Consider treating empty strings as not provided (use string.IsNullOrEmpty in the outer conditional as well), and/or normalize empty to null before building the model.
| ScheduledEventsPolicy = (scheduledEventsApiVersion == null && enableAllInstancesDown == null) ? null : new ScheduledEventsPolicy | |
| ScheduledEventsPolicy = (string.IsNullOrEmpty(scheduledEventsApiVersion) && enableAllInstancesDown == null) ? null : new ScheduledEventsPolicy |
| [Parameter( | ||
| Mandatory = false, | ||
| ValueFromPipelineByPropertyName = true, | ||
| HelpMessage = "Specifies the api-version to determine which Scheduled Events configuration schema version will be delivered. Format: YYYY-MM-DD")] | ||
| public string ScheduledEventsApiVersion { get; set; } | ||
|
|
||
| [Parameter( | ||
| Mandatory = false, | ||
| ValueFromPipelineByPropertyName = true, | ||
| HelpMessage = "Specifies if Scheduled Events should be auto-approved when all instances are down.")] | ||
| public bool? EnableAllInstancesDown { get; set; } |
There was a problem hiding this comment.
These parameters are accepted by the cmdlet, but they are not applied in the PATCH path (VirtualMachineScaleSetUpdate), per the comment below. As a result, users can pass -ScheduledEventsApiVersion / -EnableAllInstancesDown and see no effect depending on parameter set. Consider restricting these parameters to the parameter set(s) that use the PUT/CreateOrUpdate path, or emitting a terminating error/warning when they’re bound but the cmdlet is using the PATCH model.
| ``` | ||
|
|
||
| ### -ScheduledEventsApiVersion | ||
| Specifies the api-version to determine which Scheduled Events configuration schema version will be delivered. Format: YYYY-MM-DD |
There was a problem hiding this comment.
The help shows -ScheduledEventsApiVersion / -EnableAllInstancesDown as available for all parameter sets, but the implementation only supports these when the cmdlet takes the PUT/CreateOrUpdate path (per code comment in VirtualMachineScaleSetUpdateMethod). Please update the help text to document this requirement (or adjust parameter sets so the help is accurate).
| Specifies the api-version to determine which Scheduled Events configuration schema version will be delivered. Format: YYYY-MM-DD | |
| Specifies the api-version to determine which Scheduled Events configuration schema version will be delivered. Format: YYYY-MM-DD. This parameter is only applied when `Update-AzVmss` performs a CreateOrUpdate (PUT) operation and is ignored for other update paths. |
|
|
Description
https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/1511
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.