Skip to content

Commit

Permalink
deploy premium SSDv2 disks and specify IOPS and throughput configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
rahalan committed Nov 12, 2024
1 parent 9bd6587 commit 0d752ea
Show file tree
Hide file tree
Showing 6 changed files with 441 additions and 8 deletions.
236 changes: 232 additions & 4 deletions avm/res/compute/virtual-machine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This module deploys a Virtual Machine with one or multiple NICs and optionally o
| `Microsoft.Authorization/locks` | [2020-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-05-01/locks) |
| `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) |
| `Microsoft.Automanage/configurationProfileAssignments` | [2022-05-04](https://learn.microsoft.com/en-us/azure/templates) |
| `Microsoft.Compute/disks` | [2024-03-02](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Compute/2024-03-02/disks) |
| `Microsoft.Compute/virtualMachines` | [2024-07-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Compute/2024-07-01/virtualMachines) |
| `Microsoft.Compute/virtualMachines/extensions` | [2022-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Compute/2022-11-01/virtualMachines/extensions) |
| `Microsoft.DevTestLab/schedules` | [2018-09-15](https://learn.microsoft.com/en-us/azure/templates/Microsoft.DevTestLab/2018-09-15/schedules) |
Expand Down Expand Up @@ -47,8 +48,9 @@ The following section provides usage examples for the module, which were used to
- [Using a host pool to register the VM](#example-7-using-a-host-pool-to-register-the-vm)
- [Using large parameter set for Windows](#example-8-using-large-parameter-set-for-windows)
- [Deploy a VM with nVidia graphic card](#example-9-deploy-a-vm-with-nvidia-graphic-card)
- [Using disk encryption set for the VM.](#example-10-using-disk-encryption-set-for-the-vm)
- [Adding the VM to a VMSS.](#example-11-adding-the-vm-to-a-vmss)
- [Deploying Windows VM with premium SSDv2 data disk](#example-10-deploying-windows-vm-with-premium-ssdv2-data-disk)
- [Using disk encryption set for the VM.](#example-11-using-disk-encryption-set-for-the-vm)
- [Adding the VM to a VMSS.](#example-12-adding-the-vm-to-a-vmss)

### Example 1: _Using automanage for the VM._

Expand Down Expand Up @@ -4152,7 +4154,209 @@ param location = '<location>'
</details>
<p>

### Example 10: _Using disk encryption set for the VM._
### Example 10: _Deploying Windows VM with premium SSDv2 data disk_

This instance deploys the module with premium SSDv2 data disk.


<details>

<summary>via Bicep module</summary>

```bicep
module virtualMachine 'br/public:avm/res/compute/virtual-machine:<version>' = {
name: 'virtualMachineDeployment'
params: {
// Required parameters
adminUsername: 'localAdminUser'
imageReference: {
offer: 'WindowsServer'
publisher: 'MicrosoftWindowsServer'
sku: '2022-datacenter-azure-edition'
version: 'latest'
}
name: 'cvmwinssdv2'
nicConfigurations: [
{
ipConfigurations: [
{
name: 'ipconfig01'
subnetResourceId: '<subnetResourceId>'
}
]
nicSuffix: '-nic-01'
}
]
osDisk: {
caching: 'ReadWrite'
diskSizeGB: 128
managedDisk: {
storageAccountType: 'Premium_LRS'
}
}
osType: 'Windows'
vmSize: 'Standard_D2s_v3'
zone: 1
// Non-required parameters
adminPassword: '<adminPassword>'
dataDisks: [
{
caching: 'None'
diskIOPSReadWrite: 3000
diskMBpsReadWrite: 125
diskSizeGB: 1024
managedDisk: {
storageAccountType: 'PremiumV2_LRS'
}
}
]
location: '<location>'
}
}
```

</details>
<p>

<details>

<summary>via JSON parameters file</summary>

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
// Required parameters
"adminUsername": {
"value": "localAdminUser"
},
"imageReference": {
"value": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2022-datacenter-azure-edition",
"version": "latest"
}
},
"name": {
"value": "cvmwinssdv2"
},
"nicConfigurations": {
"value": [
{
"ipConfigurations": [
{
"name": "ipconfig01",
"subnetResourceId": "<subnetResourceId>"
}
],
"nicSuffix": "-nic-01"
}
]
},
"osDisk": {
"value": {
"caching": "ReadWrite",
"diskSizeGB": 128,
"managedDisk": {
"storageAccountType": "Premium_LRS"
}
}
},
"osType": {
"value": "Windows"
},
"vmSize": {
"value": "Standard_D2s_v3"
},
"zone": {
"value": 1
},
// Non-required parameters
"adminPassword": {
"value": "<adminPassword>"
},
"dataDisks": {
"value": [
{
"caching": "None",
"diskIOPSReadWrite": 3000,
"diskMBpsReadWrite": 125,
"diskSizeGB": 1024,
"managedDisk": {
"storageAccountType": "PremiumV2_LRS"
}
}
]
},
"location": {
"value": "<location>"
}
}
}
```

