Skip to content

Commit

Permalink
Merge pull request #6100 from aqche/azurerm_function_app_daily_memory…
Browse files Browse the repository at this point in the history
…_time_quota

`azurerm_function_app` - support for `daily_memory_time_quota`
  • Loading branch information
tombuildsstuff authored Mar 16, 2020
2 parents 6896d70 + 518b5fb commit 65c55d2
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
10 changes: 10 additions & 0 deletions azurerm/internal/services/web/resource_arm_function_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ func resourceArmFunctionApp() *schema.Resource {
Default: false,
},

"daily_memory_time_quota": {
Type: schema.TypeInt,
Optional: true,
},

"site_config": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -323,6 +328,7 @@ func resourceArmFunctionAppCreate(d *schema.ResourceData, meta interface{}) erro
enabled := d.Get("enabled").(bool)
clientAffinityEnabled := d.Get("client_affinity_enabled").(bool)
httpsOnly := d.Get("https_only").(bool)
dailyMemoryTimeQuota := d.Get("daily_memory_time_quota").(int)
t := d.Get("tags").(map[string]interface{})
appServiceTier, err := getFunctionAppServiceTier(ctx, appServicePlanID, meta)
if err != nil {
Expand All @@ -347,6 +353,7 @@ func resourceArmFunctionAppCreate(d *schema.ResourceData, meta interface{}) erro
Enabled: utils.Bool(enabled),
ClientAffinityEnabled: utils.Bool(clientAffinityEnabled),
HTTPSOnly: utils.Bool(httpsOnly),
DailyMemoryTimeQuota: utils.Int32(int32(dailyMemoryTimeQuota)),
SiteConfig: &siteConfig,
},
}
Expand Down Expand Up @@ -413,6 +420,7 @@ func resourceArmFunctionAppUpdate(d *schema.ResourceData, meta interface{}) erro
enabled := d.Get("enabled").(bool)
clientAffinityEnabled := d.Get("client_affinity_enabled").(bool)
httpsOnly := d.Get("https_only").(bool)
dailyMemoryTimeQuota := d.Get("daily_memory_time_quota").(int)
t := d.Get("tags").(map[string]interface{})

appServiceTier, err := getFunctionAppServiceTier(ctx, appServicePlanID, meta)
Expand All @@ -437,6 +445,7 @@ func resourceArmFunctionAppUpdate(d *schema.ResourceData, meta interface{}) erro
Enabled: utils.Bool(enabled),
ClientAffinityEnabled: utils.Bool(clientAffinityEnabled),
HTTPSOnly: utils.Bool(httpsOnly),
DailyMemoryTimeQuota: utils.Int32(int32(dailyMemoryTimeQuota)),
SiteConfig: &siteConfig,
},
}
Expand Down Expand Up @@ -576,6 +585,7 @@ func resourceArmFunctionAppRead(d *schema.ResourceData, meta interface{}) error
d.Set("enabled", props.Enabled)
d.Set("default_hostname", props.DefaultHostName)
d.Set("https_only", props.HTTPSOnly)
d.Set("daily_memory_time_quota", props.DailyMemoryTimeQuota)
d.Set("outbound_ip_addresses", props.OutboundIPAddresses)
d.Set("possible_outbound_ip_addresses", props.PossibleOutboundIPAddresses)
d.Set("client_affinity_enabled", props.ClientAffinityEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,34 @@ func TestAccAzureRMFunctionApp_httpsOnly(t *testing.T) {
})
}

func TestAccAzureRMFunctionApp_dailyMemoryTimeQuota(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_function_app", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMFunctionAppDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMFunctionApp_consumptionPlan(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMFunctionAppExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "daily_memory_time_quota", "0"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMFunctionApp_dailyMemoryTimeQuota(data, 1000),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMFunctionAppExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "daily_memory_time_quota", "1000"),
),
},
data.ImportStep(),
},
})
}

func TestAccAzureRMFunctionApp_consumptionPlan(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_function_app", "test")

Expand Down Expand Up @@ -1470,6 +1498,48 @@ resource "azurerm_function_app" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger)
}

func testAccAzureRMFunctionApp_dailyMemoryTimeQuota(data acceptance.TestData, dailyMemoryTimeQuota int) 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 = "FunctionApp"
sku {
tier = "Dynamic"
size = "Y1"
}
}
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
daily_memory_time_quota = %d
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger, dailyMemoryTimeQuota)
}

func testAccAzureRMFunctionApp_consumptionPlan(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ The following arguments are supported:

* `version` - (Optional) The runtime version associated with the Function App. Defaults to `~1`.

* `daily_memory_time_quota` - (Optional) The amount of memory in gigabyte-seconds that your application is allowed to consume per day. Setting this value only affects function apps under the consumption plan. Defaults to `0`.

* `site_config` - (Optional) A `site_config` object as defined below.

* `identity` - (Optional) An `identity` block as defined below.
Expand Down

0 comments on commit 65c55d2

Please sign in to comment.