diff --git a/azurerm/internal/services/web/data_source_function_app.go b/azurerm/internal/services/web/data_source_function_app.go index c0ae357f58b4..bf4eb6e7a738 100644 --- a/azurerm/internal/services/web/data_source_function_app.go +++ b/azurerm/internal/services/web/data_source_function_app.go @@ -2,6 +2,7 @@ package web import ( "fmt" + "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -94,6 +95,11 @@ func dataSourceArmFunctionApp() *schema.Resource { }, }, + "os_type": { + Type: schema.TypeString, + Computed: true, + }, + "outbound_ip_addresses": { Type: schema.TypeString, Computed: true, @@ -168,6 +174,12 @@ func dataSourceArmFunctionAppRead(d *schema.ResourceData, meta interface{}) erro d.Set("possible_outbound_ip_addresses", props.PossibleOutboundIPAddresses) } + osType := "" + if v := resp.Kind; v != nil && strings.Contains(*v, "linux") { + osType = "linux" + } + d.Set("os_type", osType) + appSettings := flattenAppServiceAppSettings(appSettingsResp.Properties) if err = d.Set("app_settings", appSettings); err != nil { diff --git a/azurerm/internal/services/web/resource_arm_function_app.go b/azurerm/internal/services/web/resource_arm_function_app.go index 223d9d127804..fd6418430015 100644 --- a/azurerm/internal/services/web/resource_arm_function_app.go +++ b/azurerm/internal/services/web/resource_arm_function_app.go @@ -143,6 +143,15 @@ func resourceArmFunctionApp() *schema.Resource { Computed: true, }, + "os_type": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + "linux", + }, false), + }, + "outbound_ip_addresses": { Type: schema.TypeString, Computed: true, @@ -307,6 +316,13 @@ func resourceArmFunctionAppCreate(d *schema.ResourceData, meta interface{}) erro location := azure.NormalizeLocation(d.Get("location").(string)) kind := "functionapp" + if osTypeRaw, ok := d.GetOk("os_type"); ok { + osType := osTypeRaw.(string) + if osType == "linux" { + kind = "functionapp,linux" + } + } + appServicePlanID := d.Get("app_service_plan_id").(string) enabled := d.Get("enabled").(bool) clientAffinityEnabled := d.Get("client_affinity_enabled").(bool) @@ -394,6 +410,12 @@ func resourceArmFunctionAppUpdate(d *schema.ResourceData, meta interface{}) erro location := azure.NormalizeLocation(d.Get("location").(string)) kind := "functionapp" + if osTypeRaw, ok := d.GetOk("os_type"); ok { + osType := osTypeRaw.(string) + if osType == "Linux" { + kind = "functionapp,linux" + } + } appServicePlanID := d.Get("app_service_plan_id").(string) enabled := d.Get("enabled").(bool) clientAffinityEnabled := d.Get("client_affinity_enabled").(bool) @@ -551,6 +573,11 @@ func resourceArmFunctionAppRead(d *schema.ResourceData, meta interface{}) error d.Set("name", name) d.Set("resource_group_name", resGroup) d.Set("kind", resp.Kind) + osType := "" + if v := resp.Kind; v != nil && strings.Contains(*v, "linux") { + osType = "linux" + } + d.Set("os_type", osType) if location := resp.Location; location != nil { d.Set("location", azure.NormalizeLocation(*location)) diff --git a/azurerm/internal/services/web/tests/resource_arm_function_app_test.go b/azurerm/internal/services/web/tests/resource_arm_function_app_test.go index ccc9d3c3468a..cd38d86192dd 100644 --- a/azurerm/internal/services/web/tests/resource_arm_function_app_test.go +++ b/azurerm/internal/services/web/tests/resource_arm_function_app_test.go @@ -1165,6 +1165,7 @@ resource "azurerm_function_app" "test" { resource_group_name = "${azurerm_resource_group.test.name}" app_service_plan_id = "${azurerm_app_service_plan.test.id}" storage_connection_string = "${azurerm_storage_account.test.primary_connection_string}" + os_type = "linux" site_config { linux_fx_version = "DOCKER|(golang:latest)" diff --git a/website/docs/d/function_app.html.markdown b/website/docs/d/function_app.html.markdown index f14fea19cf7c..6a712ed2aa37 100644 --- a/website/docs/d/function_app.html.markdown +++ b/website/docs/d/function_app.html.markdown @@ -46,6 +46,10 @@ The following attributes are exported: * `site_credential` - A `site_credential` block as defined below, which contains the site-level credentials used to publish to this App Service. +* `os_type` - A string indicating the Operating System type for this function app. + +~> **NOTE:** This value will be `linux` for Linux Derivatives or an empty string for Windows. + * `outbound_ip_addresses` - A comma separated list of outbound IP addresses. * `possible_outbound_ip_addresses` - A comma separated list of outbound IP addresses, not all of which are necessarily in use. Superset of `outbound_ip_addresses`. diff --git a/website/docs/r/function_app.html.markdown b/website/docs/r/function_app.html.markdown index 5ab0845ff867..c2ac13f73ac3 100644 --- a/website/docs/r/function_app.html.markdown +++ b/website/docs/r/function_app.html.markdown @@ -109,6 +109,10 @@ The following arguments are supported: * `connection_string` - (Optional) An `connection_string` block as defined below. +* `os_type` - (Optional) A string indicating the Operating System type for this function app. + +~> **NOTE:** This value will be `linux` for Linux Derivatives or an empty string for Windows (default). + * `client_affinity_enabled` - (Optional) Should the Function App send session affinity cookies, which route client requests in the same session to the same instance? * `enabled` - (Optional) Is the Function App enabled?