Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for linux function apps #5839

Merged
merged 3 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
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