Skip to content

Commit 2df75ef

Browse files
authored
[Compute] az vm create: Add parameters --data-disk-mbps and --data-disk-iops to support IOPS and MBPS (#32717)
1 parent 55b9e97 commit 2df75ef

File tree

6 files changed

+5195
-7
lines changed

6 files changed

+5195
-7
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ def load_arguments(self, _):
431431
c.argument('name', name_arg_type, validator=_resource_not_exists(self.cli_ctx, 'Microsoft.Compute/virtualMachines'))
432432
c.argument('vm_name', name_arg_type, id_part=None, help='Name of the virtual machine.', completer=None)
433433
c.argument('os_disk_size_gb', type=int, help='the size of the os disk in GB', arg_group='Storage')
434+
c.argument('disk_iops_read_write', options_list=['--data-disk-iops'], type=int, help='Specify the Read-Write IOPS for the managed disk when storage account type is UltraSSD_LRS.')
435+
c.argument('disk_mbps_read_write', options_list=['--data-disk-mbps'], type=int, help='Specify the bandwidth in MB per second for the managed disk when storage account type is UltraSSD_LRS.')
434436
c.argument('availability_set', help='Name or ID of an existing availability set to add the VM to. None by default.')
435437
c.argument('vmss', help='Name or ID of an existing virtual machine scale set that the virtual machine should be assigned to. None by default.')
436438
c.argument('nsg', help='The name to use when creating a new Network Security Group (default) or referencing an existing one. Can also reference an existing NSG by ID or specify "" for none (\'""\' in Azure CLI using PowerShell or --% operator).', arg_group='Network')

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def build_msi_role_assignment(vm_vmss_name, vm_vmss_resource_id, role_definition
294294

295295

296296
def build_vm_resource( # pylint: disable=too-many-locals, too-many-statements, too-many-branches
297-
cmd, name, location, tags, size, storage_profile, nics, admin_username,
297+
name, location, tags, size, storage_profile, nics, admin_username,
298298
availability_set_id=None, admin_password=None, ssh_key_values=None, ssh_key_path=None,
299299
image_reference=None, os_disk_name=None, custom_image_os_type=None, authentication_type=None,
300300
os_publisher=None, os_offer=None, os_sku=None, os_version=None, os_vhd_uri=None,
@@ -311,7 +311,8 @@ def build_vm_resource( # pylint: disable=too-many-locals, too-many-statements,
311311
enable_user_reboot_scheduled_events=None, enable_user_redeploy_scheduled_events=None,
312312
zone_placement_policy=None, include_zones=None, exclude_zones=None, align_regional_disks_to_vm_zone=None,
313313
wire_server_mode=None, imds_mode=None, wire_server_access_control_profile_reference_id=None,
314-
imds_access_control_profile_reference_id=None, key_incarnation_id=None, add_proxy_agent_extension=None):
314+
imds_access_control_profile_reference_id=None, key_incarnation_id=None, add_proxy_agent_extension=None,
315+
disk_iops_read_write=None, disk_mbps_read_write=None):
315316

316317
os_caching = disk_info['os'].get('caching')
317318

@@ -568,7 +569,11 @@ def _build_storage_profile():
568569
data_disk['managedDisk']['diskEncryptionSet'] = {'id': data_disk_encryption_sets[i]}
569570
if data_disks:
570571
profile['dataDisks'] = data_disks
571-
572+
for data_disk in profile['dataDisks']:
573+
if disk_iops_read_write is not None:
574+
data_disk['diskIOPSReadWrite'] = disk_iops_read_write
575+
if disk_mbps_read_write is not None:
576+
data_disk['diskMBPSReadWrite'] = disk_mbps_read_write
572577
if disk_info['os'].get('diffDiskSettings'):
573578
profile['osDisk']['diffDiskSettings'] = disk_info['os']['diffDiskSettings']
574579

@@ -732,7 +737,7 @@ def _build_storage_profile():
732737
}
733738

734739
vm = {
735-
'apiVersion': cmd.get_api_version(ResourceType.MGMT_COMPUTE, operation_group='virtual_machines'),
740+
'apiVersion': '2025-04-01',
736741
'type': 'Microsoft.Compute/virtualMachines',
737742
'name': name,
738743
'location': location,

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,8 @@ def create_vm(cmd, vm_name, resource_group_name, image=None, size='Standard_DS1_
955955
enable_user_redeploy_scheduled_events=None, zone_placement_policy=None, include_zones=None,
956956
exclude_zones=None, align_regional_disks_to_vm_zone=None, wire_server_mode=None, imds_mode=None,
957957
wire_server_access_control_profile_reference_id=None, imds_access_control_profile_reference_id=None,
958-
key_incarnation_id=None, add_proxy_agent_extension=None):
958+
key_incarnation_id=None, add_proxy_agent_extension=None, disk_iops_read_write=None,
959+
disk_mbps_read_write=None):
959960

960961
from azure.cli.core.commands.client_factory import get_subscription_id
961962
from azure.cli.core.util import random_string, hash_string
@@ -1156,7 +1157,7 @@ def create_vm(cmd, vm_name, resource_group_name, image=None, size='Standard_DS1_
11561157
secrets = _merge_secrets([validate_file_or_dict(secret) for secret in secrets])
11571158

11581159
vm_resource = build_vm_resource(
1159-
cmd=cmd, name=vm_name, location=location, tags=tags, size=size, storage_profile=storage_profile, nics=nics,
1160+
name=vm_name, location=location, tags=tags, size=size, storage_profile=storage_profile, nics=nics,
11601161
admin_username=admin_username, availability_set_id=availability_set, admin_password=admin_password,
11611162
ssh_key_values=ssh_key_value, ssh_key_path=ssh_dest_key_path, image_reference=image,
11621163
os_disk_name=os_disk_name, custom_image_os_type=os_type, authentication_type=authentication_type,
@@ -1185,7 +1186,8 @@ def create_vm(cmd, vm_name, resource_group_name, image=None, size='Standard_DS1_
11851186
imds_mode=imds_mode,
11861187
wire_server_access_control_profile_reference_id=wire_server_access_control_profile_reference_id,
11871188
imds_access_control_profile_reference_id=imds_access_control_profile_reference_id,
1188-
key_incarnation_id=key_incarnation_id, add_proxy_agent_extension=add_proxy_agent_extension)
1189+
key_incarnation_id=key_incarnation_id, add_proxy_agent_extension=add_proxy_agent_extension,
1190+
disk_iops_read_write=disk_iops_read_write, disk_mbps_read_write=disk_mbps_read_write)
11891191

11901192
vm_resource['dependsOn'] = vm_dependencies
11911193

0 commit comments

Comments
 (0)