Cannot change app service plan, from standard to Free, because of always_on and use_32_bit_worker_process

Hi,
I’m trying to create a module for some services, part of that is a app service plan and a web app.
I need the ability to change the app service plan from Standard down to Free when required. However, Although the plan looks good, it changes the alway_on to false and the use_32_bit_worker_process to true it fails to run. Checking the errors, it says

{"Code":"Conflict","Message":"Cannot update the site 'Webapp' because it uses x64 worker process which is not allowed in the target compute mode.","Target":null,"Details":[{"Message":"Cannot update     
                   the site 'Webapp' because it uses x64 worker process which is not allowed in the target compute mode."},{"Code":"Conflict"},{"ErrorEntity":{"ExtendedCode":"04066","MessageTemplate":"Cannot update the site '{0}'
                   because it uses x64 worker process which is not allowed in the target compute mode.","Parameters":["Webapp"],"Code":"Conflict","Message":"Cannot update the site 'Webapp' because it uses x64 worker process 
                   which is not allowed in the target compute mode."}}],"Innererror":null}"

Why is it not changing the web app first and then changing the app service plan. If I could put a depends_on, but then I wouldn’t be able to create the app service plan in the first place. Any help would be great

data "azurerm_subscription" "current" {}



resource "azurerm_resource_group" "tq_resource_group" {
  name     = var.resource_group_name
  location = var.location
}

resource "azurerm_app_service_plan" "tq_app_service_plan" {
  name                = var.app_service_plan
  location            = azurerm_resource_group.tq_resource_group.location
  resource_group_name = azurerm_resource_group.tq_resource_group.name
  kind = var.kind
  reserved = var.kind == "linux" ? true : false
  sku {
    tier = var.skutier
    size = var.skusize
    capacity  = var.capacity
  }
}

resource "azurerm_app_service" "tq_webapp" {
  name                      = var.name
  location                  = azurerm_resource_group.tq_resource_group.location
  resource_group_name       = azurerm_resource_group.tq_resource_group.name
  app_service_plan_id       = azurerm_app_service_plan.tq_app_service_plan.id
  https_only          = true

  site_config {
    always_on = local.always_on

    dotnet_framework_version = local.dotnet_framework_version
    use_32_bit_worker_process = local.use_32_bit_worker_process
    http2_enabled = local.http2_enabled
 
  }

  dynamic "connection_string" {
    for_each = var.connection_strings
    content {
      name  = connection_string.value.name
      type  = connection_string.value.type
      value = connection_string.value.value
    }
  }

 app_settings = local.app_settings



}

### Basic settings - will be used in multiple places

variable "location" {
    type     = string
    description = "Location of the resources"

  }

variable "resource_group_name" {
    type     = string
    description = "The Resource Group Name of the Service"

  }

### End of Basic settings

### Used for App Service Plan

variable "app_service_plan" {
    type     = string
    description = "Used to specify the App Service Plan name which the Web App will use."

  }

variable "kind" {
  type = string
  default = "app"
  description =  "The kind of App Service Plan to create. The options are as follows -> Windows (also available as App), Linux, elastic (for Premium Consumption) and FunctionApp (for a Consumption Plan). Defaults to Windows. Changing this forces a new resource to be created."

}

variable "reserved" {
    type     = bool
    default = false
    description = "This is required to be set if you are going to linux for the App Serice Plan, It defaults to false "

  }

### ### used in the Sku block in the App Service Plan

variable "skutier" {
    type     = string
    default = "Free"
    description = "The required tier - Free, Basic, Standard"

  }

  

variable "skusize" {
    type     = string
    default = "F1"
    description = "The required sku size F1 (Free), B1 (Basic 1), S1 (Standard 1), S2 (Standard 2) for a full list please see the list at ->"

  }

variable "capacity" {
  type = number
  default = 0
  description =  "Number of instances assigned to the App Service."

}

### ### end of the sku block in the App Service Plan

### End of the App Serivce Plan 

### Start of the Web App 

variable "name" {
    type     = string
    description = "The name of the App Service."
  }


 variable "app_settings" {
    type     = map(string)
    default = {}
    description = "App Settings Go here"
  } 

variable "connection_strings" {
  type = list(object({
    name = string
    type = string
    value = string
  }))
  default =[]
}

locals {

is_shared = contains(["F1", "FREE", "D1", "SHARED"], upper(var.skusize))
always_on = "${local.is_shared == true ? null : true}"
use_32_bit_worker_process = "${local.is_shared == true ? null : false}"
dotnet_framework_version = "v4.0"
http2_enabled = false
app_settings = var.app_settings

}