</details>
<p>

<details>

<summary>via Bicep parameters file</summary>

```bicep-params
using 'br/public:avm/res/compute/virtual-machine:<version>'
// Required parameters
param adminUsername = 'localAdminUser'
param imageReference = {
offer: 'WindowsServer'
publisher: 'MicrosoftWindowsServer'
sku: '2022-datacenter-azure-edition'
version: 'latest'
}
param name = 'cvmwinssdv2'
param nicConfigurations = [
{
ipConfigurations: [
{
name: 'ipconfig01'
subnetResourceId: '<subnetResourceId>'
}
]
nicSuffix: '-nic-01'
}
]
param osDisk = {
caching: 'ReadWrite'
diskSizeGB: 128
managedDisk: {
storageAccountType: 'Premium_LRS'
}
}
param osType = 'Windows'
param vmSize = 'Standard_D2s_v3'
param zone = 1
// Non-required parameters
param adminPassword = '<adminPassword>'
param dataDisks = [
{
caching: 'None'
diskIOPSReadWrite: 3000
diskMBpsReadWrite: 125
diskSizeGB: 1024
managedDisk: {
storageAccountType: 'PremiumV2_LRS'
}
}
]
param location = '<location>'
```

</details>
<p>

### Example 11: _Using disk encryption set for the VM._

This instance deploys the module with disk enryption set.

Expand Down Expand Up @@ -4360,7 +4564,7 @@ param location = '<location>'
</details>
<p>

### Example 11: _Adding the VM to a VMSS._
### Example 12: _Adding the VM to a VMSS._

This instance deploys the module with the minimum set of required parameters and adds it to a VMSS.

