Skip to content

Commit

Permalink
azurerm_windows_function_app, azurerm_linux_function_app: fix the…
Browse files Browse the repository at this point in the history
… `runtime_scale_monitoring_enabled` not being set issue (#18149)
  • Loading branch information
xiaxyi authored Aug 30, 2022
1 parent 4274f70 commit 403db16
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 1 deletion.
8 changes: 8 additions & 0 deletions internal/services/appservice/helpers/function_app_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions internal/services/appservice/linux_function_app_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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" {
Expand Down
42 changes: 42 additions & 0 deletions internal/services/appservice/windows_function_app_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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" {
Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/linux_function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/windows_function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit 403db16

Please sign in to comment.