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

App Service Beta - support for Load Balancer timeouts and VNet Route All. #14202

Merged
merged 6 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
359 changes: 172 additions & 187 deletions internal/services/appservice/helpers/web_app_schema.go

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions internal/services/appservice/linux_web_app_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ func (r LinuxWebAppDataSource) Read() sdk.ResourceFunc {
return fmt.Errorf("reading Site Publishing Credential information for Linux %s: %+v", id, err)
}

webApp.AppSettings = helpers.FlattenAppSettings(appSettings)
var healthCheckCount *int
webApp.AppSettings, healthCheckCount = helpers.FlattenAppSettings(appSettings)
webApp.Kind = utils.NormalizeNilableString(existing.Kind)
webApp.Location = location.NormalizeNilable(existing.Location)
webApp.Tags = tags.ToTypedObject(existing.Tags)
Expand Down Expand Up @@ -290,7 +291,7 @@ func (r LinuxWebAppDataSource) Read() sdk.ResourceFunc {

webApp.LogsConfig = helpers.FlattenLogsConfig(logsConfig)

webApp.SiteConfig = helpers.FlattenSiteConfigLinux(webAppSiteConfig.SiteConfig)
webApp.SiteConfig = helpers.FlattenSiteConfigLinux(webAppSiteConfig.SiteConfig, healthCheckCount)

webApp.StorageAccounts = helpers.FlattenStorageAccounts(storageAccounts)

Expand Down
14 changes: 12 additions & 2 deletions internal/services/appservice/linux_web_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package appservice
import (
"context"
"fmt"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -306,6 +307,10 @@ func (r LinuxWebAppResource) Create() sdk.ResourceFunc {
metadata.SetID(id)

appSettings := helpers.ExpandAppSettings(webApp.AppSettings)
if metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time") {
appSettings.Properties["WEBSITE_HEALTHCHECK_MAXPINGFAILURE"] = utils.String(strconv.Itoa(webApp.SiteConfig[0].HealthCheckEvictionTime))
}

if appSettings.Properties != nil {
if _, err := client.UpdateApplicationSettings(ctx, id.ResourceGroup, id.SiteName, *appSettings); err != nil {
return fmt.Errorf("setting App Settings for Linux %s: %+v", id, err)
Expand Down Expand Up @@ -432,10 +437,12 @@ func (r LinuxWebAppResource) Read() sdk.ResourceFunc {
Name: id.SiteName,
ResourceGroup: id.ResourceGroup,
Location: location.NormalizeNilable(webApp.Location),
AppSettings: helpers.FlattenAppSettings(appSettings),
Tags: tags.ToTypedObject(webApp.Tags),
}

var healthCheckCount *int
state.AppSettings, healthCheckCount = helpers.FlattenAppSettings(appSettings)

webAppProps := webApp.SiteProperties
if v := webAppProps.ServerFarmID; v != nil {
state.ServicePlanId = *v
Expand Down Expand Up @@ -493,7 +500,7 @@ func (r LinuxWebAppResource) Read() sdk.ResourceFunc {

state.LogsConfig = helpers.FlattenLogsConfig(logsConfig)

state.SiteConfig = helpers.FlattenSiteConfigLinux(webAppSiteConfig.SiteConfig)
state.SiteConfig = helpers.FlattenSiteConfigLinux(webAppSiteConfig.SiteConfig, healthCheckCount)

state.StorageAccounts = helpers.FlattenStorageAccounts(storageAccounts)

Expand Down Expand Up @@ -600,6 +607,9 @@ func (r LinuxWebAppResource) Update() sdk.ResourceFunc {
// (@jackofallops) - App Settings can clobber logs configuration so must be updated before we send any Log updates
if metadata.ResourceData.HasChange("app_settings") {
appSettingsUpdate := helpers.ExpandAppSettings(state.AppSettings)
if metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time") {
appSettingsUpdate.Properties["WEBSITE_HEALTHCHECK_MAXPINGFAILURE"] = utils.String(strconv.Itoa(state.SiteConfig[0].HealthCheckEvictionTime))
}
if _, err := client.UpdateApplicationSettings(ctx, id.ResourceGroup, id.SiteName, *appSettingsUpdate); err != nil {
return fmt.Errorf("updating App Settings for Linux %s: %+v", id, err)
}
Expand Down
4 changes: 3 additions & 1 deletion internal/services/appservice/linux_web_app_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ resource "azurerm_linux_web_app" "test" {
websockets_enabled = true
ftps_state = "FtpsOnly"
health_check_path = "/health2"
health_check_eviction_time = 7
number_of_workers = 2
minimum_tls_version = "1.2"
scm_minimum_tls_version = "1.2"
Expand Down Expand Up @@ -1383,7 +1384,8 @@ resource "azurerm_linux_web_app" "test" {
minimum_process_execution_time = "00:05:00"
}
}
// auto_swap_slot_name = // TODO - Not supported yet

vnet_route_all_enabled = true
}

storage_account {
Expand Down
5 changes: 3 additions & 2 deletions internal/services/appservice/windows_web_app_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ func (d WindowsWebAppDataSource) Read() sdk.ResourceFunc {
return fmt.Errorf("reading Site Metadata for Windows %s: %+v", id, err)
}

webApp.AppSettings = helpers.FlattenAppSettings(appSettings)
var healthCheckCount *int
webApp.AppSettings, healthCheckCount = helpers.FlattenAppSettings(appSettings)
webApp.Kind = utils.NormalizeNilableString(existing.Kind)
webApp.Location = location.NormalizeNilable(existing.Location)
webApp.Tags = tags.ToTypedObject(existing.Tags)
Expand Down Expand Up @@ -292,7 +293,7 @@ func (d WindowsWebAppDataSource) Read() sdk.ResourceFunc {
if ok {
currentStack = *currentStackPtr
}
webApp.SiteConfig = helpers.FlattenSiteConfigWindows(webAppSiteConfig.SiteConfig, currentStack)
webApp.SiteConfig = helpers.FlattenSiteConfigWindows(webAppSiteConfig.SiteConfig, currentStack, healthCheckCount)

webApp.StorageAccounts = helpers.FlattenStorageAccounts(storageAccounts)

Expand Down
6 changes: 4 additions & 2 deletions internal/services/appservice/windows_web_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,12 @@ func (r WindowsWebAppResource) Read() sdk.ResourceFunc {
Name: id.SiteName,
ResourceGroup: id.ResourceGroup,
Location: location.NormalizeNilable(webApp.Location),
AppSettings: helpers.FlattenAppSettings(appSettings),
Tags: tags.ToTypedObject(webApp.Tags),
}

var healthCheckCount *int
state.AppSettings, healthCheckCount = helpers.FlattenAppSettings(appSettings)

webAppProps := webApp.SiteProperties
if v := webAppProps.ServerFarmID; v != nil {
state.ServicePlanId = *v
Expand Down Expand Up @@ -499,7 +501,7 @@ func (r WindowsWebAppResource) Read() sdk.ResourceFunc {
currentStack = *currentStackPtr
}

state.SiteConfig = helpers.FlattenSiteConfigWindows(webAppSiteConfig.SiteConfig, currentStack)
state.SiteConfig = helpers.FlattenSiteConfigWindows(webAppSiteConfig.SiteConfig, currentStack, healthCheckCount)

state.StorageAccounts = helpers.FlattenStorageAccounts(storageAccounts)

Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/linux_web_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ A `site_config` block exports the following:

* `health_check_path` - The path to the Health Check endpoint.

* `health_check_eviction_time` - (Optional) The amount of time in minutes that a node can be unhealthy before being removed from the load balancer. Possible values are between `2` and `10`. Only valid in conjunction with `health_check_path`.

* `http2_enabled` - Is HTTP2.0 enabled.

* `ip_restriction` - A `ip_restriction` block as defined above.
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/windows_web_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ A `site_config` block exports the following:

* `health_check_path` - The path to the Health Check endpoint.

* `health_check_eviction_time` - (Optional) The amount of time in minutes that a node can be unhealthy before being removed from the load balancer. Possible values are between `2` and `10`. Only valid in conjunction with `health_check_path`.

* `http2_enabled` - Is HTTP2.0 enabled.

* `ip_restriction` - A `ip_restriction` block as defined above.
Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/linux_web_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ A `site_config` block supports the following:

* `health_check_path` - (Optional) The path to the Health Check.

* `health_check_eviction_time` - (Optional) The amount of time in minutes that a node can be unhealthy before being removed from the load balancer. Possible values are between `2` and `10`. Only valid in conjunction with `health_check_path`.

* `http2_enabled` - (Optional) Should the HTTP2 be enabled?

* `ip_restriction` - (Optional) One or more `ip_restriction` blocks as defined above.
Expand All @@ -449,7 +451,7 @@ A `site_config` block supports the following:

* `scm_use_main_ip_restriction` - (Optional) Should the Linux Web App `ip_restriction` configuration be used for the SCM also.

* `32_bit_worker` - (Optional) Should the Linux Web App use a 32-bit worker.
* `use_32_bit_worker` - (Optional) Should the Linux Web App use a 32-bit worker. Defaults to `true`.

* `websockets` - (Optional) Should Web Sockets be enabled. Defaults to `false`.

Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/windows_web_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ A `site_config` block supports the following:

* `health_check_path` - (Optional) The path to the Health Check.

* `health_check_eviction_time` - (Optional) The amount of time in minutes that a node can be unhealthy before being removed from the load balancer. Possible values are between `2` and `10`. Only valid in conjunction with `health_check_path`.

* `http2_enabled` - (Optional) Should the HTTP2 be enabled?

* `ip_restriction` - (Optional) One or more `ip_restriction` blocks as defined above.
Expand Down