Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_function_app app_settings refresh plan is not empty #7440

Merged
merged 1 commit into from Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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