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
28 changes: 28 additions & 0 deletions src/Compute/Compute.Management.Sdk/Customizations/DataDisk.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// Describes a data disk.
/// </summary>
public partial class DataDisk
{
/// <summary>
/// Gets or sets specifies the Read-Write IOPS for the managed disk when
/// StorageAccountType is UltraSSD_LRS or PremiumV2_LRS.
/// </summary>
[JsonProperty(PropertyName = "diskIOPSReadWrite")]
public new long? DiskIOPSReadWrite { get; set; }

/// <summary>
/// Gets or sets specifies the bandwidth in MB per second for the managed disk
/// when StorageAccountType is UltraSSD_LRS or PremiumV2_LRS.
/// </summary>
[JsonProperty(PropertyName = "diskMBpsReadWrite")]
public new long? DiskMBpsReadWrite { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,12 @@ public void TestVirtualMachineProfileWithoutAUC()
{
TestRunner.RunTestScript("Test-VirtualMachineProfileWithoutAUC");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineDataDiskIOPSMBPS()
{
TestRunner.RunTestScript("Test-VirtualMachineDataDiskIOPSMBPS");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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(
Expand All @@ -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))
Expand Down Expand Up @@ -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;
Expand Down
45 changes: 44 additions & 1 deletion src/Compute/Compute/help/Add-AzVMDataDisk.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +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>]
[-SourceResourceId <String>] [-DiskIOPSReadWrite <Int64>] [-DiskMBpsReadWrite <Int64>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
```

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down