Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -703,5 +703,12 @@ public void TestVirtualMachineGalleryApplicationFlags()
{
TestRunner.RunTestScript("Test-VirtualMachineGalleryApplicationFlags");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVMDataDiskIOPSMBPS()
{
TestRunner.RunTestScript("Test-VMDataDiskIOPSMBPS");
}
}
}
68 changes: 67 additions & 1 deletion src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8115,4 +8115,70 @@ function Test-VirtualMachineGalleryApplicationFlags
finally {
Clean-ResourceGroup $resourceGroupName
}
}
}
<#
.SYNOPSIS
Test Virtual Machine Data Disk with IOPS and MBPS parameters
#>
function Test-VMDataDiskIOPSMBPS
{
# Setup
$rgname = Get-ComputeTestResourceName

try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzResourceGroup -Name $rgname -Location $loc -Force;

# VM Profile & Hardware
$vmsize = 'Standard_D4s_v3';
$vmname = 'vm' + $rgname;
$p = New-AzVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;

# Test adding data disk with DiskIOPSReadWrite and DiskMBpsReadWrite parameters
$diskName = 'testdisk1';
$diskLun = 0;
$diskSize = 10;
$diskIOPS = 5000;
$diskMBPS = 200;

# Add data disk with IOPS and MBPS for managed disk (implicit creation scenario)
$p = Add-AzVMDataDisk -VM $p -Name $diskName -Lun $diskLun -CreateOption Empty `
-DiskSizeInGB $diskSize -StorageAccountType UltraSSD_LRS -Caching None `
-DiskIOPSReadWrite $diskIOPS -DiskMBpsReadWrite $diskMBPS;

# Verify the disk was added with correct properties
Assert-AreEqual $p.StorageProfile.DataDisks.Count 1;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Name $diskName;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Lun $diskLun;
Assert-AreEqual $p.StorageProfile.DataDisks[0].DiskSizeGB $diskSize;
Assert-AreEqual $p.StorageProfile.DataDisks[0].CreateOption 'Empty';
Assert-AreEqual $p.StorageProfile.DataDisks[0].DiskIOPSReadWrite $diskIOPS;
Assert-AreEqual $p.StorageProfile.DataDisks[0].DiskMBpsReadWrite $diskMBPS;
Assert-AreEqual $p.StorageProfile.DataDisks[0].ManagedDisk.StorageAccountType 'UltraSSD_LRS';

# Test adding another data disk without IOPS/MBPS parameters
$diskName2 = 'testdisk2';
$diskLun2 = 1;
$diskSize2 = 20;

$p = Add-AzVMDataDisk -VM $p -Name $diskName2 -Lun $diskLun2 -CreateOption Empty `
-DiskSizeInGB $diskSize2 -StorageAccountType Premium_LRS -Caching ReadOnly;

# Verify the second disk was added without IOPS/MBPS
Assert-AreEqual $p.StorageProfile.DataDisks.Count 2;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Name $diskName2;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Lun $diskLun2;
Assert-AreEqual $p.StorageProfile.DataDisks[1].DiskSizeGB $diskSize2;
Assert-AreEqual $p.StorageProfile.DataDisks[1].ManagedDisk.StorageAccountType 'Premium_LRS';
Assert-Null $p.StorageProfile.DataDisks[1].DiskIOPSReadWrite;
Assert-Null $p.StorageProfile.DataDisks[1].DiskMBpsReadWrite;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
4 changes: 4 additions & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

-->
## Upcoming Release
* Added support for Disk IOPS and MBPS parameters in `Add-AzVMDataDisk` cmdlet
- Added `-DiskIOPSReadWrite` parameter to specify Read-Write IOPS for UltraSSD_LRS or PremiumV2_LRS data disks
- Added `-DiskMBpsReadWrite` parameter to specify bandwidth in MB per second for UltraSSD_LRS or PremiumV2_LRS data disks
- These parameters allow setting IOPS and MBPS values during implicit disk creation for Single Instance (SI) Virtual Machines
* Compute SDK generation updates:
- Generation now uses autorest.powershell, replacing deprecated track 1 SDK.
- Removed local swagger files and replaced references with remote swagger files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public class AddAzureVMDataDiskCommand : ComputeClientBaseCmdlet
ValueFromPipelineByPropertyName = true,
HelpMessage = HelpMessages.VMManagedDiskAccountType)]
[ValidateNotNullOrEmpty]
[PSArgumentCompleter("Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS")]
[PSArgumentCompleter("Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "PremiumV2_LRS")]
public string StorageAccountType { get; set; }

[Parameter(
Expand All @@ -152,6 +152,20 @@ public class AddAzureVMDataDiskCommand : ComputeClientBaseCmdlet
[ValidateNotNullOrEmpty]
public string SourceResourceId { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
ParameterSetName = VmManagedDiskParameterSet,
HelpMessage = "Specifies the Read-Write IOPS for the managed disk when StorageAccountType is UltraSSD_LRS or PremiumV2_LRS.")]
public long? DiskIOPSReadWrite { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
ParameterSetName = VmManagedDiskParameterSet,
HelpMessage = "Specifies the bandwidth in MB per second for the managed disk when StorageAccountType is UltraSSD_LRS or PremiumV2_LRS.")]
public long? DiskMBpsReadWrite { get; set; }

public override void ExecuteCmdlet()
{
if (this.ParameterSetName.Equals(VmNormalDiskParameterSet))
Expand Down Expand Up @@ -229,7 +243,9 @@ public override void ExecuteCmdlet()
SourceResource = string.IsNullOrEmpty(this.SourceResourceId) ? null : new ApiEntityReference
{
Id = this.SourceResourceId
}
},
DiskIOPSReadWrite = this.DiskIOPSReadWrite,
DiskMBpsReadWrite = this.DiskMBpsReadWrite
});

this.VM.StorageProfile = storageProfile;
Expand Down
47 changes: 45 additions & 2 deletions src/Compute/Compute/help/Add-AzVMDataDisk.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Add-AzVMDataDisk [-VM] <PSVirtualMachine> [[-Name] <String>] [[-VhdUri] <String>
Add-AzVMDataDisk [-VM] <PSVirtualMachine> [[-Name] <String>] [[-Caching] <CachingTypes>]
[[-DiskSizeInGB] <Int32>] [-Lun] <Int32> [-CreateOption] <String> [[-ManagedDiskId] <String>]
[[-StorageAccountType] <String>] [-DiskEncryptionSetId <String>] [-WriteAccelerator] [-DeleteOption <String>]
[-SourceResourceId <String>] [-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
[-SourceResourceId <String>] [-DiskIOPSReadWrite <Int64>] [-DiskMBpsReadWrite <Int64>]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -96,6 +96,17 @@ This approach is used to improve the readability of the following commands.
The final command add a data disk to the virtual machine stored in $VirtualMachine.
The command specifies the name and location for the disk, and other properties of the disk.

### Example 5: Add an UltraSSD data disk with custom IOPS and throughput
```powershell
$VirtualMachine = New-AzVMConfig -VMName "VirtualMachine07" -VMSize "Standard_D4s_v3"
$VirtualMachine = Add-AzVMDataDisk -VM $VirtualMachine -Name 'UltraData1' -Lun 0 -CreateOption Empty -DiskSizeInGB 10 -Caching None -StorageAccountType UltraSSD_LRS -DiskIOPSReadWrite 5000 -DiskMBpsReadWrite 200
```

The first command creates a virtual machine object and stores it in the $VirtualMachine variable.
The command assigns a name and size to the virtual machine.
The second command adds an UltraSSD data disk with custom IOPS (Input/Output Operations Per Second) set to 5000 and throughput set to 200 MB per second.
These parameters allow fine-tuning of disk performance for UltraSSD_LRS and PremiumV2_LRS storage account types during implicit disk creation.

## PARAMETERS

### -Caching
Expand Down Expand Up @@ -350,6 +361,38 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -DiskIOPSReadWrite
Specifies the Read-Write IOPS (Input/Output Operations Per Second) for the managed disk when StorageAccountType is UltraSSD_LRS or PremiumV2_LRS.
This parameter is used during implicit disk creation to set custom IOPS values for high-performance disks.

```yaml
Type: System.Nullable`1[System.Int64]
Parameter Sets: VmManagedDiskParameterSetName
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -DiskMBpsReadWrite
Specifies the bandwidth in MB per second for the managed disk when StorageAccountType is UltraSSD_LRS or PremiumV2_LRS.
This parameter is used during implicit disk creation to set custom throughput values for high-performance disks.

```yaml
Type: System.Nullable`1[System.Int64]
Parameter Sets: VmManagedDiskParameterSetName
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

Expand Down
Loading