hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.64k forks source link

azurerm_function_app: support for runtime language version attributes #11067

Open khaliddermoumi opened 3 years ago

khaliddermoumi commented 3 years ago

Community Note

Description

An Azure function app is created for a specific language runtime, f. e. dotnet or python. Those runtime languages are typically supported in several versions each, f. e. python: 3.8, 3.7, & 3.6. This is documented here. The ARM REST API supports this by several attributes, in the "siteConfig" data structure. From the azure-sdk-for-go docs:

        // NetFrameworkVersion - .NET Framework version.
    NetFrameworkVersion *string `json:"netFrameworkVersion,omitempty"`
    // PhpVersion - Version of PHP.
    PhpVersion *string `json:"phpVersion,omitempty"`
    // PythonVersion - Version of Python.
    PythonVersion *string `json:"pythonVersion,omitempty"`
    // NodeVersion - Version of Node.js.
    NodeVersion *string `json:"nodeVersion,omitempty"`
    // PowerShellVersion - Version of PowerShell.
    PowerShellVersion *string `json:"powerShellVersion,omitempty"`
    // LinuxFxVersion - Linux App Framework and version
    LinuxFxVersion *string `json:"linuxFxVersion,omitempty"`
    // WindowsFxVersion - Xenon App Framework and version
    WindowsFxVersion *string `json:"windowsFxVersion,omitempty"`
        // JavaVersion - Java version.
    JavaVersion *string `json:"javaVersion,omitempty"`

Of all these attributes, only LinuxFxVersion is currently supported. Support for the other attributes is needed, especially to create valid configurations for Windows function apps. The attributes "PhpVersion" and "WindowsFxVersion" don't need to be implemented, as they aren't supported for function apps. The "JavaContainerVersion" may also needed to be implemented, if it is supported by function apps.

The support is also needed for azurerm_function_app_slot. Some, but not all of these attributes are already implemented in azurerm_app_service.

New or Affected Resource(s)

Potential Terraform Configuration

resource "azurerm_resource_group" "example" {
  name     = "azure-functions-cptest-rg"
  location = "West Europe"
}

resource "azurerm_storage_account" "example" {
  name                     = "functionsapptestsa"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

resource "azurerm_app_service_plan" "example" {
  name                = "azure-functions-test-service-plan"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  kind                = "FunctionApp"

  sku {
    tier = "Dynamic"
    size = "Y1"
  }
}

resource "azurerm_function_app" "example" {
  name                       = "test-azure-functions"
  location                   = azurerm_resource_group.example.location
  resource_group_name        = azurerm_resource_group.example.name
  app_service_plan_id        = azurerm_app_service_plan.example.id
  storage_account_name       = azurerm_storage_account.example.name
  storage_account_access_key = azurerm_storage_account.example.primary_access_key
 app_settings = {
    FUNCTIONS_WORKER_RUNTIME = "powershell"
  }
  site_config {
    powershell_version = "7"
  }
}

References

antonismladenis commented 3 years ago

We need support for the rest siteConfig arguments: https://github.com/Azure/azure-sdk-for-go/blob/v52.5.0/services/web/mgmt/2020-09-01/web/models.go#L21405

Supporting only 'LinuxFxVersion' is not helping.

Elip-tdlr commented 3 years ago

This is needed for .NET 5 functions. I don't think an isolated .NET 5 app can be created without it.

amarkulis commented 3 years ago

Yes @Elip-tdlr .NET 5 functions cannot be built.

Scarlettliuyc commented 3 years ago

hi team, we meet same issue that for function app deploy from Terraform, but got this error. Terraform version : Terraform v1.0.3 on linux_amd64

terraform { required_providers { azure = { source = "hashicorp/azurerm" version = "= 2.73.0" } } Error: Unsupported argument │ │ on main.tf line 25, in resource "azurerm_function_app" "example": │ 25: php_version = "7.4" │ │ An argument named "php_version" is not expected here.

Could I confirm whether terraform support for PHP version now