From 20bb205ce0957126f66a2673606d5b3273e32190 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Dec 2025 16:56:30 +0000 Subject: [PATCH 1/2] Initial plan From fd4349a48935094ff0040ea01c75c9055bb3d957 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Dec 2025 17:12:57 +0000 Subject: [PATCH 2/2] Add DiskIOPSReadWrite and DiskMBpsReadWrite parameters to Add-AzVMDataDisk cmdlet Co-authored-by: haagha <64601174+haagha@users.noreply.github.com> --- .../Customizations/DataDisk.cs | 28 +++++++++++ .../VirtualMachineProfileTests.cs | 7 +++ .../VirtualMachineProfileTests.ps1 | 50 +++++++++++++++++++ src/Compute/Compute/ChangeLog.md | 1 + .../Config/AddAzureVMDataDiskCommand.cs | 21 +++++++- src/Compute/Compute/help/Add-AzVMDataDisk.md | 45 ++++++++++++++++- 6 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 src/Compute/Compute.Management.Sdk/Customizations/DataDisk.cs diff --git a/src/Compute/Compute.Management.Sdk/Customizations/DataDisk.cs b/src/Compute/Compute.Management.Sdk/Customizations/DataDisk.cs new file mode 100644 index 000000000000..c9eb221a3108 --- /dev/null +++ b/src/Compute/Compute.Management.Sdk/Customizations/DataDisk.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +namespace Microsoft.Azure.Management.Compute.Models +{ + using Newtonsoft.Json; + + /// + /// Describes a data disk. + /// + public partial class DataDisk + { + /// + /// Gets or sets specifies the Read-Write IOPS for the managed disk when + /// StorageAccountType is UltraSSD_LRS or PremiumV2_LRS. + /// + [JsonProperty(PropertyName = "diskIOPSReadWrite")] + public new long? DiskIOPSReadWrite { get; set; } + + /// + /// Gets or sets specifies the bandwidth in MB per second for the managed disk + /// when StorageAccountType is UltraSSD_LRS or PremiumV2_LRS. + /// + [JsonProperty(PropertyName = "diskMBpsReadWrite")] + public new long? DiskMBpsReadWrite { get; set; } + } +} diff --git a/src/Compute/Compute.Test/ScenarioTests/VirtualMachineProfileTests.cs b/src/Compute/Compute.Test/ScenarioTests/VirtualMachineProfileTests.cs index ce6c8579f23d..f4ec26ef98f9 100644 --- a/src/Compute/Compute.Test/ScenarioTests/VirtualMachineProfileTests.cs +++ b/src/Compute/Compute.Test/ScenarioTests/VirtualMachineProfileTests.cs @@ -37,5 +37,12 @@ public void TestVirtualMachineProfileWithoutAUC() { TestRunner.RunTestScript("Test-VirtualMachineProfileWithoutAUC"); } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void TestVirtualMachineDataDiskIOPSMBPS() + { + TestRunner.RunTestScript("Test-VirtualMachineDataDiskIOPSMBPS"); + } } } diff --git a/src/Compute/Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1 b/src/Compute/Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1 index 73718922ab47..45b620b2c0a3 100644 --- a/src/Compute/Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1 +++ b/src/Compute/Compute.Test/ScenarioTests/VirtualMachineProfileTests.ps1 @@ -446,3 +446,53 @@ function Test-VirtualMachineProfileWithoutAUC Assert-False {$p.OSProfile.WindowsConfiguration.ProvisionVMAgent}; } + +<# +.SYNOPSIS +Test Virtual Machine Data Disk with IOPS and MBPS parameters +#> +function Test-VirtualMachineDataDiskIOPSMBPS +{ + Get-AzVmss -ResourceGroupName "fakeresource" -VMScaleSetName "fakevmss" -ErrorAction SilentlyContinue + + # VM Profile & Hardware + $vmsize = 'Standard_D2s_v3'; + $vmname = 'pstestvm' + ((Get-Random) % 10000); + $p = New-AzVMConfig -VMName $vmname -VMSize $vmsize -EnableUltraSSD; + Assert-AreEqual $p.HardwareProfile.VmSize $vmsize; + Assert-True { $p.AdditionalCapabilities.UltraSSDEnabled }; + + # Add managed data disk with DiskIOPSReadWrite and DiskMBpsReadWrite + $managedDataDiskId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rggroup/providers/Microsoft.Compute/disks/testUltraDataDisk"; + $diskIOPS = 1000; + $diskMBps = 100; + + $p = Add-AzVMDataDisk -VM $p -Name 'testUltraDataDisk' -Caching 'None' -DiskSizeInGB 10 -Lun 0 -CreateOption Empty ` + -ManagedDiskId $managedDataDiskId -StorageAccountType UltraSSD_LRS ` + -DiskIOPSReadWrite $diskIOPS -DiskMBpsReadWrite $diskMBps; + + Assert-AreEqual $managedDataDiskId $p.StorageProfile.DataDisks[0].ManagedDisk.Id; + Assert-AreEqual "UltraSSD_LRS" $p.StorageProfile.DataDisks[0].ManagedDisk.StorageAccountType; + Assert-AreEqual $diskIOPS $p.StorageProfile.DataDisks[0].DiskIOPSReadWrite; + Assert-AreEqual $diskMBps $p.StorageProfile.DataDisks[0].DiskMBpsReadWrite; + Assert-AreEqual 0 $p.StorageProfile.DataDisks[0].Lun; + Assert-AreEqual 10 $p.StorageProfile.DataDisks[0].DiskSizeGB; + Assert-AreEqual 'None' $p.StorageProfile.DataDisks[0].Caching; + Assert-AreEqual 'Empty' $p.StorageProfile.DataDisks[0].CreateOption; + + # Add another disk without IOPS/MBPS (should be null) + $managedDataDiskId2 = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rggroup/providers/Microsoft.Compute/disks/testDataDisk2"; + $p = Add-AzVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 20 -Lun 1 -CreateOption Empty ` + -ManagedDiskId $managedDataDiskId2 -StorageAccountType Premium_LRS; + + Assert-AreEqual $managedDataDiskId2 $p.StorageProfile.DataDisks[1].ManagedDisk.Id; + Assert-AreEqual "Premium_LRS" $p.StorageProfile.DataDisks[1].ManagedDisk.StorageAccountType; + Assert-Null $p.StorageProfile.DataDisks[1].DiskIOPSReadWrite; + Assert-Null $p.StorageProfile.DataDisks[1].DiskMBpsReadWrite; + Assert-AreEqual 1 $p.StorageProfile.DataDisks[1].Lun; + Assert-AreEqual 20 $p.StorageProfile.DataDisks[1].DiskSizeGB; + Assert-AreEqual 'ReadOnly' $p.StorageProfile.DataDisks[1].Caching; + + # Verify disk count + Assert-AreEqual 2 $p.StorageProfile.DataDisks.Count; +} diff --git a/src/Compute/Compute/ChangeLog.md b/src/Compute/Compute/ChangeLog.md index 3b20e3949f01..c51b71afd5c3 100644 --- a/src/Compute/Compute/ChangeLog.md +++ b/src/Compute/Compute/ChangeLog.md @@ -24,6 +24,7 @@ * Updated Azure.Core from 1.45.0 to 1.47.3 * Added `-EnableAutomaticUpgrade` and `-TreatFailureAsDeploymentFailure` parameters (Bool) to `New-AzVmGalleryApplication` and `New-AzVmssGalleryApplication` cmdlets. * Added `-EnableAutomaticUpgrade` and `-TreatFailureAsDeploymentFailure` parameters (Switch) to `Add-AzVmGalleryApplication` and `Add-AzVmssGalleryApplication` cmdlets. +* Added `-DiskIOPSReadWrite` and `-DiskMBpsReadWrite` parameters to `Add-AzVMDataDisk` cmdlet for setting IOPS and bandwidth during implicit disk creation of UltraSSD or Premium V2 data disks. ## Version 10.5.0 * Added `-Redeploy` switch parameter for `Update-AzHost` cmdlet to enable dedicated host redeployment. diff --git a/src/Compute/Compute/VirtualMachine/Config/AddAzureVMDataDiskCommand.cs b/src/Compute/Compute/VirtualMachine/Config/AddAzureVMDataDiskCommand.cs index 9b044bc9a449..6db512796093 100644 --- a/src/Compute/Compute/VirtualMachine/Config/AddAzureVMDataDiskCommand.cs +++ b/src/Compute/Compute/VirtualMachine/Config/AddAzureVMDataDiskCommand.cs @@ -20,6 +20,7 @@ using CM = Microsoft.Azure.Commands.Compute.Models; using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; using Microsoft.Azure.Management.Compute.Models; +using Microsoft.WindowsAzure.Commands.Utilities.Common; namespace Microsoft.Azure.Commands.Compute { @@ -125,7 +126,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( @@ -152,6 +153,20 @@ public class AddAzureVMDataDiskCommand : ComputeClientBaseCmdlet [ValidateNotNullOrEmpty] public string SourceResourceId { get; set; } + [Parameter( + ParameterSetName = VmManagedDiskParameterSet, + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Specifies the Read-Write IOPS for the managed disk. Should be used only when StorageAccountType is UltraSSD_LRS or PremiumV2_LRS. If not specified, a default value would be assigned based on diskSizeGB.")] + public long DiskIOPSReadWrite { get; set; } + + [Parameter( + ParameterSetName = VmManagedDiskParameterSet, + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Specifies the bandwidth in MB per second for the managed disk. Should be used only when StorageAccountType is UltraSSD_LRS or PremiumV2_LRS. If not specified, a default value would be assigned based on diskSizeGB.")] + public long DiskMBpsReadWrite { get; set; } + public override void ExecuteCmdlet() { if (this.ParameterSetName.Equals(VmNormalDiskParameterSet)) @@ -229,7 +244,9 @@ public override void ExecuteCmdlet() SourceResource = string.IsNullOrEmpty(this.SourceResourceId) ? null : new ApiEntityReference { Id = this.SourceResourceId - } + }, + DiskIOPSReadWrite = this.IsParameterBound(c => c.DiskIOPSReadWrite) ? this.DiskIOPSReadWrite : (long?)null, + DiskMBpsReadWrite = this.IsParameterBound(c => c.DiskMBpsReadWrite) ? this.DiskMBpsReadWrite : (long?)null }); this.VM.StorageProfile = storageProfile; diff --git a/src/Compute/Compute/help/Add-AzVMDataDisk.md b/src/Compute/Compute/help/Add-AzVMDataDisk.md index c89b7e9c17d8..7b153454417d 100644 --- a/src/Compute/Compute/help/Add-AzVMDataDisk.md +++ b/src/Compute/Compute/help/Add-AzVMDataDisk.md @@ -26,7 +26,8 @@ Add-AzVMDataDisk [-VM] [[-Name] ] [[-VhdUri] Add-AzVMDataDisk [-VM] [[-Name] ] [[-Caching] ] [[-DiskSizeInGB] ] [-Lun] [-CreateOption] [[-ManagedDiskId] ] [[-StorageAccountType] ] [-DiskEncryptionSetId ] [-WriteAccelerator] [-DeleteOption ] - [-SourceResourceId ] [-DefaultProfile ] + [-SourceResourceId ] [-DiskIOPSReadWrite ] [-DiskMBpsReadWrite ] + [-DefaultProfile ] [] ``` @@ -96,6 +97,16 @@ 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 specified IOPS and throughput +```powershell +$VirtualMachine = New-AzVMConfig -VMName "VirtualMachine07" -VMSize "Standard_D2s_v3" -EnableUltraSSD +$VirtualMachine = Add-AzVMDataDisk -VM $VirtualMachine -Name 'UltraDataDisk1' -Lun 0 -CreateOption Empty -DiskSizeInGB 10 -Caching None -StorageAccountType UltraSSD_LRS -DiskIOPSReadWrite 1000 -DiskMBpsReadWrite 100 +``` + +The first command creates a virtual machine object with UltraSSD enabled and stores it in the $VirtualMachine variable. +The second command adds an UltraSSD data disk to the virtual machine with specified IOPS (1000) and throughput (100 MB/s) values. +These parameters allow you to set custom performance characteristics for UltraSSD or Premium V2 data disks during implicit disk creation. + ## PARAMETERS ### -Caching @@ -196,6 +207,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -DiskIOPSReadWrite +Specifies the Read-Write IOPS for the managed disk. Should be used only when StorageAccountType is UltraSSD_LRS or PremiumV2_LRS. If not specified, a default value would be assigned based on diskSizeGB. + +```yaml +Type: 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. Should be used only when StorageAccountType is UltraSSD_LRS or PremiumV2_LRS. If not specified, a default value would be assigned based on diskSizeGB. + +```yaml +Type: System.Int64 +Parameter Sets: VmManagedDiskParameterSetName +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + ### -DiskSizeInGB Specifies the size, in gigabytes, of an empty disk to attach to a virtual machine. @@ -363,6 +404,8 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### System.Nullable`1[[System.Int32, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] +### System.Int64 + ## OUTPUTS ### Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine