diff --git a/azurerm/helpers/azure/app_service.go b/azurerm/helpers/azure/app_service.go index 5354401c4723..56d623b2f933 100644 --- a/azurerm/helpers/azure/app_service.go +++ b/azurerm/helpers/azure/app_service.go @@ -450,6 +450,11 @@ func SchemaAppServiceSiteConfig() *schema.Schema { }, false), }, + "health_check_path": { + Type: schema.TypeString, + Optional: true, + }, + "linux_fx_version": { Type: schema.TypeString, Optional: true, @@ -749,6 +754,11 @@ func SchemaAppServiceDataSourceSiteConfig() *schema.Schema { Computed: true, }, + "health_check_path": { + Type: schema.TypeString, + Computed: true, + }, + "linux_fx_version": { Type: schema.TypeString, Computed: true, @@ -1486,6 +1496,10 @@ func ExpandAppServiceSiteConfig(input interface{}) (*web.SiteConfig, error) { siteConfig.FtpsState = web.FtpsState(v.(string)) } + if v, ok := config["health_check_path"]; ok { + siteConfig.HealthCheckPath = utils.String(v.(string)) + } + if v, ok := config["min_tls_version"]; ok { siteConfig.MinTLSVersion = web.SupportedTLSVersions(v.(string)) } @@ -1606,6 +1620,11 @@ func FlattenAppServiceSiteConfig(input *web.SiteConfig) []interface{} { result["scm_type"] = string(input.ScmType) result["ftps_state"] = string(input.FtpsState) + + if input.HealthCheckPath != nil { + result["health_check_path"] = *input.HealthCheckPath + } + result["min_tls_version"] = string(input.MinTLSVersion) result["cors"] = FlattenWebCorsSettings(input.Cors) diff --git a/azurerm/internal/services/web/tests/resource_arm_app_service_test.go b/azurerm/internal/services/web/tests/resource_arm_app_service_test.go index bb2ae8eb9370..569e9422ca48 100644 --- a/azurerm/internal/services/web/tests/resource_arm_app_service_test.go +++ b/azurerm/internal/services/web/tests/resource_arm_app_service_test.go @@ -1201,6 +1201,25 @@ func TestAccAzureRMAppService_ftpsState(t *testing.T) { }) } +func TestAccAzureRMAppService_healthCheckPath(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_app_service", "test") + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMAppService_healthCheckPath(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "site_config.0.health_check_path", "/health"), + ), + }, + data.ImportStep(), + }, + }) +} + // todo - linuxFxVersion seems to reject all supplied values - needs more detailed investigation. // error message simply reads: Original Error: Code="BadRequest" Message="The parameter LinuxFxVersion has an invalid value." func TestAccAzureRMAppService_linuxFxVersion(t *testing.T) { @@ -3391,6 +3410,41 @@ resource "azurerm_app_service" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) } +func testAccAzureRMAppService_healthCheckPath(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + app_service_plan_id = azurerm_app_service_plan.test.id + + site_config { + health_check_path = "/health" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} + func testAccAzureRMAppService_linuxFxVersion(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/website/docs/d/app_service.html.markdown b/website/docs/d/app_service.html.markdown index 07d6832efc6b..8632a61ecc49 100644 --- a/website/docs/d/app_service.html.markdown +++ b/website/docs/d/app_service.html.markdown @@ -103,6 +103,8 @@ A `ip_restriction` block exports the following: * `ftps_state` - State of FTP / FTPS service for this AppService. +* `health_check_path` - The health check path to be pinged by App Service. + * `ip_restriction` - One or more `ip_restriction` blocks as defined above. * `java_version` - The version of Java in use. diff --git a/website/docs/r/app_service.html.markdown b/website/docs/r/app_service.html.markdown index 5400097688d7..ca76a223325e 100644 --- a/website/docs/r/app_service.html.markdown +++ b/website/docs/r/app_service.html.markdown @@ -187,6 +187,10 @@ A `site_config` block supports the following: * `ftps_state` - (Optional) State of FTP / FTPS service for this App Service. Possible values include: `AllAllowed`, `FtpsOnly` and `Disabled`. +* `health_check_path` - (Optional) The health check path to be pinged by App Service. [For more information - please see the corresponding Kudu Wiki page](https://github.com/projectkudu/kudu/wiki/Health-Check-(Preview)). + +~> **Note:** This functionality is in Preview and is subject to changes (including breaking changes) on Azure's end + * `http2_enabled` - (Optional) Is HTTP2 Enabled on this App Service? Defaults to `false`. * `ip_restriction` - (Optional) A [List of objects](/docs/configuration/attr-as-blocks.html) representing ip restrictions as defined below.