Skip to content

Commit ca0978e

Browse files
committed
send security type to standard
1 parent 3c2e1fb commit ca0978e

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/azure-cli/azure/cli/command_modules/vm/_template_builder.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -675,11 +675,12 @@ def _build_storage_profile():
675675

676676
# The `Standard` is used for backward compatibility to allow customers to keep their current behavior
677677
# after changing the default values to Trusted Launch VMs in the future.
678-
from ._constants import COMPATIBLE_SECURITY_TYPE_VALUE
679-
if security_type is not None and security_type != COMPATIBLE_SECURITY_TYPE_VALUE:
678+
if security_type is not None:
680679
vm_properties['securityProfile']['securityType'] = security_type
681680

682-
if enable_secure_boot is not None or enable_vtpm is not None:
681+
from ._constants import COMPATIBLE_SECURITY_TYPE_VALUE
682+
if security_type != COMPATIBLE_SECURITY_TYPE_VALUE and (
683+
enable_secure_boot is not None or enable_vtpm is not None):
683684
vm_properties['securityProfile']['uefiSettings'] = {
684685
'secureBootEnabled': enable_secure_boot,
685686
'vTpmEnabled': enable_vtpm
@@ -1506,11 +1507,12 @@ def build_vmss_resource(cmd, name, computer_name_prefix, location, tags, overpro
15061507

15071508
# The `Standard` is used for backward compatibility to allow customers to keep their current behavior
15081509
# after changing the default values to Trusted Launch VMs in the future.
1509-
from ._constants import COMPATIBLE_SECURITY_TYPE_VALUE
1510-
if security_type is not None and security_type != COMPATIBLE_SECURITY_TYPE_VALUE:
1510+
if security_type is not None:
15111511
security_profile['securityType'] = security_type
15121512

1513-
if enable_secure_boot is not None or enable_vtpm is not None:
1513+
from ._constants import COMPATIBLE_SECURITY_TYPE_VALUE
1514+
if security_type != COMPATIBLE_SECURITY_TYPE_VALUE and (
1515+
enable_secure_boot is not None or enable_vtpm is not None):
15141516
security_profile['uefiSettings'] = {
15151517
'secureBootEnabled': enable_secure_boot,
15161518
'vTpmEnabled': enable_vtpm

src/azure-cli/azure/cli/command_modules/vm/custom.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,7 @@ def update_vm(cmd, resource_group_name, vm_name, os_disk=None, disk_caching=None
15971597
vm.storage_profile.os_disk.managed_disk.id = disk_id
15981598
vm.storage_profile.os_disk.name = disk_name
15991599

1600+
from ._constants import COMPATIBLE_SECURITY_TYPE_VALUE
16001601
if security_type == "TrustedLaunch":
16011602
from azure.cli.core.azclierror import InvalidArgumentValueError
16021603
if vm.security_profile is not None and vm.security_profile.security_type == "ConfidentialVM":
@@ -1615,6 +1616,11 @@ def update_vm(cmd, resource_group_name, vm_name, os_disk=None, disk_caching=None
16151616
if vm.security_profile is None:
16161617
vm.security_profile = SecurityProfile()
16171618
vm.security_profile.security_type = security_type
1619+
elif security_type == COMPATIBLE_SECURITY_TYPE_VALUE:
1620+
if vm.security_profile is None:
1621+
vm.security_profile = SecurityProfile()
1622+
vm.security_profile.security_type = security_type
1623+
vm.security_profile.uefi_settings = None
16181624

16191625
if write_accelerator is not None:
16201626
update_write_accelerator_settings(vm.storage_profile, write_accelerator)
@@ -1683,7 +1689,7 @@ def update_vm(cmd, resource_group_name, vm_name, os_disk=None, disk_caching=None
16831689
if proximity_placement_group is not None:
16841690
vm.proximity_placement_group = {'id': proximity_placement_group}
16851691

1686-
if enable_secure_boot is not None or enable_vtpm is not None:
1692+
if security_type != COMPATIBLE_SECURITY_TYPE_VALUE and (enable_secure_boot is not None or enable_vtpm is not None):
16871693
if vm.security_profile is None:
16881694
vm.security_profile = SecurityProfile()
16891695

0 commit comments

Comments
 (0)