From f9659d61ad826a133095e8cc38a3195c29ee555e Mon Sep 17 00:00:00 2001 From: Boran Car Date: Fri, 5 Jun 2020 13:37:04 +0100 Subject: [PATCH] Fix Linux Consumption Function Apps Do not add WEBSITE_CONTENTSHARE and WEBSITE_CONTENTAZUREFILECONNECTIONSTRING automatically nor ignore it when comparing resources for Linux Consumption Function Apps. According to a bug report they should not be there for Linux https://github.com/Azure/azure-functions-python-worker/issues/598. Fixes terraform-providers/terraform-provider-azurerm#5209 --- .../services/web/resource_arm_function_app.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/azurerm/internal/services/web/resource_arm_function_app.go b/azurerm/internal/services/web/resource_arm_function_app.go index e5d143fff1fb..6042c3c9176f 100644 --- a/azurerm/internal/services/web/resource_arm_function_app.go +++ b/azurerm/internal/services/web/resource_arm_function_app.go @@ -664,8 +664,14 @@ func resourceArmFunctionAppRead(d *schema.ResourceData, meta interface{}) error delete(appSettings, "AzureWebJobsDashboard") delete(appSettings, "AzureWebJobsStorage") delete(appSettings, "FUNCTIONS_EXTENSION_VERSION") - delete(appSettings, "WEBSITE_CONTENTSHARE") - delete(appSettings, "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING") + + // 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 + // report (see // https://github.com/Azure/azure-functions-python-worker/issues/598) + if !strings.EqualFold(d.Get("os_type").(string), "linux") { + delete(appSettings, "WEBSITE_CONTENTSHARE") + delete(appSettings, "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING") + } if err = d.Set("app_settings", appSettings); err != nil { return err @@ -732,6 +738,7 @@ func getBasicFunctionAppAppSettings(d *schema.ResourceData, appServiceTier, endp dashboardPropName := "AzureWebJobsDashboard" storagePropName := "AzureWebJobsStorage" functionVersionPropName := "FUNCTIONS_EXTENSION_VERSION" + contentSharePropName := "WEBSITE_CONTENTSHARE" contentFileConnStringPropName := "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING" @@ -783,8 +790,10 @@ func getBasicFunctionAppAppSettings(d *schema.ResourceData, appServiceTier, endp {Name: &contentFileConnStringPropName, Value: &storageConnection}, } - // On consumption and premium plans include WEBSITE_CONTENT components - if strings.EqualFold(appServiceTier, "dynamic") || strings.EqualFold(appServiceTier, "elasticpremium") { + // On consumption and premium plans include WEBSITE_CONTENT components, unless it's a Linux consumption plan + // (see https://github.com/Azure/azure-functions-python-worker/issues/598) + if (strings.EqualFold(appServiceTier, "dynamic") || strings.EqualFold(appServiceTier, "elasticpremium")) && + !strings.EqualFold(d.Get("os_type").(string), "linux") { return append(basicSettings, consumptionSettings...), nil }