Skip to content

Commit

Permalink
azurerm_function_app - add support for the http2_enabled pr… (#4696)
Browse files Browse the repository at this point in the history
Fixes #4490
  • Loading branch information
aczelandi authored and katbyte committed Oct 27, 2019
1 parent 728578f commit da37799
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
13 changes: 13 additions & 0 deletions azurerm/resource_arm_function_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ func resourceArmFunctionApp() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"http2_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"cors": azure.SchemaWebCorsSettings(),
},
},
Expand Down Expand Up @@ -713,6 +718,10 @@ func expandFunctionAppSiteConfig(d *schema.ResourceData) web.SiteConfig {
siteConfig.VnetName = utils.String(v.(string))
}

if v, ok := config["http2_enabled"]; ok {
siteConfig.HTTP20Enabled = utils.Bool(v.(bool))
}

return siteConfig
}

Expand Down Expand Up @@ -745,6 +754,10 @@ func flattenFunctionAppSiteConfig(input *web.SiteConfig) []interface{} {
result["virtual_network_name"] = *input.VnetName
}

if input.HTTP20Enabled != nil {
result["http2_enabled"] = *input.HTTP20Enabled
}

result["cors"] = azure.FlattenWebCorsSettings(input.Cors)

results = append(results, result)
Expand Down
67 changes: 67 additions & 0 deletions azurerm/resource_arm_function_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,33 @@ func TestAccAzureRMFunctionApp_vnetName(t *testing.T) {
})
}

func TestAccAzureRMFunctionApp_enableHttp2(t *testing.T) {
resourceName := "azurerm_function_app.test"
ri := tf.AccRandTimeInt()
rs := strings.ToLower(acctest.RandString(11))
config := testAccAzureRMFunctionApp_enableHttp2(ri, rs, testLocation())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMFunctionAppDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMFunctionAppExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "site_config.0.http2_enabled", "true"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testCheckAzureRMFunctionAppDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*ArmClient).Web.AppServicesClient

Expand Down Expand Up @@ -1674,3 +1701,43 @@ resource "azurerm_function_app" "test" {
}
`, rInt, location, storage, vnetName)
}

func testAccAzureRMFunctionApp_enableHttp2(rInt int, rString string, location string) string {
return fmt.Sprintf(`
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"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
tier = "Standard"
size = "S1"
}
}
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}"
site_config {
http2_enabled = true
}
}
`, rInt, location, rString, rInt, rInt)
}
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 @@ -146,6 +146,8 @@ The following arguments are supported:

* `linux_fx_version` - (Optional) Linux App Framework and version for the AppService, e.g. `DOCKER|(golang:latest)`.

* `http2_enabled` - (Optional) Specifies whether or not the http2 protocol should be enabled. Defaults to `false`.

* `cors` - (Optional) A `cors` block as defined below.

---
Expand Down

0 comments on commit da37799

Please sign in to comment.