Skip to content

[Compute] az vmss lifecycle-hook/ lifecycle-hook-event: Add new command groups to support vmss lifecycle hooks#33758

Open
william051200 wants to merge 13 commits into
Azure:devfrom
william051200:lifecycle-hooks
Open

[Compute] az vmss lifecycle-hook/ lifecycle-hook-event: Add new command groups to support vmss lifecycle hooks#33758
william051200 wants to merge 13 commits into
Azure:devfrom
william051200:lifecycle-hooks

Conversation

@william051200

@william051200 william051200 commented Jul 21, 2026

Copy link
Copy Markdown
Member

Related command

az vmss lifecycle-hook add/list/remove/show/update
az vmss lifecycle-hook-event approve/list/reject/show/update

Description

Resolve #33652

aaz Azure/aaz#1046

Testing Guide

Refer to azure-cli\src\azure-cli\azure\cli\command_modules\vm\tests\latest\test_vm_commands.py:

  1. test_vmss_lifecycle_hook
  2. test_vmss_lifecycle_hook_event

az vmss lifecycle-hook-event approve/reject/update are not included in the test cases as they required live platform-generated event. Service team will be helping with the test locally.

History Notes

[Compute] az vmss lifecycle-hook/ lifecycle-hook-event: Add new command groups to support vmss lifecycle hooks


This checklist is used to make sure that common guidelines for a pull request are followed.

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests
⚠️ None ️✔️ 130/130
⚠️AzureCLI-BreakingChangeTest
⚠️vm
rule cmd_name rule_message suggest_message
⚠️ 1011 - SubgroupAdd vmss lifecycle-hook sub group vmss lifecycle-hook added
⚠️ 1011 - SubgroupAdd vmss lifecycle-hook-event sub group vmss lifecycle-hook-event added

Copilot AI review requested due to automatic review settings July 21, 2026 05:53
@william051200
william051200 requested a review from a team as a code owner July 21, 2026 05:53
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi @william051200,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@william051200 william051200 changed the title {Compute} az vmss lifecycle-hooks &az vmss lifecycle-hooks-event: Add new command groups to support vmss lifecycle hooks {Compute} az vmss lifecycle-hooks/ lifecycle-hooks-event: Add new command groups to support vmss lifecycle hooks Jul 21, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Auto-Assign Auto assign by bot label Jul 21, 2026
@william051200 william051200 changed the title {Compute} az vmss lifecycle-hooks/ lifecycle-hooks-event: Add new command groups to support vmss lifecycle hooks {Compute} az vmss lifecycle-hook/ lifecycle-hook-event: Add new command groups to support vmss lifecycle hooks Jul 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds new preview command groups under the vmss command module to manage VM Scale Set lifecycle hooks and to interact with platform-generated lifecycle hook events, along with scenario tests and recordings.

Changes:

  • Add az vmss lifecycle-hook commands (add/update/remove/show/list) backed by new custom implementations.
  • Add az vmss lifecycle-hook-event commands, including AAZ-generated list/show/update and custom wrappers for update/approve/reject with client-side validation.
  • Add scenario tests and a recording to validate core command behaviors.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py Adds scenario tests for lifecycle-hook and lifecycle-hook-event command groups.
src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_lifecycle_hook_event.yaml Adds recording for lifecycle-hook-event list scenario.
src/azure-cli/azure/cli/command_modules/vm/custom.py Implements lifecycle hook CRUD and lifecycle hook event update/approve/reject helpers.
src/azure-cli/azure/cli/command_modules/vm/commands.py Registers new command groups and wires validators.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vmss/lifecycle_hook_event/_update.py Adds AAZ-generated vmss lifecycle-hook-event update.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vmss/lifecycle_hook_event/_show.py Adds AAZ-generated vmss lifecycle-hook-event show.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vmss/lifecycle_hook_event/_list.py Adds AAZ-generated vmss lifecycle-hook-event list.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vmss/lifecycle_hook_event/init.py Exposes lifecycle_hook_event AAZ commands for loading.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vmss/lifecycle_hook_event/__cmd_group.py Registers the AAZ command group for lifecycle hook events.
src/azure-cli/azure/cli/command_modules/vm/_validators.py Adds validators for hook removal and lifecycle-hook-event update/action behaviors.
src/azure-cli/azure/cli/command_modules/vm/_params.py Adds argument definitions/enums for lifecycle hook and lifecycle hook event commands.
src/azure-cli/azure/cli/command_modules/vm/_help.py Adds help content for the new command groups/commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# AZURE CLI VM TEST DEFINITIONS
import json
import os
import datetime
Comment on lines +5123 to +5131
def _commit_vmss_lifecycle_hooks(cmd, resource_group_name, vmss_name, hooks, no_wait):
from .operations.vmss import VMSSCreate, convert_show_result_to_snake_case
vmss = get_vmss_modified_by_aaz(cmd, resource_group_name, vmss_name)
vmss = convert_show_result_to_snake_case(vmss)
vmss["lifecycle_hooks_profile"] = {"lifecycle_hooks": hooks}
vmss["resource_group"] = resource_group_name
vmss["vm_scale_set_name"] = vmss_name
vmss["no_wait"] = no_wait
return VMSSCreate(cli_ctx=cmd.cli_ctx)(command_args=vmss)
Comment on lines +3079 to +3082
helps['vmss lifecycle-hook-event'] = """
type: group
short-summary: Manage virtual machine scale set lifecycle hook events.
"""
@william051200 william051200 changed the title {Compute} az vmss lifecycle-hook/ lifecycle-hook-event: Add new command groups to support vmss lifecycle hooks [Compute] az vmss lifecycle-hook/ lifecycle-hook-event: Add new command groups to support vmss lifecycle hooks Jul 21, 2026
@yonzhan

yonzhan commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Compute

@william051200

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@william051200

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@AnshulVermaa

Copy link
Copy Markdown
Member
  1. lifecycle-hook-event commands apart from show and list fail with exit code -1 (even though the underlying operation on CRP side succeeds).
  2. lifecycle-hook-event show and list have a resource group field appended at the end of the response.
  3. az vmss lifecycle-hook add: 'TestLCH' is not a valid value for '--type'. Allowed values: UpgradeAutoOSScheduling, UpgradeAutoOSRollingBatchStarting. Is this validation on PS side, and every time we surface new LCH type, would we need PS changes and rollout as well?

@AnshulVermaa AnshulVermaa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comments added in discussions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-observability-squad Auto-Assign Auto assign by bot Compute az vm/vmss/image/disk/snapshot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add VMSS Lifecycle Hooks support to az vmss (preview)

5 participants