diff --git a/azurerm/internal/services/web/function_app.go b/azurerm/internal/services/web/function_app.go index 61c96562ce96..7c28886b136e 100644 --- a/azurerm/internal/services/web/function_app.go +++ b/azurerm/internal/services/web/function_app.go @@ -69,6 +69,7 @@ func schemaAppServiceFunctionAppSiteConfig() *schema.Schema { "pre_warmed_instance_count": { Type: schema.TypeInt, Optional: true, + Computed: true, ValidateFunc: validation.IntBetween(0, 10), }, diff --git a/azurerm/internal/services/web/function_app_resource_test.go b/azurerm/internal/services/web/function_app_resource_test.go index 8be6e78faf8c..b014f2196306 100644 --- a/azurerm/internal/services/web/function_app_resource_test.go +++ b/azurerm/internal/services/web/function_app_resource_test.go @@ -651,6 +651,22 @@ func TestAccFunctionApp_preWarmedInstanceCount(t *testing.T) { }) } +func TestAccAzureRMFunctionApp_computedPreWarmedInstanceCount(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_function_app", "test") + r := FunctionAppResource{} + + data.ResourceTest(t, r, []resource.TestStep{ + { + Config: r.computedPreWarmedInstanceCount(data), + Check: resource.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("site_config.0.pre_warmed_instance_count").HasValue("1"), + ), + }, + data.ImportStep(), + }) +} + func TestAccFunctionApp_oneIpRestriction(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -2303,6 +2319,47 @@ resource "azurerm_function_app" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger) } +func (r FunctionAppResource) computedPreWarmedInstanceCount(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_storage_account" "test" { + name = "acctestsa%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + kind = "elastic" + + sku { + tier = "ElasticPremium" + size = "EP1" + } +} + +resource "azurerm_function_app" "test" { + name = "acctest-%d-func" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + app_service_plan_id = azurerm_app_service_plan.test.id + storage_connection_string = azurerm_storage_account.test.primary_connection_string +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger) +} + func (r FunctionAppResource) oneIpRestriction(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" {