创建 azurerm_windows_virtual_machine_scale_set 时,属性 windowsConfiguration.patchSettings.patchMode 无效

问题描述 投票:0回答:1

我尝试创建

azurerm_windows_virtual_machine_scale_set
资源。

我编写简单的 Terraform 代码:

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
    }
  }
}

但是当我申请时,我收到一个错误:

╷
│ 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" {
│
╵

如何在不更改订阅级别的情况下克服此问题?

编辑:

当我添加:

  upgrade_mode             = "Manual"
  enable_automatic_updates = false

或者只是

enable_automatic_updates = false
我有同样的错误

编辑2:

当我在调试模式下运行

terraform apply
时,我收到这个 json 手臂:

{
    "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"
    }
}       
azure terraform azure-resource-manager azure-virtual-machine azure-vm-scale-set
1个回答
0
投票

生成的ARM模板有:

"upgradePolicy": {
            "mode": "Automatic"
        }

默认情况下这通常是错误的。但您使用的 Terraform 版本可能并非如此。

确保使用 tf.conf 中正确的块禁用此功能。这是通过

automatic_os_upgrade
完成的,而不是 enable_automatic_updates

© www.soinside.com 2019 - 2024. All rights reserved.