Skip to content

Commit

Permalink
Merge branch 'Azure:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
rahalan authored May 7, 2024
2 parents d7f5f56 + e3505a6 commit 8bfabfd
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 31 deletions.
136 changes: 136 additions & 0 deletions avm/res/compute/virtual-machine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ The following section provides usage examples for the module, which were used to
- [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)

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

Expand Down Expand Up @@ -2947,6 +2948,132 @@ module virtualMachine 'br/public:avm/res/compute/virtual-machine:<version>' = {
</details>
<p>

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

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


<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: 'cvmwinvmss'
nicConfigurations: [
{
ipConfigurations: [
{
name: 'ipconfig01'
subnetResourceId: '<subnetResourceId>'
}
]
nicSuffix: '-nic-01'
}
]
osDisk: {
caching: 'ReadWrite'
diskSizeGB: 128
managedDisk: {
storageAccountType: 'Premium_LRS'
}
}
osType: 'Windows'
vmSize: 'Standard_DS2_v2'
zone: 0
// Non-required parameters
adminPassword: '<adminPassword>'
location: '<location>'
virtualMachineScaleSetResourceId: '<virtualMachineScaleSetResourceId>'
}
}
```

</details>
<p>

<details>

<summary>via JSON Parameter 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": "cvmwinvmss"
},
"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_DS2_v2"
},
"zone": {
"value": 0
},
// Non-required parameters
"adminPassword": {
"value": "<adminPassword>"
},
"location": {
"value": "<location>"
},
"virtualMachineScaleSetResourceId": {
"value": "<virtualMachineScaleSetResourceId>"
}
}
}
```

</details>
<p>


## Parameters

