Skip to content

Commit

Permalink
Fixes #745, adds more options to azurerm_function_app
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudify committed Feb 24, 2018
1 parent 1ea6d1a commit 1d65509
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
45 changes: 42 additions & 3 deletions azurerm/resource_arm_function_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ func resourceArmFunctionApp() *schema.Resource {
Computed: true,
},

"client_affinity_enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true,

// TODO: (tombuildsstuff) support Update once the API is fixed:
// https://github.com/Azure/azure-rest-api-specs/issues/1697
ForceNew: true,
},

"site_config": {
Type: schema.TypeList,
Optional: true,
Expand All @@ -134,6 +144,16 @@ func resourceArmFunctionApp() *schema.Resource {
Optional: true,
Default: false,
},
"use_32_bit_worker_process": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"websockets_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
},
},
},
Expand All @@ -152,6 +172,7 @@ func resourceArmFunctionAppCreate(d *schema.ResourceData, meta interface{}) erro
kind := "functionapp"
appServicePlanID := d.Get("app_service_plan_id").(string)
enabled := d.Get("enabled").(bool)
clientAffinityEnabled := d.Get("client_affinity_enabled").(bool)
tags := d.Get("tags").(map[string]interface{})
basicAppSettings := getBasicFunctionAppAppSettings(d)
siteConfig := expandFunctionAppSiteConfig(d)
Expand All @@ -162,9 +183,10 @@ func resourceArmFunctionAppCreate(d *schema.ResourceData, meta interface{}) erro
Location: &location,
Tags: expandTags(tags),
SiteProperties: &web.SiteProperties{
ServerFarmID: utils.String(appServicePlanID),
Enabled: utils.Bool(enabled),
SiteConfig: &siteConfig,
ServerFarmID: utils.String(appServicePlanID),
Enabled: utils.Bool(enabled),
ClientAffinityEnabled: utils.Bool(clientAffinityEnabled),
SiteConfig: &siteConfig,
},
}

Expand Down Expand Up @@ -288,6 +310,7 @@ func resourceArmFunctionAppRead(d *schema.ResourceData, meta interface{}) error
d.Set("enabled", props.Enabled)
d.Set("default_hostname", props.DefaultHostName)
d.Set("outbound_ip_addresses", props.OutboundIPAddresses)
d.Set("client_affinity_enabled", props.ClientAffinityEnabled)
}

appSettings := flattenAppServiceAppSettings(appSettingsResp.Properties)
Expand Down Expand Up @@ -394,6 +417,14 @@ func expandFunctionAppSiteConfig(d *schema.ResourceData) web.SiteConfig {
siteConfig.AlwaysOn = utils.Bool(v.(bool))
}

if v, ok := config["use_32_bit_worker_process"]; ok {
siteConfig.Use32BitWorkerProcess = utils.Bool(v.(bool))
}

if v, ok := config["websockets_enabled"]; ok {
siteConfig.WebSocketsEnabled = utils.Bool(v.(bool))
}

return siteConfig
}

Expand All @@ -410,6 +441,14 @@ func flattenFunctionAppSiteConfig(input *web.SiteConfig) []interface{} {
result["always_on"] = *input.AlwaysOn
}

if input.Use32BitWorkerProcess != nil {
result["use_32_bit_worker_process"] = *input.Use32BitWorkerProcess
}

if input.WebSocketsEnabled != nil {
result["websockets_enabled"] = *input.WebSocketsEnabled
}

results = append(results, result)
return results
}
Expand Down
9 changes: 8 additions & 1 deletion website/docs/r/function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ The following arguments are supported:

* `enabled` - (Optional) Is the Function App enabled? Changing this forces a new resource to be created.

* `client_affinity_enabled` - (Optional) Should the Function App send session affinity cookies, which route client requests in the same session to the same instance? Changing this forces a new resource to be created.

* `version` - (Optional) The runtime version associated with the Function App. Possible values are `~1` and `beta`. Defaults to `~1`.

* `site_config` - (Optional) A `site_config` object as defined below.
Expand All @@ -87,7 +89,12 @@ The following arguments are supported:

`site_config` supports the following:

* `always_on` - (Optional) Should the app be loaded at all times? Defaults to `false`.
* `always_on` - (Optional) Should the Function App be loaded at all times? Defaults to `false`.
* `use_32_bit_worker_process` - (Optional) Should the Function App run in 32 bit mode, rather than 64 bit mode? Defaults to `true`.

~> **Note:** when using an App Service Plan in the `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`.

* `websockets_enabled` - (Optional) Should WebSockets be enabled?

## Attributes Reference

Expand Down

0 comments on commit 1d65509

Please sign in to comment.