Skip to content

Commit 604774c

Browse files
authored
[Compute] az disk create/grant-access: Support Confidential VM OS Disks (#31934)
1 parent f87bc09 commit 604774c

File tree

45 files changed

+22928
-25135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+22928
-25135
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def load_arguments(self, _):
206206
c.argument('upload_type', arg_type=get_enum_type(['Upload', 'UploadWithSecurityData']), min_api='2018-09-30',
207207
help="Create the disk for upload scenario. 'Upload' is for Standard disk only upload. 'UploadWithSecurityData' is for OS Disk upload along with VM Guest State. Please note the 'UploadWithSecurityData' is not valid for data disk upload, it only to be used for OS Disk upload at present.")
208208
c.argument('performance_plus', arg_type=get_three_state_flag(), min_api='2022-07-02', help='Set this flag to true to get a boost on the performance target of the disk deployed. This flag can only be set on disk creation time and cannot be disabled after enabled')
209+
c.argument('security_metadata_uri', help='Specify the blob URI to be imported into VM metadata for Confidential VM')
209210
# endregion
210211

211212
# region Snapshots

src/azure-cli/azure/cli/command_modules/vm/aaz/latest/disk/_create.py

Lines changed: 95 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ class Create(AAZCommand):
7070
"""
7171

7272
_aaz_info = {
73-
"version": "2023-04-02",
73+
"version": "2025-01-02",
7474
"resources": [
75-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/disks/{}", "2023-04-02"],
75+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/disks/{}", "2025-01-02"],
7676
]
7777
}
7878

@@ -161,6 +161,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
161161
# define Arg Group "Properties"
162162

163163
_args_schema = cls._args_schema
164+
_args_schema.availability_policy = AAZObjectArg(
165+
options=["--availability-policy"],
166+
arg_group="Properties",
167+
help="Determines how platform treats disk failures",
168+
)
164169
_args_schema.bursting_enabled = AAZBoolArg(
165170
options=["--bursting-enabled"],
166171
arg_group="Properties",
@@ -267,6 +272,13 @@ def _build_arguments_schema(cls, *args, **kwargs):
267272
help="Performance tier of the disk (e.g, P4, S10) as described here: https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Does not apply to Ultra disks.",
268273
)
269274

275+
availability_policy = cls._args_schema.availability_policy
276+
availability_policy.action_on_disk_delay = AAZStrArg(
277+
options=["action-on-disk-delay"],
278+
help="Determines on how to handle disks with slow I/O.",
279+
enum={"AutomaticReattach": "AutomaticReattach", "None": "None"},
280+
)
281+
270282
creation_data = cls._args_schema.creation_data
271283
creation_data.create_option = AAZStrArg(
272284
options=["create-option"],
@@ -288,6 +300,13 @@ def _build_arguments_schema(cls, *args, **kwargs):
288300
help="Disk source information for PIR or user images.",
289301
)
290302
cls._build_args_image_disk_reference_create(creation_data.image_reference)
303+
creation_data.instant_access_duration_minutes = AAZIntArg(
304+
options=["instant-access-duration-minutes"],
305+
help="For snapshots created from Premium SSD v2 or Ultra disk, this property determines the time in minutes the snapshot is retained for instant access to enable faster restore.",
306+
fmt=AAZIntArgFormat(
307+
minimum=1,
308+
),
309+
)
291310
creation_data.logical_sector_size = AAZIntArg(
292311
options=["logical-sector-size"],
293312
help="Logical sector size in bytes for Ultra disks. Supported values are 512 ad 4096. 4096 is the default.",
@@ -296,10 +315,19 @@ def _build_arguments_schema(cls, *args, **kwargs):
296315
options=["performance-plus"],
297316
help="Set this flag to true to get a boost on the performance target of the disk deployed, see here on the respective performance target. This flag can only be set on disk creation time and cannot be disabled after enabled.",
298317
)
318+
creation_data.provisioned_bandwidth_copy_speed = AAZStrArg(
319+
options=["provisioned-bandwidth-copy-speed"],
320+
help="If this field is set on a snapshot and createOption is CopyStart, the snapshot will be copied at a quicker speed.",
321+
enum={"Enhanced": "Enhanced", "None": "None"},
322+
)
299323
creation_data.security_data_uri = AAZStrArg(
300324
options=["security-data-uri"],
301325
help="If createOption is ImportSecure, this is the URI of a blob to be imported into VM guest state.",
302326
)
327+
creation_data.security_metadata_uri = AAZStrArg(
328+
options=["security-metadata-uri"],
329+
help="If createOption is ImportSecure, this is the URI of a blob to be imported into VM metadata for Confidential VM.",
330+
)
303331
creation_data.source_resource_id = AAZStrArg(
304332
options=["source-resource-id"],
305333
help="If createOption is Copy, this is the ARM id of the source snapshot or disk.",
@@ -336,7 +364,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
336364
security_profile.security_type = AAZStrArg(
337365
options=["security-type"],
338366
help="Specifies the SecurityType of the VM. Applicable for OS disks only.",
339-
enum={"ConfidentialVM_DiskEncryptedWithCustomerKey": "ConfidentialVM_DiskEncryptedWithCustomerKey", "ConfidentialVM_DiskEncryptedWithPlatformKey": "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey": "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", "TrustedLaunch": "TrustedLaunch"},
367+
enum={"ConfidentialVM_DiskEncryptedWithCustomerKey": "ConfidentialVM_DiskEncryptedWithCustomerKey", "ConfidentialVM_DiskEncryptedWithPlatformKey": "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_NonPersistedTPM": "ConfidentialVM_NonPersistedTPM", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey": "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", "TrustedLaunch": "TrustedLaunch"},
340368
)
341369

342370
supported_capabilities = cls._args_schema.supported_capabilities
@@ -353,6 +381,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
353381
options=["disk-controller-types"],
354382
help="The disk controllers that an OS disk supports. If set it can be SCSI or SCSI, NVME or NVME, SCSI.",
355383
)
384+
supported_capabilities.supported_security_option = AAZStrArg(
385+
options=["supported-security-option"],
386+
help="Refers to the security capability of the disk supported to create a Trusted launch or Confidential VM",
387+
enum={"TrustedLaunchAndConfidentialVMSupported": "TrustedLaunchAndConfidentialVMSupported", "TrustedLaunchSupported": "TrustedLaunchSupported"},
388+
)
356389
return cls._args_schema
357390

358391
_args_image_disk_reference_create = None
@@ -438,7 +471,7 @@ def __call__(self, *args, **kwargs):
438471
session,
439472
self.on_200,
440473
self.on_error,
441-
lro_options={"final-state-via": "azure-async-operation"},
474+
lro_options={"final-state-via": "location"},
442475
path_format_arguments=self.url_parameters,
443476
)
444477
if session.http_response.status_code in [200]:
@@ -447,7 +480,7 @@ def __call__(self, *args, **kwargs):
447480
session,
448481
self.on_200,
449482
self.on_error,
450-
lro_options={"final-state-via": "azure-async-operation"},
483+
lro_options={"final-state-via": "location"},
451484
path_format_arguments=self.url_parameters,
452485
)
453486

@@ -466,7 +499,7 @@ def method(self):
466499

467500
@property
468501
def error_format(self):
469-
return "MgmtErrorFormat"
502+
return "ODataV4Format"
470503

471504
@property
472505
def url_parameters(self):
@@ -490,7 +523,7 @@ def url_parameters(self):
490523
def query_parameters(self):
491524
parameters = {
492525
**self.serialize_query_param(
493-
"api-version", "2023-04-02",
526+
"api-version", "2025-01-02",
494527
required=True,
495528
),
496529
}
@@ -529,6 +562,7 @@ def content(self):
529562

530563
properties = _builder.get(".properties")
531564
if properties is not None:
565+
properties.set_prop("availabilityPolicy", AAZObjectType, ".availability_policy")
532566
properties.set_prop("burstingEnabled", AAZBoolType, ".bursting_enabled")
533567
properties.set_prop("creationData", AAZObjectType, ".creation_data", typ_kwargs={"flags": {"required": True}})
534568
properties.set_prop("dataAccessAuthMode", AAZStrType, ".data_access_auth_mode")
@@ -550,15 +584,22 @@ def content(self):
550584
properties.set_prop("supportsHibernation", AAZBoolType, ".supports_hibernation")
551585
properties.set_prop("tier", AAZStrType, ".tier")
552586

587+
availability_policy = _builder.get(".properties.availabilityPolicy")
588+
if availability_policy is not None:
589+
availability_policy.set_prop("actionOnDiskDelay", AAZStrType, ".action_on_disk_delay")
590+
553591
creation_data = _builder.get(".properties.creationData")
554592
if creation_data is not None:
555593
creation_data.set_prop("createOption", AAZStrType, ".create_option", typ_kwargs={"flags": {"required": True}})
556594
creation_data.set_prop("elasticSanResourceId", AAZStrType, ".elastic_san_resource_id")
557595
_CreateHelper._build_schema_image_disk_reference_create(creation_data.set_prop("galleryImageReference", AAZObjectType, ".gallery_image_reference"))
558596
_CreateHelper._build_schema_image_disk_reference_create(creation_data.set_prop("imageReference", AAZObjectType, ".image_reference"))
597+
creation_data.set_prop("instantAccessDurationMinutes", AAZIntType, ".instant_access_duration_minutes")
559598
creation_data.set_prop("logicalSectorSize", AAZIntType, ".logical_sector_size")
560599
creation_data.set_prop("performancePlus", AAZBoolType, ".performance_plus")
600+
creation_data.set_prop("provisionedBandwidthCopySpeed", AAZStrType, ".provisioned_bandwidth_copy_speed")
561601
creation_data.set_prop("securityDataUri", AAZStrType, ".security_data_uri")
602+
creation_data.set_prop("securityMetadataUri", AAZStrType, ".security_metadata_uri")
562603
creation_data.set_prop("sourceResourceId", AAZStrType, ".source_resource_id")
563604
creation_data.set_prop("sourceUri", AAZStrType, ".source_uri")
564605
creation_data.set_prop("storageAccountId", AAZStrType, ".storage_account_id")
@@ -579,6 +620,7 @@ def content(self):
579620
supported_capabilities.set_prop("acceleratedNetwork", AAZBoolType, ".accelerated_network")
580621
supported_capabilities.set_prop("architecture", AAZStrType, ".architecture")
581622
supported_capabilities.set_prop("diskControllerTypes", AAZStrType, ".disk_controller_types")
623+
supported_capabilities.set_prop("supportedSecurityOption", AAZStrType, ".supported_security_option")
582624

583625
sku = _builder.get(".sku")
584626
if sku is not None:
@@ -646,6 +688,7 @@ def _build_schema_disk_read(cls, _schema):
646688
_schema.name = cls._schema_disk_read.name
647689
_schema.properties = cls._schema_disk_read.properties
648690
_schema.sku = cls._schema_disk_read.sku
691+
_schema.system_data = cls._schema_disk_read.system_data
649692
_schema.tags = cls._schema_disk_read.tags
650693
_schema.type = cls._schema_disk_read.type
651694
_schema.zones = cls._schema_disk_read.zones
@@ -678,6 +721,10 @@ def _build_schema_disk_read(cls, _schema):
678721
flags={"client_flatten": True},
679722
)
680723
disk_read.sku = AAZObjectType()
724+
disk_read.system_data = AAZObjectType(
725+
serialized_name="systemData",
726+
flags={"read_only": True},
727+
)
681728
disk_read.tags = AAZDictType()
682729
disk_read.type = AAZStrType(
683730
flags={"read_only": True},
@@ -696,6 +743,9 @@ def _build_schema_disk_read(cls, _schema):
696743
serialized_name="LastOwnershipUpdateTime",
697744
flags={"read_only": True},
698745
)
746+
properties.availability_policy = AAZObjectType(
747+
serialized_name="availabilityPolicy",
748+
)
699749
properties.bursting_enabled = AAZBoolType(
700750
serialized_name="burstingEnabled",
701751
)
@@ -795,6 +845,11 @@ def _build_schema_disk_read(cls, _schema):
795845
flags={"read_only": True},
796846
)
797847

848+
availability_policy = _schema_disk_read.properties.availability_policy
849+
availability_policy.action_on_disk_delay = AAZStrType(
850+
serialized_name="actionOnDiskDelay",
851+
)
852+
798853
creation_data = _schema_disk_read.properties.creation_data
799854
creation_data.create_option = AAZStrType(
800855
serialized_name="createOption",
@@ -811,15 +866,24 @@ def _build_schema_disk_read(cls, _schema):
811866
serialized_name="imageReference",
812867
)
813868
cls._build_schema_image_disk_reference_read(creation_data.image_reference)
869+
creation_data.instant_access_duration_minutes = AAZIntType(
870+
serialized_name="instantAccessDurationMinutes",
871+
)
814872
creation_data.logical_sector_size = AAZIntType(
815873
serialized_name="logicalSectorSize",
816874
)
817875
creation_data.performance_plus = AAZBoolType(
818876
serialized_name="performancePlus",
819877
)
878+
creation_data.provisioned_bandwidth_copy_speed = AAZStrType(
879+
serialized_name="provisionedBandwidthCopySpeed",
880+
)
820881
creation_data.security_data_uri = AAZStrType(
821882
serialized_name="securityDataUri",
822883
)
884+
creation_data.security_metadata_uri = AAZStrType(
885+
serialized_name="securityMetadataUri",
886+
)
823887
creation_data.source_resource_id = AAZStrType(
824888
serialized_name="sourceResourceId",
825889
)
@@ -931,13 +995,36 @@ def _build_schema_disk_read(cls, _schema):
931995
supported_capabilities.disk_controller_types = AAZStrType(
932996
serialized_name="diskControllerTypes",
933997
)
998+
supported_capabilities.supported_security_option = AAZStrType(
999+
serialized_name="supportedSecurityOption",
1000+
)
9341001

9351002
sku = _schema_disk_read.sku
9361003
sku.name = AAZStrType()
9371004
sku.tier = AAZStrType(
9381005
flags={"read_only": True},
9391006
)
9401007

1008+
system_data = _schema_disk_read.system_data
1009+
system_data.created_at = AAZStrType(
1010+
serialized_name="createdAt",
1011+
)
1012+
system_data.created_by = AAZStrType(
1013+
serialized_name="createdBy",
1014+
)
1015+
system_data.created_by_type = AAZStrType(
1016+
serialized_name="createdByType",
1017+
)
1018+
system_data.last_modified_at = AAZStrType(
1019+
serialized_name="lastModifiedAt",
1020+
)
1021+
system_data.last_modified_by = AAZStrType(
1022+
serialized_name="lastModifiedBy",
1023+
)
1024+
system_data.last_modified_by_type = AAZStrType(
1025+
serialized_name="lastModifiedByType",
1026+
)
1027+
9411028
tags = _schema_disk_read.tags
9421029
tags.Element = AAZStrType()
9431030

@@ -952,6 +1039,7 @@ def _build_schema_disk_read(cls, _schema):
9521039
_schema.name = cls._schema_disk_read.name
9531040
_schema.properties = cls._schema_disk_read.properties
9541041
_schema.sku = cls._schema_disk_read.sku
1042+
_schema.system_data = cls._schema_disk_read.system_data
9551043
_schema.tags = cls._schema_disk_read.tags
9561044
_schema.type = cls._schema_disk_read.type
9571045
_schema.zones = cls._schema_disk_read.zones

src/azure-cli/azure/cli/command_modules/vm/aaz/latest/disk/_grant_access.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class GrantAccess(AAZCommand):
2525
"""
2626

2727
_aaz_info = {
28-
"version": "2023-04-02",
28+
"version": "2025-01-02",
2929
"resources": [
30-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/disks/{}/begingetaccess", "2023-04-02"],
30+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.compute/disks/{}/begingetaccess", "2025-01-02"],
3131
]
3232
}
3333

@@ -139,7 +139,7 @@ def method(self):
139139

140140
@property
141141
def error_format(self):
142-
return "MgmtErrorFormat"
142+
return "ODataV4Format"
143143

144144
@property
145145
def url_parameters(self):
@@ -163,7 +163,7 @@ def url_parameters(self):
163163
def query_parameters(self):
164164
parameters = {
165165
**self.serialize_query_param(
166-
"api-version", "2023-04-02",
166+
"api-version", "2025-01-02",
167167
required=True,
168168
),
169169
}
@@ -220,6 +220,10 @@ def _build_schema_on_200(cls):
220220
serialized_name="securityDataAccessSAS",
221221
flags={"read_only": True},
222222
)
223+
_schema_on_200.security_metadata_access_sas = AAZStrType(
224+
serialized_name="securityMetadataAccessSAS",
225+
flags={"read_only": True},
226+
)
223227

224228
return cls._schema_on_200
225229

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def create_managed_disk(cmd, resource_group_name, disk_name, location=None, # p
364364
public_network_access=None, accelerated_network=None, architecture=None,
365365
data_access_auth_mode=None, gallery_image_reference_type=None, security_data_uri=None,
366366
upload_type=None, secure_vm_disk_encryption_set=None, performance_plus=None,
367-
optimized_for_frequent_attach=None):
367+
optimized_for_frequent_attach=None, security_metadata_uri=None):
368368

369369
from azure.mgmt.core.tools import resource_id, is_valid_resource_id
370370
from azure.cli.core.commands.client_factory import get_subscription_id
@@ -459,7 +459,8 @@ def create_managed_disk(cmd, resource_group_name, disk_name, location=None, # p
459459
"upload_size_bytes": upload_size_bytes,
460460
"logical_sector_size": logical_sector_size,
461461
"security_data_uri": security_data_uri,
462-
"performance_plus": performance_plus
462+
"performance_plus": performance_plus,
463+
"security_metadata_uri": security_metadata_uri,
463464
}
464465

465466
if size_gb is None and option == "Empty":

0 commit comments

Comments
 (0)