Expand Down Expand Up @@ -4959,6 +5163,8 @@ Specifies the data disks. For security reasons, it is recommended to specify Dis
| [`caching`](#parameter-datadiskscaching) | string | Specifies the caching requirements. |
| [`createOption`](#parameter-datadiskscreateoption) | string | Specifies how the virtual machine should be created. |
| [`deleteOption`](#parameter-datadisksdeleteoption) | string | Specifies whether data disk should be deleted or detached upon VM deletion. |
| [`diskIOPSReadWrite`](#parameter-datadisksdiskiopsreadwrite) | int | The number of IOPS allowed for this disk; only settable for UltraSSD disks. One operation can transfer between 4k and 256k bytes. |
| [`diskMBpsReadWrite`](#parameter-datadisksdiskmbpsreadwrite) | int | The bandwidth allowed for this disk; only settable for UltraSSD disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. |
| [`lun`](#parameter-datadiskslun) | int | Specifies the logical unit number of the data disk. |
| [`name`](#parameter-datadisksname) | string | The disk name. |

Expand Down Expand Up @@ -4987,6 +5193,7 @@ The managed disk parameters.
| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`diskEncryptionSetResourceId`](#parameter-datadisksmanageddiskdiskencryptionsetresourceid) | string | Specifies the customer managed disk encryption set resource id for the managed disk. |
| [`id`](#parameter-datadisksmanageddiskid) | string | Specifies the customer managed disk id for the managed disk. |

### Parameter: `dataDisks.managedDisk.storageAccountType`

Expand Down Expand Up @@ -5014,6 +5221,13 @@ Specifies the customer managed disk encryption set resource id for the managed d
- Required: No
- Type: string

### Parameter: `dataDisks.managedDisk.id`

Specifies the customer managed disk id for the managed disk.

- Required: No
- Type: string

### Parameter: `dataDisks.caching`

Specifies the caching requirements.
Expand Down Expand Up @@ -5058,6 +5272,20 @@ Specifies whether data disk should be deleted or detached upon VM deletion.
]
```

### Parameter: `dataDisks.diskIOPSReadWrite`

The number of IOPS allowed for this disk; only settable for UltraSSD disks. One operation can transfer between 4k and 256k bytes.

- Required: No
- Type: int

### Parameter: `dataDisks.diskMBpsReadWrite`

The bandwidth allowed for this disk; only settable for UltraSSD disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10.

- Required: No
- Type: int

### Parameter: `dataDisks.lun`

Specifies the logical unit number of the data disk.
Expand Down
31 changes: 30 additions & 1 deletion avm/res/compute/virtual-machine/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,25 @@ module vm_nic 'modules/nic-configuration.bicep' = [
}
]

resource managedDataDisks 'Microsoft.Compute/disks@2024-03-02' = [
for (dataDisk, index) in dataDisks ?? []: {
location: location
name: dataDisk.?name ?? '${name}-disk-data-${padLeft((index + 1), 2, '0')}'
sku: {
name: dataDisk.managedDisk.storageAccountType
}
properties: {
diskSizeGB: dataDisk.diskSizeGB
creationData: {
createOption: dataDisk.?createoption ?? 'Empty'
}
diskIOPSReadWrite: dataDisk.?diskIOPSReadWrite
diskMBpsReadWrite: dataDisk.?diskMBpsReadWrite
}
zones: zone != 0 ? array(string(zone)) : null
}
]

resource vm 'Microsoft.Compute/virtualMachines@2024-07-01' = {
name: name
location: location
Expand Down Expand Up @@ -541,11 +560,12 @@ resource vm 'Microsoft.Compute/virtualMachines@2024-07-01' = {
lun: dataDisk.?lun ?? index
name: dataDisk.?name ?? '${name}-disk-data-${padLeft((index + 1), 2, '0')}'
diskSizeGB: dataDisk.diskSizeGB
createOption: dataDisk.?createoption ?? 'Empty'
createOption: (managedDataDisks[index].?id != null) ? 'Attach' : dataDisk.?createoption ?? 'Empty'
deleteOption: dataDisk.?deleteOption ?? 'Delete'
caching: dataDisk.?caching ?? 'ReadOnly'
managedDisk: {
storageAccountType: dataDisk.managedDisk.storageAccountType
id: managedDataDisks[index].?id
diskEncryptionSet: {
id: dataDisk.managedDisk.?diskEncryptionSetResourceId
}
Expand Down Expand Up @@ -1111,6 +1131,12 @@ type dataDisksType = {
@description('Optional. Specifies the caching requirements.')
caching: 'None' | 'ReadOnly' | 'ReadWrite'?

@description('Optional. The number of IOPS allowed for this disk; only settable for UltraSSD disks. One operation can transfer between 4k and 256k bytes.')
diskIOPSReadWrite: int?

@description('Optional. The bandwidth allowed for this disk; only settable for UltraSSD disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10.')
diskMBpsReadWrite: int?

@description('Required. The managed disk parameters.')
managedDisk: {
@description('Required. Specifies the storage account type for the managed disk.')
Expand All @@ -1125,5 +1151,8 @@ type dataDisksType = {

@description('Optional. Specifies the customer managed disk encryption set resource id for the managed disk.')
diskEncryptionSetResourceId: string?

@description('Optional. Specifies the customer managed disk id for the managed disk.')
id: string?
}
}[]?
Loading

0 comments on commit 0d752ea

Please sign in to comment.