Skip to content

Commit

Permalink
Merge pull request #7440 from yupwei68/wyp-function-app
Browse files Browse the repository at this point in the history
`azurerm_function_app` `app_settings` refresh plan is not empty
  • Loading branch information
jackofallops committed Jun 23, 2020
2 parents a715fb1 + a590e9a commit f5da29e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 8 deletions.
12 changes: 9 additions & 3 deletions azurerm/internal/services/web/resource_arm_function_app.go
Expand Up @@ -661,9 +661,15 @@ func resourceArmFunctionAppRead(d *schema.ResourceData, meta interface{}) error
dashboard, ok := appSettings["AzureWebJobsDashboard"]
d.Set("enable_builtin_logging", ok && dashboard != "")

delete(appSettings, "AzureWebJobsDashboard")
delete(appSettings, "AzureWebJobsStorage")
delete(appSettings, "FUNCTIONS_EXTENSION_VERSION")
if _, ok = d.GetOk("app_settings.AzureWebJobsDashboard"); !ok {
delete(appSettings, "AzureWebJobsDashboard")
}
if _, ok = d.GetOk("app_settings.AzureWebJobsStorage"); !ok {
delete(appSettings, "AzureWebJobsStorage")
}
if _, ok = d.GetOk("app_settings.FUNCTIONS_EXTENSION_VERSION"); !ok {
delete(appSettings, "FUNCTIONS_EXTENSION_VERSION")
}

// Let the user have a final say whether he wants to keep these 2 or not on
// Linux consumption plans. They shouldn't be there according to a bug
Expand Down
Expand Up @@ -174,23 +174,27 @@ func TestAccAzureRMFunctionApp_appSettings(t *testing.T) {
Config: testAccAzureRMFunctionApp_basic(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMFunctionAppExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "app_settings.%", "0"),
resource.TestCheckResourceAttr(data.ResourceName, "site_credential.#", "1"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMFunctionApp_appSettings(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMFunctionAppExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "app_settings.%", "1"),
resource.TestCheckResourceAttr(data.ResourceName, "app_settings.hello", "world"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMFunctionApp_appSettingsUpdate(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMFunctionAppExists(data.ResourceName),
),
},
data.ImportStep("app_settings.%", "app_settings.AzureWebJobsDashboard", "app_settings.AzureWebJobsStorage"),
{
Config: testAccAzureRMFunctionApp_basic(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMFunctionAppExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "app_settings.%", "0"),
),
},
data.ImportStep(),
Expand Down Expand Up @@ -1224,6 +1228,53 @@ resource "azurerm_function_app" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func testAccAzureRMFunctionApp_appSettingsUpdate(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%[1]d"
location = "%[2]s"
}
resource "azurerm_storage_account" "test" {
name = "acctestsa%[3]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-%[1]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-%[1]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_account_name = azurerm_storage_account.test.name
storage_account_access_key = azurerm_storage_account.test.primary_access_key
app_settings = {
"APPINSIGHTS_INSTRUMENTATIONKEY" = azurerm_storage_account.test.primary_connection_string
"AzureWebJobsDashboard" = azurerm_storage_account.test.primary_connection_string
"AzureWebJobsStorage" = azurerm_storage_account.test.primary_connection_string
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func testAccAzureRMFunctionApp_alwaysOn(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down

0 comments on commit f5da29e

Please sign in to comment.