Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ def load_arguments(self, _):
c.argument('orchestration_mode', help='Choose how virtual machines are managed by the scale set. In Uniform mode, you define a virtual machine model and Azure will generate identical instances based on that model.',
arg_type=get_enum_type(['Uniform']), default='Uniform', max_api='2020-09-30')
c.argument('scale_in_policy', scale_in_policy_type)
c.argument('enable_automatic_repairs', options_list=['--enable-automatic-repairs', '--enable-auto-repairs'], min_api='2021-11-01', arg_type=get_three_state_flag(), help='Enable automatic repairs')
c.argument('automatic_repairs_grace_period', min_api='2018-10-01',
help='The amount of time (in minutes, between 30 and 90) for which automatic repairs are suspended due to a state change on VM.')
c.argument('automatic_repairs_action', arg_type=get_enum_type(['Replace', 'Restart', 'Reimage']), min_api='2021-11-01', help='Type of repair action that will be used for repairing unhealthy virtual machines in the scale set.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,8 @@ def build_vmss_resource(cmd, name, computer_name_prefix, location, tags, overpro
security_posture_reference_is_overridable=None, zone_balance=None, wire_server_mode=None,
imds_mode=None, wire_server_access_control_profile_reference_id=None,
imds_access_control_profile_reference_id=None, enable_automatic_zone_balancing=None,
automatic_zone_balancing_strategy=None, automatic_zone_balancing_behavior=None):
automatic_zone_balancing_strategy=None, automatic_zone_balancing_behavior=None,
enable_automatic_repairs=None):

# Build IP configuration
ip_configuration = {}
Expand Down Expand Up @@ -1541,6 +1542,9 @@ def build_vmss_resource(cmd, name, computer_name_prefix, location, tags, overpro
automatic_zone_rebalancing_policy = {}
if enable_automatic_zone_balancing is not None:
automatic_zone_rebalancing_policy['enabled'] = enable_automatic_zone_balancing
if enable_automatic_zone_balancing is True and enable_automatic_repairs is not None:
automatic_repairs_policy = {'enabled': enable_automatic_repairs}
vmss_properties['automaticRepairsPolicy'] = automatic_repairs_policy

if automatic_zone_balancing_strategy is not None:
automatic_zone_rebalancing_policy['rebalanceStrategy'] = automatic_zone_balancing_strategy
Expand Down
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/vm/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2530,6 +2530,9 @@ def _validate_vmss_create_automatic_repairs(cmd, namespace): # pylint: disable=
if namespace.load_balancer is None or namespace.health_probe is None:
raise ArgumentUsageError("usage error: --load-balancer and --health-probe are required "
"when creating vmss with automatic repairs")
if namespace.enable_automatic_repairs is not None and namespace.enable_automatic_repairs is False:
raise ArgumentUsageError("usage error: --enable-automatic-repairs cannot be false when "
"--automatic-repairs-action or --automatic-repairs-grace-period are used")
_validate_vmss_automatic_repairs(cmd, namespace)


Expand Down
6 changes: 4 additions & 2 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3278,7 +3278,8 @@ def create_vmss(cmd, vmss_name, resource_group_name, image=None,
security_posture_reference_is_overridable=None, zone_balance=None, wire_server_mode=None,
imds_mode=None, wire_server_access_control_profile_reference_id=None,
imds_access_control_profile_reference_id=None, enable_automatic_zone_balancing=None,
automatic_zone_balancing_strategy=None, automatic_zone_balancing_behavior=None):
automatic_zone_balancing_strategy=None, automatic_zone_balancing_behavior=None,
enable_automatic_repairs=None):
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.cli.core.util import random_string, hash_string
from azure.cli.core.commands.arm import ArmTemplateBuilder
Expand Down Expand Up @@ -3600,7 +3601,8 @@ def _get_public_ip_address_allocation(value, sku):
imds_access_control_profile_reference_id=imds_access_control_profile_reference_id,
enable_automatic_zone_balancing=enable_automatic_zone_balancing,
automatic_zone_balancing_strategy=automatic_zone_balancing_strategy,
automatic_zone_balancing_behavior=automatic_zone_balancing_behavior)
automatic_zone_balancing_behavior=automatic_zone_balancing_behavior,
enable_automatic_repairs=enable_automatic_repairs)

vmss_resource['dependsOn'] = vmss_dependencies

Expand Down
Loading
Loading