diff --git a/azurerm/resource_arm_app_service.go b/azurerm/resource_arm_app_service.go index 8b07bd0a621d..deb0c5c56df6 100644 --- a/azurerm/resource_arm_app_service.go +++ b/azurerm/resource_arm_app_service.go @@ -267,7 +267,7 @@ func resourceArmAppServiceCreate(d *schema.ResourceData, meta interface{}) error }, } - if v, ok := d.GetOk("client_affinity_enabled"); ok { + if v, ok := d.GetOkExists("client_affinity_enabled"); ok { enabled := v.(bool) siteEnvelope.SiteProperties.ClientAffinityEnabled = utils.Bool(enabled) } diff --git a/azurerm/resource_arm_app_service_test.go b/azurerm/resource_arm_app_service_test.go index ceb04ea2015e..768cb122bc1b 100644 --- a/azurerm/resource_arm_app_service_test.go +++ b/azurerm/resource_arm_app_service_test.go @@ -194,6 +194,27 @@ func TestAccAzureRMAppService_clientAffinityEnabled(t *testing.T) { }) } +func TestAccAzureRMAppService_clientAffinityDisabled(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := acctest.RandInt() + config := testAccAzureRMAppService_clientAffinityDisabled(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "client_affinity_enabled", "false"), + ), + }, + }, + }) +} + func TestAccAzureRMAppService_connectionStrings(t *testing.T) { resourceName := "azurerm_app_service.test" ri := acctest.RandInt() @@ -846,6 +867,34 @@ resource "azurerm_app_service" "test" { `, rInt, location, rInt, rInt) } +func testAccAzureRMAppService_clientAffinityDisabled(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +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_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + client_affinity_enabled = false +} +`, rInt, location, rInt, rInt) +} + func testAccAzureRMAppService_connectionStrings(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" {