Search code examples
phpazureazure-web-app-servicegithub-actionsterraform-provider-azure

Error setting php version for azure windows web app terraform


I'm deploying a web app service to Azure via terraform. My runtime stack should be php. The terraform documentation states the php_version variable should be "v7.4". Within my github actions run, I receive the below error:

[ERROR] vertex "azurerm_windows_web_app.lab9_app_srv" 
error: expected site_config.0.application_stack.0.php_version to be one of [7.4], got v7.4

Terraform version used in deployment: ~>3.30.0

I understand that the end of life for php version 7.4 is 28/11/2022, but version 8.0 is not set as an option in the terraform documentation.

I changed the php_version variable to the below assignments to no avail:

  • php_version=["7.4"]
  • php_version=["v7.4"]
  • php_version=7.4

When the php_version was declared in a list, the below error is produced:

Inappropriate value for attribute "php_version": string required.

The web-app.tf config deploys the web app resource as follows:

resource "azurerm_windows_web_app" "lab9_app_srv" {
    name                = "${local.naming_prefix}wapp-service-${random_integer.rand_val.result}"
    resource_group_name = azurerm_resource_group.lab9_resource_group.name
    location            = azurerm_service_plan.lab9_app_srv_plan.location
    service_plan_id     = azurerm_service_plan.lab9_app_srv_plan.id

    # ensuring web app is enabled 
    enabled = true

    site_config {
        # ensuring web app is always on 
        always_on = true
        
        application_stack {
            current_stack = "php"
            # PHP 7.4 will reach EOL on 30/11/2022
            # https://github.com/Azure/app-service-linux-docs/tree/master/Runtime_Support
            php_version = ["7.4"]
        }
    }

    # explicit dependancy set on creation of app service plan 
    depends_on = [
      azurerm_service_plan.lab9_app_srv_plan
    ]
}

Any advice on how to properly declare the php_version I want to use? If I am not mistaken, this seems to be just a syntactical error?


Solution

  • As the error message says that the property php_version accepts string type input. You just need to pass the value of php_verion as "7.4" or "8.0".

    I have tested this in my local environment and able to deploy the phpv8.0 webapp without any issues.

    Here is my terraform script that I have tested:

    enter image description here

    Here is the sample output for your reference:

    enter image description here

    Note: Starting from php8.0 is supported only for Linux app service plan refer to this documentation for more information.