Skip to content

Commit

Permalink
add userdata property
Browse files Browse the repository at this point in the history
  • Loading branch information
rahalan committed Nov 8, 2024
1 parent d5bc11b commit 4be4763
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 31 deletions.
9 changes: 9 additions & 0 deletions avm/res/compute/virtual-machine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4613,6 +4613,7 @@ param virtualMachineScaleSetResourceId = '<virtualMachineScaleSetResourceId>'
| [`tags`](#parameter-tags) | object | Tags of the resource. |
| [`timeZone`](#parameter-timezone) | string | Specifies the time zone of the virtual machine. e.g. 'Pacific Standard Time'. Possible values can be `TimeZoneInfo.id` value from time zones returned by `TimeZoneInfo.GetSystemTimeZones`. |
| [`ultraSSDEnabled`](#parameter-ultrassdenabled) | bool | The flag that enables or disables a capability to have one or more managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale set only if this property is enabled. |
| [`userData`](#parameter-userdata) | string | UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here. |
| [`virtualMachineScaleSetResourceId`](#parameter-virtualmachinescalesetresourceid) | string | Resource ID of a virtual machine scale set, where the VM should be added. |
| [`vTpmEnabled`](#parameter-vtpmenabled) | bool | Specifies whether vTPM should be enabled on the virtual machine. This parameter is part of the UefiSettings. SecurityType should be set to TrustedLaunch to enable UefiSettings. |
| [`winRM`](#parameter-winrm) | array | Specifies the Windows Remote Management listeners. This enables remote Windows PowerShell. - WinRMConfiguration object. |
Expand Down Expand Up @@ -5695,6 +5696,14 @@ The flag that enables or disables a capability to have one or more managed data
- Type: bool
- Default: `False`

### Parameter: `userData`

UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here.

- Required: No
- Type: string
- Default: `''`

### Parameter: `virtualMachineScaleSetResourceId`

Resource ID of a virtual machine scale set, where the VM should be added.
Expand Down
4 changes: 4 additions & 0 deletions avm/res/compute/virtual-machine/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ param adminUsername string
@secure()
param adminPassword string = ''

@description('Optional. UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here.')
param userData string = ''

@description('Optional. Custom data associated to the VM, this value will be automatically converted into base64 to account for the expected VM format.')
param customData string = ''

Expand Down Expand Up @@ -620,6 +623,7 @@ resource vm 'Microsoft.Compute/virtualMachines@2024-07-01' = {
}
: null
licenseType: !empty(licenseType) ? licenseType : null
userData: !empty(userData) ? base64(userData) : null
}
dependsOn: [
vm_nic
Expand Down
70 changes: 39 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.30.3.12046",
"templateHash": "1443306495474212036"
"version": "0.30.23.60470",
"templateHash": "4176414002212875016"
},
"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 @@ -412,6 +412,13 @@
"description": "Optional. When specifying a Windows Virtual Machine, this value should be passed."
}
},
"userData": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Optional. UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here."
}
},
"customData": {
"type": "string",
"defaultValue": "",
Expand Down Expand Up @@ -1069,7 +1076,8 @@
"evictionPolicy": "[if(parameters('enableEvictionPolicy'), 'Deallocate', null())]",
"billingProfile": "[if(and(not(empty(parameters('priority'))), not(empty(parameters('maxPriceForLowPriorityVm')))), createObject('maxPrice', json(parameters('maxPriceForLowPriorityVm'))), null())]",
"host": "[if(not(empty(parameters('dedicatedHostId'))), createObject('id', parameters('dedicatedHostId')), null())]",
"licenseType": "[if(not(empty(parameters('licenseType'))), parameters('licenseType'), null())]"
"licenseType": "[if(not(empty(parameters('licenseType'))), parameters('licenseType'), null())]",
"userData": "[if(not(empty(parameters('userData'))), base64(parameters('userData')), null())]"
},
"dependsOn": [
"vm_nic"
Expand Down Expand Up @@ -1251,8 +1259,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "191716886366421622"
"version": "0.30.23.60470",
"templateHash": "12465121820739149822"
}
},
"definitions": {
Expand Down Expand Up @@ -2855,8 +2863,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.30.23.60470",
"templateHash": "16065702394900050638"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -3070,8 +3078,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.30.23.60470",
"templateHash": "16065702394900050638"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -3281,8 +3289,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.30.23.60470",
"templateHash": "16065702394900050638"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -3487,8 +3495,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.30.23.60470",
"templateHash": "16065702394900050638"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -3698,8 +3706,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.30.23.60470",
"templateHash": "16065702394900050638"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -3904,8 +3912,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.30.23.60470",
"templateHash": "16065702394900050638"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -4118,8 +4126,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.30.23.60470",
"templateHash": "16065702394900050638"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -4336,8 +4344,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.30.23.60470",
"templateHash": "16065702394900050638"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -4548,8 +4556,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.30.23.60470",
"templateHash": "16065702394900050638"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -4756,8 +4764,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.30.23.60470",
"templateHash": "16065702394900050638"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -4973,8 +4981,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.30.23.60470",
"templateHash": "16065702394900050638"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -5186,8 +5194,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.30.23.60470",
"templateHash": "16065702394900050638"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -5385,8 +5393,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "18427642917647797213"
"version": "0.30.23.60470",
"templateHash": "12193073774274736616"
},
"name": "Recovery Service Vaults Protection Container Protected Item",
"description": "This module deploys a Recovery Services Vault Protection Container Protected Item.",
Expand Down

0 comments on commit 4be4763

Please sign in to comment.