Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/vm/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ def load_arguments(self, _):
c.argument('name', name_arg_type, validator=_resource_not_exists(self.cli_ctx, 'Microsoft.Compute/virtualMachines'))
c.argument('vm_name', name_arg_type, id_part=None, help='Name of the virtual machine.', completer=None)
c.argument('os_disk_size_gb', type=int, help='the size of the os disk in GB', arg_group='Storage')
c.argument('disk_iops_read_write', options_list=['--data-disk-iops'], type=int, help='Specifies the Read-Write IOPS for the managed disk when StorageAccountType is UltraSSD_LRS.')
c.argument('disk_mbps_read_write', options_list=['--data-disk-mbps'], type=int, help='Specifies the bandwidth in MB per second for the managed disk when StorageAccountType is UltraSSD_LRS.')
c.argument('availability_set', help='Name or ID of an existing availability set to add the VM to. None by default.')
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.')
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')
Expand Down
17 changes: 11 additions & 6 deletions src/azure-cli/azure/cli/command_modules/vm/_template_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def build_msi_role_assignment(vm_vmss_name, vm_vmss_resource_id, role_definition


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

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

Expand Down Expand Up @@ -567,8 +568,12 @@ def _build_storage_profile():
for i, data_disk in enumerate(data_disks):
data_disk['managedDisk']['diskEncryptionSet'] = {'id': data_disk_encryption_sets[i]}
if data_disks:
profile['dataDisks'] = data_disks

profile['dataDisks'] = list(data_disks)
for data_disk in profile['dataDisks']:
if disk_iops_read_write is not None:
data_disk['diskIOPSReadWrite'] = disk_iops_read_write
if disk_mbps_read_write is not None:
data_disk['diskMBPSReadWrite'] = disk_mbps_read_write
if disk_info['os'].get('diffDiskSettings'):
profile['osDisk']['diffDiskSettings'] = disk_info['os']['diffDiskSettings']

Expand Down Expand Up @@ -732,7 +737,7 @@ def _build_storage_profile():
}

vm = {
'apiVersion': cmd.get_api_version(ResourceType.MGMT_COMPUTE, operation_group='virtual_machines'),
'apiVersion': '2025-04-01',
'type': 'Microsoft.Compute/virtualMachines',
'name': name,
'location': location,
Expand Down Expand Up @@ -1239,7 +1244,7 @@ def build_vmss_resource(cmd, name, computer_name_prefix, location, tags, overpro
for i, data_disk in enumerate(data_disks):
data_disk['diskMBpsReadWrite'] = data_disk_mbps[i]
if data_disks:
storage_properties['dataDisks'] = data_disks
storage_properties['dataDisks'] = list(data_disks)
if disk_controller_type is not None:
storage_properties['diskControllerType'] = disk_controller_type

Expand Down
8 changes: 5 additions & 3 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,8 @@ def create_vm(cmd, vm_name, resource_group_name, image=None, size='Standard_DS1_
enable_user_redeploy_scheduled_events=None, zone_placement_policy=None, include_zones=None,
exclude_zones=None, align_regional_disks_to_vm_zone=None, wire_server_mode=None, imds_mode=None,
wire_server_access_control_profile_reference_id=None, imds_access_control_profile_reference_id=None,
key_incarnation_id=None, add_proxy_agent_extension=None):
key_incarnation_id=None, add_proxy_agent_extension=None, disk_iops_read_write=None,
disk_mbps_read_write=None):

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

vm_resource = build_vm_resource(
cmd=cmd, name=vm_name, location=location, tags=tags, size=size, storage_profile=storage_profile, nics=nics,
name=vm_name, location=location, tags=tags, size=size, storage_profile=storage_profile, nics=nics,
admin_username=admin_username, availability_set_id=availability_set, admin_password=admin_password,
ssh_key_values=ssh_key_value, ssh_key_path=ssh_dest_key_path, image_reference=image,
os_disk_name=os_disk_name, custom_image_os_type=os_type, authentication_type=authentication_type,
Expand Down Expand Up @@ -1185,7 +1186,8 @@ def create_vm(cmd, vm_name, resource_group_name, image=None, size='Standard_DS1_
imds_mode=imds_mode,
wire_server_access_control_profile_reference_id=wire_server_access_control_profile_reference_id,
imds_access_control_profile_reference_id=imds_access_control_profile_reference_id,
key_incarnation_id=key_incarnation_id, add_proxy_agent_extension=add_proxy_agent_extension)
key_incarnation_id=key_incarnation_id, add_proxy_agent_extension=add_proxy_agent_extension,
disk_iops_read_write=disk_iops_read_write, disk_mbps_read_write=disk_mbps_read_write)

vm_resource['dependsOn'] = vm_dependencies

Expand Down
Loading