Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update avm/res/compute/virtual-machine - Deploy vm's with ZRS data disk(s) #4420

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
197 changes: 197 additions & 0 deletions avm/res/compute/virtual-machine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The following section provides usage examples for the module, which were used to
- [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)
- [Deploying Windows VM in a defined zone with a premium zrs data disk](#example-13-deploying-windows-vm-in-a-defined-zone-with-a-premium-zrs-data-disk)

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

Expand Down Expand Up @@ -4736,6 +4737,202 @@ param virtualMachineScaleSetResourceId = '<virtualMachineScaleSetResourceId>'
</details>
<p>

### Example 13: _Deploying Windows VM in a defined zone with a premium zrs data disk_

This instance deploys the module with a premium zrs 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: 'cvmwinzrs'
nicConfigurations: [
{
ipConfigurations: [
{
name: 'ipconfig01'
subnetResourceId: '<subnetResourceId>'
}
]
nicSuffix: '-nic-01'
}
]
osDisk: {
caching: 'ReadWrite'
diskSizeGB: 128
managedDisk: {
storageAccountType: 'Premium_ZRS'
}
}
osType: 'Windows'
vmSize: 'Standard_D2s_v3'
zone: 2
// Non-required parameters
adminPassword: '<adminPassword>'
dataDisks: [
{
caching: 'None'
diskSizeGB: 1024
managedDisk: {
storageAccountType: 'Premium_ZRS'
}
}
]
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": "cvmwinzrs"
},
"nicConfigurations": {
"value": [
{
"ipConfigurations": [
{
"name": "ipconfig01",
"subnetResourceId": "<subnetResourceId>"
}
],
"nicSuffix": "-nic-01"
}
]
},
"osDisk": {
"value": {
"caching": "ReadWrite",
"diskSizeGB": 128,
"managedDisk": {
"storageAccountType": "Premium_ZRS"
}
}
},
"osType": {
"value": "Windows"
},
"vmSize": {
"value": "Standard_D2s_v3"
},
"zone": {
"value": 2
},
// Non-required parameters
"adminPassword": {
"value": "<adminPassword>"
},
"dataDisks": {
"value": [
{
"caching": "None",
"diskSizeGB": 1024,
"managedDisk": {
"storageAccountType": "Premium_ZRS"
}
}
]
},
"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 = 'cvmwinzrs'
param nicConfigurations = [
{
ipConfigurations: [
{
name: 'ipconfig01'
subnetResourceId: '<subnetResourceId>'
}
]
nicSuffix: '-nic-01'
}
]
param osDisk = {
caching: 'ReadWrite'
diskSizeGB: 128
managedDisk: {
storageAccountType: 'Premium_ZRS'
}
}
param osType = 'Windows'
param vmSize = 'Standard_D2s_v3'
param zone = 2
// Non-required parameters
param adminPassword = '<adminPassword>'
param dataDisks = [
{
caching: 'None'
diskSizeGB: 1024
managedDisk: {
storageAccountType: 'Premium_ZRS'
}
}
]
param location = '<location>'
```

</details>
<p>

## Parameters

**Required parameters**
Expand Down
2 changes: 1 addition & 1 deletion avm/res/compute/virtual-machine/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ resource managedDataDisks 'Microsoft.Compute/disks@2024-03-02' = [
diskIOPSReadWrite: dataDisk.?diskIOPSReadWrite
diskMBpsReadWrite: dataDisk.?diskMBpsReadWrite
}
zones: zone != 0 ? array(string(zone)) : null
zones: zone != 0 && !contains(dataDisk.managedDisk.storageAccountType, 'ZRS') ? array(string(zone)) : null
}
]

Expand Down
62 changes: 31 additions & 31 deletions avm/res/compute/virtual-machine/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "11202694269777473963"
"version": "0.33.93.31351",
"templateHash": "17400759374906943003"
},
"name": "Virtual Machines",
"description": "This module deploys a Virtual Machine with one or multiple NICs and optionally one or multiple public IPs."
Expand Down Expand Up @@ -1018,7 +1018,7 @@
"diskIOPSReadWrite": "[tryGet(coalesce(parameters('dataDisks'), createArray())[copyIndex()], 'diskIOPSReadWrite')]",
"diskMBpsReadWrite": "[tryGet(coalesce(parameters('dataDisks'), createArray())[copyIndex()], 'diskMBpsReadWrite')]"
},
"zones": "[if(not(equals(parameters('zone'), 0)), array(string(parameters('zone'))), null())]"
"zones": "[if(and(not(equals(parameters('zone'), 0)), not(contains(coalesce(parameters('dataDisks'), createArray())[copyIndex()].managedDisk.storageAccountType, 'ZRS'))), array(string(parameters('zone'))), null())]"
},
"vm": {
"type": "Microsoft.Compute/virtualMachines",
Expand Down Expand Up @@ -1301,8 +1301,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "9361328819285350634"
"version": "0.33.93.31351",
"templateHash": "17423406578946107257"
}
},
"definitions": {
Expand Down Expand Up @@ -2905,8 +2905,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "10459557628823249787"
"version": "0.33.93.31351",
"templateHash": "2171772621334669730"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension."
Expand Down Expand Up @@ -3116,8 +3116,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "10459557628823249787"
"version": "0.33.93.31351",
"templateHash": "2171772621334669730"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension."
Expand Down Expand Up @@ -3323,8 +3323,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "10459557628823249787"
"version": "0.33.93.31351",
"templateHash": "2171772621334669730"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension."
Expand Down Expand Up @@ -3525,8 +3525,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "10459557628823249787"
"version": "0.33.93.31351",
"templateHash": "2171772621334669730"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension."
Expand Down Expand Up @@ -3732,8 +3732,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "10459557628823249787"
"version": "0.33.93.31351",
"templateHash": "2171772621334669730"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension."
Expand Down Expand Up @@ -3934,8 +3934,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "10459557628823249787"
"version": "0.33.93.31351",
"templateHash": "2171772621334669730"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension."
Expand Down Expand Up @@ -4144,8 +4144,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "10459557628823249787"
"version": "0.33.93.31351",
"templateHash": "2171772621334669730"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension."
Expand Down Expand Up @@ -4358,8 +4358,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "10459557628823249787"
"version": "0.33.93.31351",
"templateHash": "2171772621334669730"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension."
Expand Down Expand Up @@ -4566,8 +4566,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "10459557628823249787"
"version": "0.33.93.31351",
"templateHash": "2171772621334669730"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension."
Expand Down Expand Up @@ -4770,8 +4770,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "10459557628823249787"
"version": "0.33.93.31351",
"templateHash": "2171772621334669730"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension."
Expand Down Expand Up @@ -4983,8 +4983,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "10459557628823249787"
"version": "0.33.93.31351",
"templateHash": "2171772621334669730"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension."
Expand Down Expand Up @@ -5192,8 +5192,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "10459557628823249787"
"version": "0.33.93.31351",
"templateHash": "2171772621334669730"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension."
Expand Down Expand Up @@ -5387,8 +5387,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.33.13.18514",
"templateHash": "16309659094506585930"
"version": "0.33.93.31351",
"templateHash": "5910828956272534599"
},
"name": "Recovery Service Vaults Protection Container Protected Item",
"description": "This module deploys a Recovery Services Vault Protection Container Protected Item."
Expand Down
Loading