From 1d831a538e5c83edb42e1760ce0a52431739d4f8 Mon Sep 17 00:00:00 2001 From: Qi Pan <43341456+Pan-Qi@users.noreply.github.com> Date: Tue, 21 Jul 2026 22:26:13 +1000 Subject: [PATCH 1/2] AI generation result --- .../azure/cli/command_modules/vm/_params.py | 4 +-- .../command_modules/vm/_template_builder.py | 4 +-- .../vm/tests/latest/test_vm_commands.py | 28 +++++++++++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/_params.py b/src/azure-cli/azure/cli/command_modules/vm/_params.py index cdd3e204932..3ab22dcd16b 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_params.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_params.py @@ -474,7 +474,7 @@ def load_arguments(self, _): c.argument('enable_user_redeploy_scheduled_events', options_list=['--enable-user-redeploy-scheduled-events', '--enable-redeploy'], arg_type=get_three_state_flag(), min_api='2024-07-01', help='The configuration parameter used while creating user initiated redeploy scheduled event setting creation.') c.argument('align_regional_disks_to_vm_zone', options_list=['--align-regional-disks-to-vm-zone', '--align-regional-disks'], arg_type=get_three_state_flag(), min_api='2024-11-01', help='Specify whether the regional disks should be aligned/moved to the VM zone. This is applicable only for VMs with placement property set. Please note that this change is irreversible.') c.argument('key_incarnation_id', type=int, min_api='2024-11-01', help='Increase the value of this property allows user to reset the key used for securing communication channel between guest and host.') - c.argument('security_type', arg_type=get_enum_type(["TrustedLaunch", "Standard", "ConfidentialVM"], default=None), help='Specify the security type of the virtual machine. The value Standard can be used if subscription has feature flag UseStandardSecurityType registered under Microsoft.Compute namespace. Refer to https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/preview-features for steps to enable required feature.') + c.argument('security_type', arg_type=get_enum_type(["TrustedLaunch", "Standard", "ConfidentialVM"], default=None), help='Specify the security type of the virtual machine.') c.argument('zone_movement', arg_type=get_three_state_flag(), help='Indicates if zone movement is enabled. By default isEnabled is set to false i.e VM can\'t be moved from one zone to another.') with self.argument_context('vm create', arg_group='Storage') as c: @@ -938,7 +938,7 @@ def load_arguments(self, _): c.argument('security_posture_reference_is_overridable', arg_type=get_three_state_flag(), min_api='2024-03-01', options_list=['--security-posture-reference-is-overridable', '--is-overridable'], help='Whether the security posture can be overridden by the user.') c.argument('zone_balance', arg_type=get_three_state_flag(), min_api='2017-12-01', help='Whether to force strictly even Virtual Machine distribution cross x-zones in case there is zone outage.') c.argument('security_type', arg_type=get_enum_type(["TrustedLaunch", "Standard", "ConfidentialVM"], default=None), - help='Specify the security type of the virtual machine scale set. The value Standard can be used if subscription has feature flag UseStandardSecurityType registered under Microsoft.Compute namespace. Refer to https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/preview-features for steps to enable required feature.') + help='Specify the security type of the virtual machine scale set.') c.argument('enable_automatic_zone_balancing', arg_type=get_three_state_flag(), options_list=['--enable-automatic-zone-balancing', '--enable-zone-balancing'], min_api='2024-11-01', help='Specify whether automatic AZ balancing should be enabled on the virtualmachine scale set.') c.argument('automatic_zone_balancing_strategy', arg_type=get_enum_type(self.get_models('RebalanceStrategy')), options_list=['--automatic-zone-balancing-strategy', '--balancing-strategy'], min_api='2024-11-01', help='Type of rebalance strategy that will be used for rebalancing virtualmachines in the scale set across availability zones.') c.argument('automatic_zone_balancing_behavior', arg_type=get_enum_type(self.get_models('RebalanceBehavior')), options_list=['--automatic-zone-balancing-behavior', '--balancing-behavior'], min_api='2024-11-01', help='Type of rebalance behavior that will be used for recreating virtualmachines in the scale set across availability zones.') diff --git a/src/azure-cli/azure/cli/command_modules/vm/_template_builder.py b/src/azure-cli/azure/cli/command_modules/vm/_template_builder.py index 30fe7067345..c50d0379423 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/_template_builder.py +++ b/src/azure-cli/azure/cli/command_modules/vm/_template_builder.py @@ -747,7 +747,7 @@ def _build_storage_profile(): } vm = { - 'apiVersion': '2025-04-01', + 'apiVersion': '2025-11-01', 'type': 'Microsoft.Compute/virtualMachines', 'name': name, 'location': location, @@ -1717,7 +1717,7 @@ def build_vmss_resource(cmd, name, computer_name_prefix, location, tags, overpro 'name': name, 'location': location, 'tags': tags, - 'apiVersion': '2025-04-01', + 'apiVersion': '2025-11-01', 'dependsOn': [], 'properties': vmss_properties } diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py index 4905dbfca9a..5e5422c8199 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py @@ -33,6 +33,24 @@ TEST_SSH_KEY_PUB_2 = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCof7rG2sYVyHSDPp4lbrq5zu8N8D7inS4Qb+ZZ5Kh410znTcoVJSNsLOhrM2COxg5LXca3DQMBi4S/V8UmMnwxwDVf38GvU+0QVDR6vSO6lPlj2OpPLk4OEdTv3qcj/gpEBvv1RCacpFuu5bL546r4BqG4f0dJXqBd5tT4kjpO9ytOZ1Wkg8tA35UvbucVAsDBfOZ5GtsnflPtKCY9h20LeXEjyDZ8eFzAGH/vNrfWPiWWznwN9EoPghIQHCiC0mnJgdsABraUzeTTMjxahi0DXBxb5dsKd6YbJxQw/V+AohVMPfPvs9y95Aj7IxM2zrtgBswC8bT0z678svTJSFX9 test@example.com" TEST_SSH_KEY_PUB_ED25519 = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE+N4unGvv6pXPYebWiQ6Ak618DjYm5g6d2ECnq/1F0x generated-by-azure" + +def _check_security_profile_absent_or_standard(*path): + def _check(execution_result): + output = json.loads(execution_result.output) + security_profile = output + for key in path: + if not isinstance(security_profile, dict) or key not in security_profile: + return + security_profile = security_profile[key] + + if security_profile in (None, 'None'): + return + if isinstance(security_profile, dict) and security_profile.get('securityType') == 'Standard': + return + raise AssertionError('Expected security profile to be absent or Standard, got {}'.format(security_profile)) + + return _check + def _write_config_file(user_name): public_key = ('ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC8InHIPLAu6lMc0d+5voyXqigZfT5r6fAM1+FQAi+mkPDdk2hNq1BG0Bwfc88G' @@ -5415,7 +5433,7 @@ def test_vmss_update_security_type(self): self.cmd('vmss update -g {rg} -n {vmss3} --security-type Standard') self.cmd('vmss show -g {rg} -n {vmss3}', checks=[ self.check('name', '{vmss3}'), - self.check('securityProfile', None), + _check_security_profile_absent_or_standard('virtualMachineProfile', 'securityProfile'), ]) self.cmd('vmss create -n {vmss4} -g {rg} --image {img4} --admin-username vmtest --admin-password Test123456789# --vm-sku Standard_DC2as_v5 --nsg {nsg} ' @@ -6946,7 +6964,7 @@ def test_vmss_run_command_v2(self, resource_group): '--generate-ssh-keys --orchestration-mode Uniform --lb-sku Standard --vm-sku Standard_B2ms') self.cmd('vmss show -g {rg} -n {vmss}', checks=[ self.check('name', '{vmss}'), - self.check('securityProfile', None), + _check_security_profile_absent_or_standard('virtualMachineProfile', 'securityProfile'), ]) instace_ids = self.cmd('vmss list-instances --resource-group {rg} --name {vmss} --query "[].instanceId"').get_output_in_json() self.kwargs.update({ @@ -10227,7 +10245,7 @@ def test_vm_create_special_name(self, resource_group): self.cmd('vm show -g {rg} -n {vm}', checks=[ self.check('name', '{vm}'), - self.check('securityProfile', None), + _check_security_profile_absent_or_standard('securityProfile'), self.check('osProfile.computerName', 'vm1') ]) @@ -12244,7 +12262,7 @@ def test_vm_trusted_launch(self, resource_group): self.cmd('vm create -g {rg} -n {vm2} --image OpenLogic:CentOS:7_6-gen2:latest --admin-username azureuser --admin-password testPassword0 ' '--subnet {subnet} --vnet-name {vnet} --size Standard_B2ms --nsg-rule None') self.cmd('vm show -g {rg} -n {vm2}', checks=[ - self.check('securityProfile', 'None') + _check_security_profile_absent_or_standard('securityProfile') ]) # create VM with specifying security type Standard @@ -12252,7 +12270,7 @@ def test_vm_trusted_launch(self, resource_group): self.cmd('vm create -g {rg} -n {vm3} --image canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:latest --size Standard_B2ms ' '--admin-username clitest1 --generate-ssh-key --security-type Standard --subnet {subnet} --vnet-name {vnet} --nsg-rule None') self.cmd('vm show -g {rg} -n {vm3}', checks=[ - self.check('securityProfile', 'None') + _check_security_profile_absent_or_standard('securityProfile') ]) @AllowLargeResponse(size_kb=99999) From e0bf89c4ce70542c98b48dc8141c49049d1c1809 Mon Sep 17 00:00:00 2001 From: Qi Pan <43341456+Pan-Qi@users.noreply.github.com> Date: Tue, 21 Jul 2026 22:45:28 +1000 Subject: [PATCH 2/2] generation v2 --- .../vm/tests/latest/test_vm_commands.py | 28 ++++--------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py index 5e5422c8199..569ea127763 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py @@ -33,24 +33,6 @@ TEST_SSH_KEY_PUB_2 = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCof7rG2sYVyHSDPp4lbrq5zu8N8D7inS4Qb+ZZ5Kh410znTcoVJSNsLOhrM2COxg5LXca3DQMBi4S/V8UmMnwxwDVf38GvU+0QVDR6vSO6lPlj2OpPLk4OEdTv3qcj/gpEBvv1RCacpFuu5bL546r4BqG4f0dJXqBd5tT4kjpO9ytOZ1Wkg8tA35UvbucVAsDBfOZ5GtsnflPtKCY9h20LeXEjyDZ8eFzAGH/vNrfWPiWWznwN9EoPghIQHCiC0mnJgdsABraUzeTTMjxahi0DXBxb5dsKd6YbJxQw/V+AohVMPfPvs9y95Aj7IxM2zrtgBswC8bT0z678svTJSFX9 test@example.com" TEST_SSH_KEY_PUB_ED25519 = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE+N4unGvv6pXPYebWiQ6Ak618DjYm5g6d2ECnq/1F0x generated-by-azure" - -def _check_security_profile_absent_or_standard(*path): - def _check(execution_result): - output = json.loads(execution_result.output) - security_profile = output - for key in path: - if not isinstance(security_profile, dict) or key not in security_profile: - return - security_profile = security_profile[key] - - if security_profile in (None, 'None'): - return - if isinstance(security_profile, dict) and security_profile.get('securityType') == 'Standard': - return - raise AssertionError('Expected security profile to be absent or Standard, got {}'.format(security_profile)) - - return _check - def _write_config_file(user_name): public_key = ('ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC8InHIPLAu6lMc0d+5voyXqigZfT5r6fAM1+FQAi+mkPDdk2hNq1BG0Bwfc88G' @@ -5433,7 +5415,7 @@ def test_vmss_update_security_type(self): self.cmd('vmss update -g {rg} -n {vmss3} --security-type Standard') self.cmd('vmss show -g {rg} -n {vmss3}', checks=[ self.check('name', '{vmss3}'), - _check_security_profile_absent_or_standard('virtualMachineProfile', 'securityProfile'), + self.check('virtualMachineProfile.securityProfile.securityType', 'Standard'), ]) self.cmd('vmss create -n {vmss4} -g {rg} --image {img4} --admin-username vmtest --admin-password Test123456789# --vm-sku Standard_DC2as_v5 --nsg {nsg} ' @@ -6964,7 +6946,7 @@ def test_vmss_run_command_v2(self, resource_group): '--generate-ssh-keys --orchestration-mode Uniform --lb-sku Standard --vm-sku Standard_B2ms') self.cmd('vmss show -g {rg} -n {vmss}', checks=[ self.check('name', '{vmss}'), - _check_security_profile_absent_or_standard('virtualMachineProfile', 'securityProfile'), + self.check('virtualMachineProfile.securityProfile.securityType', 'Standard'), ]) instace_ids = self.cmd('vmss list-instances --resource-group {rg} --name {vmss} --query "[].instanceId"').get_output_in_json() self.kwargs.update({ @@ -10245,7 +10227,7 @@ def test_vm_create_special_name(self, resource_group): self.cmd('vm show -g {rg} -n {vm}', checks=[ self.check('name', '{vm}'), - _check_security_profile_absent_or_standard('securityProfile'), + self.check('securityProfile.securityType', 'Standard'), self.check('osProfile.computerName', 'vm1') ]) @@ -12262,7 +12244,7 @@ def test_vm_trusted_launch(self, resource_group): self.cmd('vm create -g {rg} -n {vm2} --image OpenLogic:CentOS:7_6-gen2:latest --admin-username azureuser --admin-password testPassword0 ' '--subnet {subnet} --vnet-name {vnet} --size Standard_B2ms --nsg-rule None') self.cmd('vm show -g {rg} -n {vm2}', checks=[ - _check_security_profile_absent_or_standard('securityProfile') + self.check('securityProfile.securityType', 'Standard') ]) # create VM with specifying security type Standard @@ -12270,7 +12252,7 @@ def test_vm_trusted_launch(self, resource_group): self.cmd('vm create -g {rg} -n {vm3} --image canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:latest --size Standard_B2ms ' '--admin-username clitest1 --generate-ssh-key --security-type Standard --subnet {subnet} --vnet-name {vnet} --nsg-rule None') self.cmd('vm show -g {rg} -n {vm3}', checks=[ - _check_security_profile_absent_or_standard('securityProfile') + self.check('securityProfile.securityType', 'Standard') ]) @AllowLargeResponse(size_kb=99999)