Expand Down Expand Up @@ -3026,6 +3153,7 @@ module virtualMachine 'br/public:avm/res/compute/virtual-machine:<version>' = {
| [`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. |
| [`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 @@ -4057,6 +4185,14 @@ The flag that enables or disables a capability to have one or more managed data
- Type: bool
- Default: `False`

### Parameter: `virtualMachineScaleSetResourceId`

Resource ID of a virtual machine scale set, where the VM should be added.

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

### Parameter: `vTpmEnabled`

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.
Expand Down
22 changes: 21 additions & 1 deletion avm/res/compute/virtual-machine/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ param bootDiagnosticStorageAccountUri string = '.blob.${environment().suffixes.s
@description('Optional. Resource ID of a proximity placement group.')
param proximityPlacementGroupResourceId string = ''

@description('Optional. Resource ID of a virtual machine scale set, where the VM should be added.')
param virtualMachineScaleSetResourceId string = ''

@description('Optional. Resource ID of an availability set. Cannot be used in combination with availability zone nor scale set.')
param availabilitySetResourceId string = ''

Expand Down Expand Up @@ -567,6 +570,11 @@ resource vm 'Microsoft.Compute/virtualMachines@2023-09-01' = {
id: proximityPlacementGroupResourceId
}
: null
virtualMachineScaleSet: !empty(virtualMachineScaleSetResourceId)
? {
id: virtualMachineScaleSetResourceId
}
: null
priority: priority
evictionPolicy: enableEvictionPolicy ? 'Deallocate' : null
#disable-next-line BCP036
Expand Down Expand Up @@ -649,6 +657,7 @@ module vm_aadJoinExtension 'extension/main.bicep' =
? extensionAadJoinConfig.enableAutomaticUpgrade
: false
settings: contains(extensionAadJoinConfig, 'settings') ? extensionAadJoinConfig.settings : {}
supressFailures: extensionAadJoinConfig.?supressFailures ?? false
tags: extensionAadJoinConfig.?tags ?? tags
}
}
Expand All @@ -672,6 +681,7 @@ module vm_domainJoinExtension 'extension/main.bicep' =
? extensionDomainJoinConfig.enableAutomaticUpgrade
: false
settings: extensionDomainJoinConfig.settings
supressFailures: extensionDomainJoinConfig.?supressFailures ?? false
tags: extensionDomainJoinConfig.?tags ?? tags
protectedSettings: {
Password: extensionDomainJoinPassword
Expand Down Expand Up @@ -701,6 +711,7 @@ module vm_microsoftAntiMalwareExtension 'extension/main.bicep' =
? extensionAntiMalwareConfig.enableAutomaticUpgrade
: false
settings: extensionAntiMalwareConfig.settings
supressFailures: extensionAntiMalwareConfig.?supressFailures ?? false
tags: extensionAntiMalwareConfig.?tags ?? tags
}
dependsOn: [
Expand Down Expand Up @@ -750,6 +761,7 @@ module vm_azureMonitorAgentExtension 'extension/main.bicep' =
: ''
GCS_AUTO_CONFIG: osType == 'Linux' ? true : null
}
supressFailures: extensionMonitoringAgentConfig.?supressFailures ?? false
tags: extensionMonitoringAgentConfig.?tags ?? tags
protectedSettings: {
workspaceKey: !empty(extensionMonitoringAgentConfig.?monitoringWorkspaceId ?? '')
Expand Down Expand Up @@ -785,6 +797,7 @@ module vm_dependencyAgentExtension 'extension/main.bicep' =
? extensionDependencyAgentConfig.enableAMA
: true
}
supressFailures: extensionDependencyAgentConfig.?supressFailures ?? false
tags: extensionDependencyAgentConfig.?tags ?? tags
}
dependsOn: [
Expand All @@ -810,6 +823,7 @@ module vm_networkWatcherAgentExtension 'extension/main.bicep' =
enableAutomaticUpgrade: contains(extensionNetworkWatcherAgentConfig, 'enableAutomaticUpgrade')
? extensionNetworkWatcherAgentConfig.enableAutomaticUpgrade
: false
supressFailures: extensionNetworkWatcherAgentConfig.?supressFailures ?? false
tags: extensionNetworkWatcherAgentConfig.?tags ?? tags
}
dependsOn: [
Expand All @@ -836,6 +850,7 @@ module vm_desiredStateConfigurationExtension 'extension/main.bicep' =
? extensionDSCConfig.enableAutomaticUpgrade
: false
settings: contains(extensionDSCConfig, 'settings') ? extensionDSCConfig.settings : {}
supressFailures: extensionDSCConfig.?supressFailures ?? false
tags: extensionDSCConfig.?tags ?? tags
protectedSettings: contains(extensionDSCConfig, 'protectedSettings') ? extensionDSCConfig.protectedSettings : {}
}
Expand Down Expand Up @@ -869,6 +884,7 @@ module vm_customScriptExtension 'extension/main.bicep' =
: fileData.uri
]
}
supressFailures: extensionCustomScriptConfig.?supressFailures ?? false
tags: extensionCustomScriptConfig.?tags ?? tags
protectedSettings: extensionCustomScriptProtectedSetting
}
Expand Down Expand Up @@ -898,7 +914,8 @@ module vm_azureDiskEncryptionExtension 'extension/main.bicep' =
forceUpdateTag: contains(extensionAzureDiskEncryptionConfig, 'forceUpdateTag')
? extensionAzureDiskEncryptionConfig.forceUpdateTag
: '1.0'
settings: extensionAzureDiskEncryptionConfig.settings
settings: extensionAzureDiskEncryptionConfig.?settings ?? {}
supressFailures: extensionAzureDiskEncryptionConfig.?supressFailures ?? false
tags: extensionAzureDiskEncryptionConfig.?tags ?? tags
}
dependsOn: [
Expand All @@ -924,6 +941,7 @@ module vm_nvidiaGpuDriverWindowsExtension 'extension/main.bicep' =
enableAutomaticUpgrade: contains(extensionNvidiaGpuDriverWindows, 'enableAutomaticUpgrade')
? extensionNvidiaGpuDriverWindows.enableAutomaticUpgrade
: false
supressFailures: extensionNvidiaGpuDriverWindows.?supressFailures ?? false
tags: extensionNvidiaGpuDriverWindows.?tags ?? tags
}
dependsOn: [
Expand Down Expand Up @@ -957,6 +975,7 @@ module vm_hostPoolRegistrationExtension 'extension/main.bicep' =
registrationInfoToken: extensionHostPoolRegistration.registrationInfoToken
aadJoin: true
}
supressFailures: extensionHostPoolRegistration.?supressFailures ?? false
}
tags: extensionHostPoolRegistration.?tags ?? tags
}
Expand Down Expand Up @@ -989,6 +1008,7 @@ module vm_azureGuestConfigurationExtension 'extension/main.bicep' =
settings: contains(extensionGuestConfigurationExtension, 'settings')
? extensionGuestConfigurationExtension.settings
: {}
supressFailures: extensionGuestConfigurationExtension.?supressFailures ?? false
protectedSettings: extensionGuestConfigurationExtensionProtectedSettings
tags: extensionGuestConfigurationExtension.?tags ?? tags
}
Expand Down
Loading

0 comments on commit 8bfabfd

Please sign in to comment.