diff --git a/internal/services/appservice/helpers/function_app_schema.go b/internal/services/appservice/helpers/function_app_schema.go index 8844f5a64dfb..848b1458b27f 100644 --- a/internal/services/appservice/helpers/function_app_schema.go +++ b/internal/services/appservice/helpers/function_app_schema.go @@ -1687,6 +1687,10 @@ func ExpandSiteConfigLinuxFunctionApp(siteConfig []SiteConfigLinuxFunctionApp, e expanded.MinimumElasticInstanceCount = utils.Int32(int32(linuxSiteConfig.ElasticInstanceMinimum)) } + if metadata.ResourceData.HasChange("site_config.0.runtime_scale_monitoring_enabled") { + expanded.FunctionsRuntimeScaleMonitoringEnabled = utils.Bool(linuxSiteConfig.RuntimeScaleMonitoring) + } + expanded.AppSettings = &appSettings return expanded, nil @@ -1923,6 +1927,10 @@ func ExpandSiteConfigWindowsFunctionApp(siteConfig []SiteConfigWindowsFunctionAp expanded.MinimumElasticInstanceCount = utils.Int32(int32(windowsSiteConfig.ElasticInstanceMinimum)) } + if metadata.ResourceData.HasChange("site_config.0.runtime_scale_monitoring_enabled") { + expanded.FunctionsRuntimeScaleMonitoringEnabled = utils.Bool(windowsSiteConfig.RuntimeScaleMonitoring) + } + expanded.AppSettings = &appSettings return expanded, nil diff --git a/internal/services/appservice/linux_function_app_resource_test.go b/internal/services/appservice/linux_function_app_resource_test.go index 21ef36a6757a..312948a4ad52 100644 --- a/internal/services/appservice/linux_function_app_resource_test.go +++ b/internal/services/appservice/linux_function_app_resource_test.go @@ -42,6 +42,23 @@ func TestAccLinuxFunctionApp_basicBasicPlan(t *testing.T) { }) } +func TestAccLinuxFunctionApp_basicRuntimeCheck(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_linux_function_app", "test") + r := LinuxFunctionAppResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.runtimeScaleCheck(data, SkuElasticPremiumPlan), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("kind").HasValue("functionapp,linux"), + check.That(data.ResourceName).Key("site_config.0.runtime_scale_monitoring_enabled").HasValue("true"), + ), + }, + data.ImportStep(), + }) +} + func TestAccLinuxFunctionApp_basicConsumptionPlan(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_linux_function_app", "test") r := LinuxFunctionAppResource{} @@ -1362,6 +1379,31 @@ resource "azurerm_linux_function_app" "test" { `, r.template(data, planSku), data.RandomInteger) } +func (r LinuxFunctionAppResource) runtimeScaleCheck(data acceptance.TestData, planSku string) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%s + +resource "azurerm_linux_function_app" "test" { + name = "acctest-LFA-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + service_plan_id = azurerm_service_plan.test.id + + storage_account_name = azurerm_storage_account.test.name + storage_account_access_key = azurerm_storage_account.test.primary_access_key + + site_config { + runtime_scale_monitoring_enabled = true + pre_warmed_instance_count = 1 + } +} +`, r.template(data, planSku), data.RandomInteger) +} + func (r LinuxFunctionAppResource) healthCheckPath(data acceptance.TestData, planSku string) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/internal/services/appservice/windows_function_app_resource_test.go b/internal/services/appservice/windows_function_app_resource_test.go index 5aaccc64cd52..25729c5ea3ff 100644 --- a/internal/services/appservice/windows_function_app_resource_test.go +++ b/internal/services/appservice/windows_function_app_resource_test.go @@ -34,6 +34,23 @@ func TestAccWindowsFunctionApp_basicBasicPlan(t *testing.T) { }) } +func TestAccWindowsFunctionApp_basicRuntimeCheck(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_windows_function_app", "test") + r := WindowsFunctionAppResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.runtimeScaleCheck(data, SkuElasticPremiumPlan), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("kind").HasValue("functionapp"), + check.That(data.ResourceName).Key("site_config.0.runtime_scale_monitoring_enabled").HasValue("true"), + ), + }, + data.ImportStep(), + }) +} + func TestAccWindowsFunctionApp_basicConsumptionPlan(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_windows_function_app", "test") r := WindowsFunctionAppResource{} @@ -1259,6 +1276,31 @@ resource "azurerm_windows_function_app" "test" { `, r.template(data, planSku), data.RandomInteger) } +func (r WindowsFunctionAppResource) runtimeScaleCheck(data acceptance.TestData, planSku string) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +%s + +resource "azurerm_windows_function_app" "test" { + name = "acctest-WFA-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + service_plan_id = azurerm_service_plan.test.id + + storage_account_name = azurerm_storage_account.test.name + storage_account_access_key = azurerm_storage_account.test.primary_access_key + + site_config { + runtime_scale_monitoring_enabled = true + pre_warmed_instance_count = 1 + } +} +`, r.template(data, planSku), data.RandomInteger) +} + func (r WindowsFunctionAppResource) appSettings(data acceptance.TestData, planSku string) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/website/docs/r/linux_function_app.html.markdown b/website/docs/r/linux_function_app.html.markdown index 7539c3dd0861..90de526e7ffd 100644 --- a/website/docs/r/linux_function_app.html.markdown +++ b/website/docs/r/linux_function_app.html.markdown @@ -434,7 +434,9 @@ A `site_config` block supports the following: * `remote_debugging_version` - (Optional) The Remote Debugging Version. Possible values include `VS2017` and `VS2019`. -* `runtime_scale_monitoring_enabled` - (Optional) Should Scale Monitoring of the Functions Runtime be enabled? +* `runtime_scale_monitoring_enabled` - (Optional) Should Scale Monitoring of the Functions Runtime be enabled? + +~> **NOTE:** Functions runtime scale monitoring can only be enabled for Elastic Premium Function Apps or Workflow Standard Logic Apps and requires a minimum prewarmed instance count of 1. * `scm_ip_restriction` - (Optional) One or more `scm_ip_restriction` blocks as defined above. diff --git a/website/docs/r/windows_function_app.html.markdown b/website/docs/r/windows_function_app.html.markdown index 2ad52917d16c..b733fd8076c1 100644 --- a/website/docs/r/windows_function_app.html.markdown +++ b/website/docs/r/windows_function_app.html.markdown @@ -410,6 +410,8 @@ A `site_config` block supports the following: * `runtime_scale_monitoring_enabled` - (Optional) Should Scale Monitoring of the Functions Runtime be enabled? +~> **NOTE:** Functions runtime scale monitoring can only be enabled for Elastic Premium Function Apps or Workflow Standard Logic Apps and requires a minimum prewarmed instance count of 1. + * `scm_ip_restriction` - (Optional) One or more `scm_ip_restriction` blocks as defined above. * `scm_minimum_tls_version` - (Optional) Configures the minimum version of TLS required for SSL requests to the SCM site. Possible values include: `1.0`, `1.1`, and `1.2`. Defaults to `1.2`.