I try to create azurerm_windows_virtual_machine_scale_set
resource.
I write simple Terraform code:
resource "azurerm_windows_virtual_machine_scale_set" "vmss" {
name = local.name
resource_group_name = local.resource_group_name
location = local.location
sku = local.skutier
instances = 2
admin_password = P@$word12345
admin_username = admin123
computer_name_prefix = "vm-"
source_image_reference {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
sku = local.vmss_sku_name
version = "latest"
}
os_disk {
storage_account_type = "Standard_LRS"
caching = "ReadWrite"
}
network_interface {
name = local.nic
primary = true
ip_configuration {
name = local.ipconfig
primary = true
subnet_id = data.azurerm_subnet.subnet.id
}
}
}
But when i apply, i got an error:
╷
│ Error: creating Windows Virtual Machine Scale Set (Subscription: "XYZ"
│ Resource Group Name: "rg"
│ Virtual Machine Scale Set Name: "vmss"): performing CreateOrUpdate: unexpected status 400 (400 Bad Request) with error: InvalidParameter: The property 'windowsConfiguration.patchSettings.patchMode' is not valid because the 'Microsoft.Compute/InGuestAutoPatchVmssUniformPreview' feature is not enabled for this subscription.
│
│ with azurerm_windows_virtual_machine_scale_set.vmss,
│ on virtualmachinescaleset.tf line 2, in resource "azurerm_windows_virtual_machine_scale_set" "vmss":
│ 2: resource "azurerm_windows_virtual_machine_scale_set" "vmss" {
│
╵
How to overcome this issue withotu subscription-level changes?
EDIT:
when i add:
upgrade_mode = "Manual"
enable_automatic_updates = false
or only enable_automatic_updates = false
i have the same error
EDIT2:
When i run terraform apply
in debug mode i receive this json arm:
{
"identity": {
"type": "None",
"userAssignedIdentities": null
},
"location": "westeurope",
"properties": {
"additionalCapabilities": {},
"doNotRunExtensionsOnOverprovisionedVMs": false,
"orchestrationMode": "Uniform",
"overprovision": true,
"scaleInPolicy": {
"forceDeletion": false,
"rules": [
"Default"
]
},
"singlePlacementGroup": true,
"upgradePolicy": {
"mode": "Automatic"
},
"virtualMachineProfile": {
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": false,
"storageUri": ""
}
},
"extensionProfile": {
"extensionsTimeBudget": "PT1H30M"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "vmss-nic",
"properties": {
"dnsSettings": {
"dnsServers": []
},
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"ipConfigurations": [
{
"name": "vmss-ipconfig",
"properties": {
"applicationGatewayBackendAddressPools": [],
"applicationSecurityGroups": [],
"loadBalancerBackendAddressPools": [],
"loadBalancerInboundNatPools": [],
"primary": true,
"privateIPAddressVersion": "IPv4",
"subnet": {
"id": "/subscriptions/sybid/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnet/subnets/subnet"
}
}
}
],
"primary": true
}
}
]
},
"osProfile": {
"adminPassword": "Vmsspassword#3",
"adminUsername": "vmssusername",
"computerNamePrefix": "vm-",
"secrets": [],
"windowsConfiguration": {
"enableAutomaticUpdates": true,
"provisionVMAgent": true,
"winRM": {
"listeners": []
}
}
},
"priority": "Regular",
"storageProfile": {
"dataDisks": [],
"imageReference": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2022-datacenter-azure-edition-core",
"version": "latest"
},
"osDisk": {
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"osType": "Windows",
"writeAcceleratorEnabled": false
}
}
}
},
"sku": {
"capacity": 2,
"name": "Standard_B4ms",
"tier": "Standard"
}
}
After applying this block:
upgrade_mode = "Manual"
overprovision = false
automatic_instance_repair {
enabled = false
grace_period = "PT30M"
}
scale_in {
force_deletion_enabled = false
rule = "Default"
}