Skip to content

Conversation

@BlairBriggs
Copy link


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

Related command

AZ VM CREATE

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

NOTES

Summary

This PR adds support for an optional --tags argument to the az vm repair extension, improves public IP handling, and enhances documentation and test coverage to align with Azure CLI standards.


Summary of Changes

1. custom.py

  • Added support for a new optional --tags argument to the create, repair_and_restore, and repair_button functions.
  • Updated logic to handle tags in both dictionary and string (key=value) formats, ensuring compatibility with Azure CLI conventions.
  • Modified VM creation logic to include --public-ip-address only when explicitly requested, fixing a bug where a public IP was created by default.
  • Improved code comments and documentation for maintainability and clarity, especially around tag handling and public IP logic.

Reason:
To allow users to specify tags for the repair VM, prevent unintended public IP creation, and improve code clarity.


2. _params.py

  • Exposed the new --tags argument for the vm repair create, vm repair repair-and-restore, and vm repair repair-button commands.

Reason:
To make the --tags argument available to users at the CLI, following Azure CLI argument exposure patterns.


3. _help.py

  • Documented the new --tags argument for all relevant commands.
  • Added usage examples showing how to use --tags in the standard Azure CLI format (e.g., --tags env=prod owner=alice).
  • Clarified that --tags is optional.

Reason:
To ensure users are aware of the new functionality and how to use it correctly.


4. test_repair_commands.py

  • Added new tests for both Windows and Linux managed disk scenarios to verify that tags are correctly applied to the repair VM.
  • Tests assert that the tags specified via --tags are present on the created repair VM.
  • Existing tests were reviewed to ensure they do not require tags, confirming that the argument is optional and does not break existing workflows.

Reason:
To verify that the new --tags functionality works as intended and does not introduce regressions.


Rationale

  • User Experience: Enables tagging of repair VMs in a way that is consistent with the rest of the Azure CLI, improving resource organization and management.
  • Security & Correctness: Prevents unintended public IP exposure, aligning behavior with user intent and security best practices.
  • Maintainability: Improved comments and code structure make it easier for future contributors to understand and extend the code.
  • Documentation & Testing: Updated help and comprehensive tests ensure that the new features are discoverable, reliable, and do not break existing scenarios.

Note:
The extension supports only the standard Azure CLI tag format (key[=value]), consistent with CLI conventions.

Copilot AI review requested due to automatic review settings July 2, 2025 13:43
@azure-client-tools-bot-prd
Copy link

Validation for Breaking Change Starting...

Thanks for your contribution!

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

Hi @BlairBriggs,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@yonzhan
Copy link
Collaborator

yonzhan commented Jul 2, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link

github-actions bot commented Jul 2, 2025

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

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 PR introduces optional tagging support for repair VMs, fixes unintended public IP creation, and updates documentation and tests to validate the new features.

  • Add --tags parameter support to create, repair-and-restore, and repair-button commands
  • Only include --public-ip-address when explicitly requested to prevent default public IPs
  • Update help text and add tests to cover tag scenarios

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/vm-repair/tests/test_vm_repair_commands.py Add base ScenarioTest for az vm repair create
src/vm-repair/azext_vm_repair/tests/latest/test_repair_commands.py Extend live tests to verify tag propagation on repair VMs
src/vm-repair/azext_vm_repair/custom.py Add tags parameter, build --tags argument, update signatures
src/vm-repair/azext_vm_repair/_validators.py Fix typo in comment and error message
src/vm-repair/azext_vm_repair/_params.py Expose tags argument to CLI contexts
src/vm-repair/azext_vm_repair/_help.py Document --tags usage and examples
Comments suppressed due to low confidence (3)

src/vm-repair/azext_vm_repair/custom.py:154

  • Consider using the Azure CLI's built-in tag parser (e.g., tags_type or get_tags_from_name_value) in parameter definition rather than custom string handling, to ensure consistent parsing and validation.
        # Azure CLI accepts tags as either a space-separated list of key=value pairs or a single string. Support both dict and string for flexibility.

src/vm-repair/azext_vm_repair/_validators.py:52

  • Add validation for the tags argument here—parse the raw string into a dict and surface errors for invalid formats—to provide early feedback and consistent behavior.
    else:

src/vm-repair/tests/test_vm_repair_commands.py:11

  • Consider adding a ScenarioTest here to verify that passing --tags to az vm repair create results in tags being applied, completing end-to-end coverage for the new feature.
        result = self.cmd('az vm repair create -g {rg} -n {vm_name} --verbose').get_output_in_json()

c.argument('yes', help='Option to skip prompt for associating public ip in no Tty mode')
c.argument('disable_trusted_launch', help='Option to disable Trusted Launch security type on the repair vm by setting the security type to Standard.')
c.argument('os_disk_type', help='Change the OS Disk storage type from the default of PremiumSSD_LRS to the given value.')
c.argument('tags', help="Space-separated tags in 'key[=value]' format. Use '' to clear existing tags.")
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

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

[nitpick] It may be preferable to use the CLI's tags_type for this argument to automatically handle parsing, validation, and completion of tag inputs.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Jul 2, 2025

Hi @BlairBriggs

Release Suggestions

Module: vm-repair

  • Please log updates into to src/vm-repair/HISTORY.rst
  • Update VERSION to 2.2.0 in src/vm-repair/setup.py

Notes

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

Labels

Auto-Assign Auto assign by bot Compute

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants