Skip to content

Conversation

@huiii99
Copy link
Member

@huiii99 huiii99 commented Jan 21, 2026

Related command
az vm availability-set create

Description
This pull request migrates az vm availability-set create cmd from the legacy mgmt.compute sdk to the new aaz framework.

aaz: Azure/aaz#925

Testing Guide

History Notes
[Compute] az vm availability-set create: Deprecate the --validate parameter after migrating the command to AAZ


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

@huiii99 huiii99 requested a review from zhoxing-ms as a code owner January 21, 2026 03:06
Copilot AI review requested due to automatic review settings January 21, 2026 03:06
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Jan 21, 2026

❌AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
❌vm
❌latest
❌3.12
Type Test Case Error Message Line
Failed test_vm_availset_scheduled_events_policy self = <azure.cli.testsdk.base.ExecutionResult object at 0x7fabe5594c50>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7fabe7852180>
command = 'vm availability-set create -g cli_test_vm_availset_scheduled_events_policy_000001 -n availset-test1 --additional-events True --enable-reboot True --enable-redeploy True --platform-fault-domain-count 1 --platform-update-domain-count 1'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.12/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/init.py:133: in exception_handler
    return handle_exception(ex)
           ^^^^^^^^^^^^^^^^^^^^
                                        

ex = CLIError(CLIError('Scheduled Events Policy is not supported for availability sets in this environment. Retry without --additional-events/--enable-reboot/--enable-redeploy.'))
args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception CLIError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <latest.test_vm_commands.VMAvailSetScenarioTest testMethod=test_vm_availset_scheduled_events_policy>
resource_group = 'cli_test_vm_availset_scheduled_events_policy_000001'

    @AllowLargeResponse()
    @ResourceGroupPreparer(name_prefix='cli_test_vm_availset_scheduled_events_policy
', location='eastasia')
    def test_vm_availset_scheduled_events_policy(self, resource_group):
        self.kwargs.update({
            'availset1': 'availset-test1',
            'availset2': 'availset-test2'
        })
    
>       self.cmd('vm availability-set create -g {rg} -n {availset1} --additional-events True --enable-reboot True --enable-redeploy True --platform-fault-domain-count 1 --platform-update-domain-count 1', checks=[
            self.check('name', '{availset1}'),
            self.check('scheduledEventsPolicy.scheduledEventsAdditionalPublishingTargets.eventGridAndResourceGraph.enable', True),
            self.check('scheduledEventsPolicy.userInitiatedRedeploy.automaticallyApprove', True),
            self.check('scheduledEventsPolicy.userInitiatedReboot.automaticallyApprove', True)
        ])

src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:2134: 
                                        
src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.12/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:669: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:737: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:729: in run_job
    return cmd_copy.exception_handler(ex)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 
 
 
 
                                   

ex = CLIError('Scheduled Events Policy is not supported for availability sets in this environment. Retry without --additional-events/--enable-reboot/--enable-redeploy.')

    def handle_template_based_exception(ex):
        try:
            raise CLIError(ex.inner_exception.error.message)
        except AttributeError:
            if hasattr(ex, 'response'):
                raise_subdivision_deployment_error(ex.response.internal_response.text, ex.error.code if ex.error else None)
            else:
>               raise CLIError(ex)
E               knack.util.CLIError: Scheduled Events Policy is not supported for availability sets in this environment. Retry without --additional-events/--enable-reboot/--enable-redeploy.

src/azure-cli-core/azure/cli/core/commands/arm.py:114: CLIError
azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:2125
Failed test_vm_avset_scheduled_events_policy_parameters self = <azure.cli.testsdk.base.ExecutionResult object at 0x7fabe5595e20>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7fabe78689e0>
command = 'vm availability-set update -g cli_test_vm_avset_scheduled_events_policy_parameters000001 -n avset000002 --enable-all-instance-down True'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.12/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/init.py:133: in exception_handler
    return handle_exception(ex)
           ^^^^^^^^^^^^^^^^^^^^
                                        

ex = HttpResponseError('(InvalidParameter) Scheduled Event Policy is not supported\nCode: InvalidParameter\nMessage: Scheduled Event Policy is not supported\nTarget: scheduledEventsPolicy')
args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception HttpResponseError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <latest.test_vm_commands.VMAvailSetScenarioTest testMethod=test_vm_avset_scheduled_events_policy_parameters>
resource_group = 'cli_test_vm_avset_scheduled_events_policy_parameters000001'

    @ResourceGroupPreparer(name_prefix='cli_test_vm_avset_scheduled_events_policy_parameters', location='eastus')
    def test_vm_avset_scheduled_events_policy_parameters(self, resource_group):
        self.kwargs.update({
            'avset': self.create_random_name('avset', 15)
        })
    
        self.cmd('vm availability-set create -g {rg} -n {avset} --platform-fault-domain-count 1 --platform-update-domain-count 1')
>       self.cmd('vm availability-set update -g {rg} -n {avset} --enable-all-instance-down True', checks=[
            self.check('scheduledEventsPolicy.allInstancesDown.automaticallyApprove', True)
        ])

src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:2167: 
 
                                       
src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.12/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:669: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:737: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:706: in run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/aaz/command.py:155: in call
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/__cmds.py:863: in handler
    self.execute_operations()
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/__cmds.py:986: in execute_operations
    self.AvailabilitySetsCreateOrUpdate(ctx=self.ctx)()
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/__cmds.py:1101: in call
    return self.on_error(session.http_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 
 
 
 
 
 
 
 
                               

self = <azure.cli.command_modules.vm.aaz.latest.vm.availability_set.__cmds.Update.AvailabilitySetsCreateOrUpdate object at 0x7fabe4a2dfd0>
response = RequestsTransportResponse: 400 , Content-Type: application/json; charset=utf-8

    def on_error(self, response):
        """ handle errors in response
        """
        # raise common http errors
        error_type = self.error_map.get(response.status_code)
        if error_type:
            raise error_type(response=response)
        # raise HttpResponseError
        error_format = self.ctx.get_error_format(self.error_format)
>       raise HttpResponseError(response=response, error_format=error_format)
E       azure.core.exceptions.HttpResponseError: (InvalidParameter) Scheduled Event Policy is not supported
E       Code: InvalidParameter
E       Message: Scheduled Event Policy is not supported
E       Target: scheduledEventsPolicy

src/azure-cli-core/azure/cli/core/aaz/_operation.py:327: HttpResponseError
azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:2159
Failed test_vm_avset_migrate self = <azure.cli.testsdk.base.ExecutionResult object at 0x7fabe45254f0>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7fabe788d100>
command = 'vm availability-set validate-migration-to-vmss -n avset000002 -g cli_test_vm_avset_migrate000001 --vmss-flexible-id /...000000000/resourceGroups/cli_test_vm_avset_migrate000001/providers/Microsoft.Compute/virtualMachineScaleSets/vms000006'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.12/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/init.py:133: in exception_handler
    return handle_exception(ex)
           ^^^^^^^^^^^^^^^^^^^^
                                        

ex = HttpResponseError('(BadRequest) Subscription is not eligible to migrate Availability Set : avset000002 to Virtual Mach...quest\nMessage: Subscription is not eligible to migrate Availability Set : avset000002 to Virtual Machines Scale Set.')
args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception HttpResponseError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <latest.test_vm_commands.VMAvailSetLiveScenarioTest testMethod=test_vm_avset_migrate>
resource_group = 'cli_test_vm_avset_migrate000001'

    @ResourceGroupPreparer(name_prefix='cli_test_vm_avset_migrate', location='westus2')
    def test_vm_avset_migrate(self, resource_group):
        self.kwargs.update({
            'avset1': self.create_random_name('avset', 15),
            'avset2': self.create_random_name('avset', 15),
            'vm1': self.create_random_name('vm', 10),
            'vm2': self.create_random_name('vm', 10),
            'vmss': self.create_random_name('vms', 10),
            'new_vmss': self.create_random_name('newvmss', 15),
        })
    
        self.cmd('vm availability-set create -g {rg} -n {avset1} --platform-fault-domain-count 2 --platform-update-domain-count 2', checks=[
            self.check('name', '{avset1}'),
            self.check('platformFaultDomainCount', 2)
        ])
        self.cmd('vm create -g {rg} -n {vm1} --image OpenLogic:CentOS:7.5:latest --admin-username vmtest --nsg-rule NONE --size Standard_B2ms --availability-set {avset1}')
        self.cmd('vmss create -g {rg} -n {vmss} --image OpenLogic:CentOS:7.5:latest --admin-username vmsstest --vm-sku Standard_B2ms')
        vmss = self.cmd('vmss show -g {rg} -n {vmss}').get_output_in_json()
        self.kwargs.update({
            'vmss_id': vmss['id'],
        })
>       self.cmd('vm availability-set validate-migration-to-vmss -n {avset1} -g {rg} --vmss-flexible-id {vmss_id}')

src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:2216: 
 
                                       
src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.12/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:669: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:737: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:706: in run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/aaz/command.py:155: in call
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/__cmds.py:1944: in handler
    self.execute_operations()
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/__cmds.py:1980: in execute_operations
    self.AvailabilitySetsValidateMigrationToVirtualMachineScaleSet(ctx=self.ctx)()
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/__cmds.py:2000: in call
    return self.on_error(session.http_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 
 
 
 
 
 
 
 
                               

self = <azure.cli.command_modules.vm.aaz.latest.vm.availability_set.__cmds.ValidateMigrationToVmss.AvailabilitySetsValidateMigrationToVirtualMachineScaleSet object at 0x7fabe4387d70>
response = RequestsTransportResponse: 400 , Content-Type: application/json; charset=utf-8

    def on_error(self, response):
        """ handle errors in response
        """
        # raise common http errors
        error_type = self.error_map.get(response.status_code)
        if error_type:
            raise error_type(response=response)
        # raise HttpResponseError
        error_format = self.ctx.get_error_format(self.error_format)
>       raise HttpResponseError(response=response, error_format=error_format)
E       azure.core.exceptions.HttpResponseError: (BadRequest) Subscription is not eligible to migrate Availability Set : avset000002 to Virtual Machines Scale Set.
E       Code: BadRequest
E       Message: Subscription is not eligible to migrate Availability Set : avset000002 to Virtual Machines Scale Set.

src/azure-cli-core/azure/cli/core/aaz/_operation.py:327: HttpResponseError
azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:2194
❌3.13
Type Test Case Error Message Line
Failed test_vm_availset_scheduled_events_policy self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f778983a900>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f778bd96d50>
command = 'vm availability-set create -g cli_test_vm_availset_scheduled_events_policy_000001 -n availset-test1 --additional-events True --enable-reboot True --enable-redeploy True --platform-fault-domain-count 1 --platform-update-domain-count 1'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.13/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/init.py:133: in exception_handler
    return handle_exception(ex)
           ^^^^^^^^^^^^^^^^^^^^
                                        

ex = CLIError(CLIError('Scheduled Events Policy is not supported for availability sets in this environment. Retry without --additional-events/--enable-reboot/--enable-redeploy.'))
args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception CLIError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <latest.test_vm_commands.VMAvailSetScenarioTest testMethod=test_vm_availset_scheduled_events_policy>
resource_group = 'cli_test_vm_availset_scheduled_events_policy_000001'

    @AllowLargeResponse()
    @ResourceGroupPreparer(name_prefix='cli_test_vm_availset_scheduled_events_policy
', location='eastasia')
    def test_vm_availset_scheduled_events_policy(self, resource_group):
        self.kwargs.update({
            'availset1': 'availset-test1',
            'availset2': 'availset-test2'
        })
    
>       self.cmd('vm availability-set create -g {rg} -n {availset1} --additional-events True --enable-reboot True --enable-redeploy True --platform-fault-domain-count 1 --platform-update-domain-count 1', checks=[
            self.check('name', '{availset1}'),
            self.check('scheduledEventsPolicy.scheduledEventsAdditionalPublishingTargets.eventGridAndResourceGraph.enable', True),
            self.check('scheduledEventsPolicy.userInitiatedRedeploy.automaticallyApprove', True),
            self.check('scheduledEventsPolicy.userInitiatedReboot.automaticallyApprove', True)
        ])

src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:2134: 
                                        
src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.13/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:669: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:737: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:729: in run_job
    return cmd_copy.exception_handler(ex)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 
 
 
 
                                   

ex = CLIError('Scheduled Events Policy is not supported for availability sets in this environment. Retry without --additional-events/--enable-reboot/--enable-redeploy.')

    def handle_template_based_exception(ex):
        try:
            raise CLIError(ex.inner_exception.error.message)
        except AttributeError:
            if hasattr(ex, 'response'):
                raise_subdivision_deployment_error(ex.response.internal_response.text, ex.error.code if ex.error else None)
            else:
>               raise CLIError(ex)
E               knack.util.CLIError: Scheduled Events Policy is not supported for availability sets in this environment. Retry without --additional-events/--enable-reboot/--enable-redeploy.

src/azure-cli-core/azure/cli/core/commands/arm.py:114: CLIError
azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:2125
Failed test_vm_avset_scheduled_events_policy_parameters self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f77889a1450>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f778bd97610>
command = 'vm availability-set update -g cli_test_vm_avset_scheduled_events_policy_parameters000001 -n avset000002 --enable-all-instance-down True'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.13/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/init.py:133: in exception_handler
    return handle_exception(ex)
           ^^^^^^^^^^^^^^^^^^^^
                                        

ex = HttpResponseError('(InvalidParameter) Scheduled Event Policy is not supported\nCode: InvalidParameter\nMessage: Scheduled Event Policy is not supported\nTarget: scheduledEventsPolicy')
args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception HttpResponseError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <latest.test_vm_commands.VMAvailSetScenarioTest testMethod=test_vm_avset_scheduled_events_policy_parameters>
resource_group = 'cli_test_vm_avset_scheduled_events_policy_parameters000001'

    @ResourceGroupPreparer(name_prefix='cli_test_vm_avset_scheduled_events_policy_parameters', location='eastus')
    def test_vm_avset_scheduled_events_policy_parameters(self, resource_group):
        self.kwargs.update({
            'avset': self.create_random_name('avset', 15)
        })
    
        self.cmd('vm availability-set create -g {rg} -n {avset} --platform-fault-domain-count 1 --platform-update-domain-count 1')
>       self.cmd('vm availability-set update -g {rg} -n {avset} --enable-all-instance-down True', checks=[
            self.check('scheduledEventsPolicy.allInstancesDown.automaticallyApprove', True)
        ])

src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:2167: 
 
                                       
src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.13/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:669: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:737: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:706: in run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/aaz/command.py:155: in call
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/__cmds.py:420: in handler
    self.execute_operations()
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/__cmds.py:543: in execute_operations
    self.AvailabilitySetsCreateOrUpdate(ctx=self.ctx)()
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/__cmds.py:658: in call
    return self.on_error(session.http_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 
 
 
 
 
 
 
 
                               

self = <azure.cli.command_modules.vm.aaz.latest.vm.availability_set.__cmds.Update.AvailabilitySetsCreateOrUpdate object at 0x7f7788a8a120>
response = RequestsTransportResponse: 400 , Content-Type: application/json; charset=utf-8

    def on_error(self, response):
        """ handle errors in response
        """
        # raise common http errors
        error_type = self.error_map.get(response.status_code)
        if error_type:
            raise error_type(response=response)
        # raise HttpResponseError
        error_format = self.ctx.get_error_format(self.error_format)
>       raise HttpResponseError(response=response, error_format=error_format)
E       azure.core.exceptions.HttpResponseError: (InvalidParameter) Scheduled Event Policy is not supported
E       Code: InvalidParameter
E       Message: Scheduled Event Policy is not supported
E       Target: scheduledEventsPolicy

src/azure-cli-core/azure/cli/core/aaz/_operation.py:327: HttpResponseError
azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:2159
Failed test_vm_avset_migrate self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f778848d6e0>
cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f778ba2c550>
command = 'vm availability-set validate-migration-to-vmss -n avset000002 -g cli_test_vm_avset_migrate000001 --vmss-flexible-id /...000000000/resourceGroups/cli_test_vm_avset_migrate000001/providers/Microsoft.Compute/virtualMachineScaleSets/vms000006'
expect_failure = False

    def in_process_execute(self, cli_ctx, command, expect_failure=False):
        from io import StringIO
        from vcr.errors import CannotOverwriteExistingCassetteException
    
        if command.startswith('az '):
            command = command[3:]
    
        stdout_buf = StringIO()
        logging_buf = StringIO()
        try:
            # issue: stderr cannot be redirect in this form, as a result some failure information
            # is lost when command fails.
>           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: 
                                        
env/lib/python3.13/site-packages/knack/cli.py:245: in invoke
    exit_code = self.exception_handler(ex)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/init.py:133: in exception_handler
    return handle_exception(ex)
           ^^^^^^^^^^^^^^^^^^^^
                                        

ex = HttpResponseError('(BadRequest) Subscription is not eligible to migrate Availability Set : avset000002 to Virtual Mach...quest\nMessage: Subscription is not eligible to migrate Availability Set : avset000002 to Virtual Machines Scale Set.')
args = (), kwargs = {}

    def handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception HttpResponseError during execution and fails the command.

src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <latest.test_vm_commands.VMAvailSetLiveScenarioTest testMethod=test_vm_avset_migrate>
resource_group = 'cli_test_vm_avset_migrate000001'

    @ResourceGroupPreparer(name_prefix='cli_test_vm_avset_migrate', location='westus2')
    def test_vm_avset_migrate(self, resource_group):
        self.kwargs.update({
            'avset1': self.create_random_name('avset', 15),
            'avset2': self.create_random_name('avset', 15),
            'vm1': self.create_random_name('vm', 10),
            'vm2': self.create_random_name('vm', 10),
            'vmss': self.create_random_name('vms', 10),
            'new_vmss': self.create_random_name('newvmss', 15),
        })
    
        self.cmd('vm availability-set create -g {rg} -n {avset1} --platform-fault-domain-count 2 --platform-update-domain-count 2', checks=[
            self.check('name', '{avset1}'),
            self.check('platformFaultDomainCount', 2)
        ])
        self.cmd('vm create -g {rg} -n {vm1} --image OpenLogic:CentOS:7.5:latest --admin-username vmtest --nsg-rule NONE --size Standard_B2ms --availability-set {avset1}')
        self.cmd('vmss create -g {rg} -n {vmss} --image OpenLogic:CentOS:7.5:latest --admin-username vmsstest --vm-sku Standard_B2ms')
        vmss = self.cmd('vmss show -g {rg} -n {vmss}').get_output_in_json()
        self.kwargs.update({
            'vmss_id': vmss['id'],
        })
>       self.cmd('vm availability-set validate-migration-to-vmss -n {avset1} -g {rg} --vmss-flexible-id {vmss_id}')

src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:2216: 
 
                                       
src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in in_process_execute
    raise ex.exception
env/lib/python3.13/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:669: in execute
    raise ex
src/azure-cli-core/azure/cli/core/commands/init.py:737: in run_jobs_serially
    results.append(self.run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:706: in run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/aaz/command.py:155: in call
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/__cmds.py:2198: in handler
    self.execute_operations()
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/__cmds.py:2234: in execute_operations
    self.AvailabilitySetsValidateMigrationToVirtualMachineScaleSet(ctx=self.ctx)()
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/__cmds.py:2254: in call
    return self.on_error(session.http_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 
 
 
 
 
 
 
 
                               

self = <azure.cli.command_modules.vm.aaz.latest.vm.availability_set.__cmds.ValidateMigrationToVmss.AvailabilitySetsValidateMigrationToVirtualMachineScaleSet object at 0x7f778863ba10>
response = RequestsTransportResponse: 400 , Content-Type: application/json; charset=utf-8

    def on_error(self, response):
        """ handle errors in response
        """
        # raise common http errors
        error_type = self.error_map.get(response.status_code)
        if error_type:
            raise error_type(response=response)
        # raise HttpResponseError
        error_format = self.ctx.get_error_format(self.error_format)
>       raise HttpResponseError(response=response, error_format=error_format)
E       azure.core.exceptions.HttpResponseError: (BadRequest) Subscription is not eligible to migrate Availability Set : avset000002 to Virtual Machines Scale Set.
E       Code: BadRequest
E       Message: Subscription is not eligible to migrate Availability Set : avset000002 to Virtual Machines Scale Set.

src/azure-cli-core/azure/cli/core/aaz/_operation.py:327: HttpResponseError
azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:2194

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

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

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

azure-client-tools-bot-prd bot commented Jan 21, 2026

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Collaborator

yonzhan commented Jan 21, 2026

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

@github-actions
Copy link

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 pull request migrates the az vm availability-set create command from using ARM template-based deployment to the AAZ (Azure CLI Code Generation) framework. The migration deprecates the --validate parameter since the command no longer generates ARM templates.

Changes:

  • Replaced ARM template-based implementation with direct AAZ API calls for availability set creation
  • Added deprecation notice for the --validate parameter with a clear error message
  • Generated new AAZ command class in _create.py using auto-generated code
  • Updated parameter help text to indicate the --validate option is deprecated

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/azure-cli/azure/cli/command_modules/vm/custom.py Refactored create_av_set function to call AAZ Create command instead of ARM template deployment; added error handling for deprecated --validate parameter
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/_create.py New auto-generated AAZ command class for availability set creation using API version 2024-07-01
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vm/availability_set/init.py Added import for the new Create command class
src/azure-cli/azure/cli/command_modules/vm/_params.py Updated help text for --validate parameter to indicate deprecation

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

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 az vm/vmss/image/disk/snapshot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants