[Bug Report]: virtual_machine enableAcceleratedNetworking setting conlict?
Describe the bug
The compute/virtual-machine module uses the nested_networkInterface.bicep module. The default is to pass in to that module the setting as below..
enableAcceleratedNetworking: contains(nicConfiguration, 'enableAcceleratedNetworking') ? nicConfiguration.enableAcceleratedNetworking : true
Source: https://github.com/Azure/ResourceModules/blob/main/modules/compute/virtual-machine/main.bicep
However the default setting for the param is set to false
param enableAcceleratedNetworking bool = false
Source https://github.com/Azure/ResourceModules/blob/main/modules/compute/virtual-machine/modules/nested_networkInterface.bicep
Considering the default value is false, and therefore if a user doesnt specifically set the value, then it makes sense that the value passed to the nested module should also default to false.
I discovered this to be an issue because I was expecting the default behaviour to be false and the vmsize i was creating didn't support network acceleration and therefore caused a Conflict failure.
To reproduce
Create a VM and do not specifically set the enableAcceleratedNetworking value
The NIC will be created as 'Accelerated Networking - true' where the user would expect this to be false (unless you read every line of code like me!) because
param enableAcceleratedNetworking bool = false
Code snippet
BUILD BICEP FILE
param virtualMachines array
module buildvms2 './modules/compute/virtual-machine/main.bicep' = [for vm in virtualMachines: {
name: 'my-vm'
params:{
location: 'eastus'
name: vm.vmName
adminUsername: vm.adminUsername
adminPassword: vm.adminPasswordOrKey
imageReference: vm.imageReference
nicConfigurations: [
{
enableAcceleratedNetworking: false
deleteOption: 'Delete'
ipConfigurations: [
{
name: 'ipconfig01'
subnetResourceId: '${resourceGroup().id}/providers/Microsoft.Network/virtualNetworks/${vm.networkname}/subnets/${vm.subnetname}'
}
]
nicSuffix: '-nic-01'
}
]
osDisk: {
diskSizeGB: 50
managedDisk: {
storageAccountType: 'Premium_LRS'
}
}
osType: 'Linux'
secureBootEnabled: true
vmSize: vm.vmsize
}
}
BICEP PARAM FILE
using './vm_from_azure_resources.bicep'
param virtualMachines = [
{
vmName: 'bicepvm'
vmsize: 'Standard_B1s' //this vm size needs acceleration turned off
imageReference: {
publisher: 'Canonical'
offer: '0001-com-ubuntu-server-jammy'
sku: '22_04-lts-gen2'
version: 'latest'
}
adminUsername: 'myadminuser'
adminPasswordOrKey: 'somegreatpassword123!!'
networkname: '<existing vnet nam>'
subnetname: '<existing subnet name>'
}
Relevant log output
"statusMessage": {
"error": {
"additionalInfo": null,
"code": "VMSizeIsNotPermittedToEnableAcceleratedNetworking",
"details": [],
"message": "Virtual machine /subscriptions/<my-subscription>/resourceGroups/<my-rg>/providers/Microsoft.Compute/virtualMachines/bicepvm has size Standard_B1s, which is not compatible with enabling accelerated networking on network interface(s) on the VM......."