Skip to content

Commit

Permalink
Merge pull request #5839 from terraform-providers/b/function-app-linux
Browse files Browse the repository at this point in the history
fix for linux function apps
  • Loading branch information
jackofallops authored Feb 26, 2020
2 parents fbb8e97 + 8fd1ad1 commit 4532984
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
12 changes: 12 additions & 0 deletions azurerm/internal/services/web/data_source_function_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package web

import (
"fmt"
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -94,6 +95,11 @@ func dataSourceArmFunctionApp() *schema.Resource {
},
},

"os_type": {
Type: schema.TypeString,
Computed: true,
},

"outbound_ip_addresses": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -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 {
Expand Down
27 changes: 27 additions & 0 deletions azurerm/internal/services/web/resource_arm_function_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -303,6 +312,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)
Expand Down Expand Up @@ -390,6 +406,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)
Expand Down Expand Up @@ -547,6 +569,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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,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)"
Expand Down
4 changes: 4 additions & 0 deletions website/docs/d/function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 4532984

Please sign in to comment.