diff --git a/internal/services/appservice/linux_function_app_resource.go b/internal/services/appservice/linux_function_app_resource.go index 0161ebe2dbff..13c9326515e0 100644 --- a/internal/services/appservice/linux_function_app_resource.go +++ b/internal/services/appservice/linux_function_app_resource.go @@ -459,7 +459,9 @@ func (r LinuxFunctionAppResource) Create() sdk.ResourceFunc { suffix := uuid.New().String()[0:4] _, contentOverVnetEnabled := functionApp.AppSettings["WEBSITE_CONTENTOVERVNET"] _, contentSharePresent := functionApp.AppSettings["WEBSITE_CONTENTSHARE"] - _, contentShareConnectionString := functionApp.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] + if _, contentShareConnectionStringPresent := functionApp.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"]; !contentShareConnectionStringPresent { + functionApp.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] = storageString + } if !contentSharePresent { if contentOverVnetEnabled { @@ -467,12 +469,6 @@ func (r LinuxFunctionAppResource) Create() sdk.ResourceFunc { } functionApp.AppSettings["WEBSITE_CONTENTSHARE"] = fmt.Sprintf("%s-%s", strings.ToLower(functionApp.Name), suffix) } - if !contentShareConnectionString { - if contentOverVnetEnabled && contentSharePresent { - return fmt.Errorf("WEBSITE_CONTENTAZUREFILECONNECTIONSTRING must be set when WEBSITE_CONTENTSHARE and WEBSITE_CONTENTOVERVNET are specified") - } - functionApp.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] = storageString - } } else { if _, present := functionApp.AppSettings["AzureWebJobsStorage__accountName"]; !present { functionApp.AppSettings["AzureWebJobsStorage__accountName"] = storageString @@ -945,7 +941,9 @@ func (r LinuxFunctionAppResource) Update() sdk.ResourceFunc { suffix := uuid.New().String()[0:4] _, contentOverVnetEnabled := state.AppSettings["WEBSITE_CONTENTOVERVNET"] _, contentSharePresent := state.AppSettings["WEBSITE_CONTENTSHARE"] - _, contentShareConnectionString := state.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] + if _, contentShareConnectionStringPresent := state.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"]; !contentShareConnectionStringPresent { + state.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] = storageString + } if !contentSharePresent { if contentOverVnetEnabled { @@ -953,12 +951,6 @@ func (r LinuxFunctionAppResource) Update() sdk.ResourceFunc { } state.AppSettings["WEBSITE_CONTENTSHARE"] = fmt.Sprintf("%s-%s", strings.ToLower(state.Name), suffix) } - if !contentShareConnectionString { - if contentOverVnetEnabled && contentSharePresent { - return fmt.Errorf("WEBSITE_CONTENTAZUREFILECONNECTIONSTRING must be set when WEBSITE_CONTENTSHARE and WEBSITE_CONTENTOVERVNET is specified") - } - state.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] = storageString - } } else { if _, present := state.AppSettings["AzureWebJobsStorage__accountName"]; !present { state.AppSettings["AzureWebJobsStorage__accountName"] = storageString diff --git a/internal/services/appservice/windows_function_app_resource.go b/internal/services/appservice/windows_function_app_resource.go index 09652b5ff342..41b5497281c3 100644 --- a/internal/services/appservice/windows_function_app_resource.go +++ b/internal/services/appservice/windows_function_app_resource.go @@ -457,7 +457,9 @@ func (r WindowsFunctionAppResource) Create() sdk.ResourceFunc { suffix := uuid.New().String()[0:4] _, contentOverVnetEnabled := functionApp.AppSettings["WEBSITE_CONTENTOVERVNET"] _, contentSharePresent := functionApp.AppSettings["WEBSITE_CONTENTSHARE"] - _, contentShareConnectionString := functionApp.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] + if _, contentShareConnectionStringPresent := functionApp.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"]; !contentShareConnectionStringPresent { + functionApp.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] = storageString + } if !contentSharePresent { if contentOverVnetEnabled { @@ -465,12 +467,6 @@ func (r WindowsFunctionAppResource) Create() sdk.ResourceFunc { } functionApp.AppSettings["WEBSITE_CONTENTSHARE"] = fmt.Sprintf("%s-%s", strings.ToLower(functionApp.Name), suffix) } - if !contentShareConnectionString { - if contentOverVnetEnabled && contentSharePresent { - return fmt.Errorf("WEBSITE_CONTENTAZUREFILECONNECTIONSTRING must be set when WEBSITE_CONTENTSHARE and WEBSITE_CONTENTOVERVNET are specified") - } - functionApp.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] = storageString - } } else { if _, present := functionApp.AppSettings["AzureWebJobsStorage__accountName"]; !present { functionApp.AppSettings["AzureWebJobsStorage__accountName"] = storageString @@ -948,7 +944,9 @@ func (r WindowsFunctionAppResource) Update() sdk.ResourceFunc { suffix := uuid.New().String()[0:4] _, contentOverVnetEnabled := state.AppSettings["WEBSITE_CONTENTOVERVNET"] _, contentSharePresent := state.AppSettings["WEBSITE_CONTENTSHARE"] - _, contentShareConnectionString := state.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] + if _, contentShareConnectionStringPresent := state.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"]; !contentShareConnectionStringPresent { + state.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] = storageString + } if !contentSharePresent { if contentOverVnetEnabled { @@ -956,12 +954,6 @@ func (r WindowsFunctionAppResource) Update() sdk.ResourceFunc { } state.AppSettings["WEBSITE_CONTENTSHARE"] = fmt.Sprintf("%s-%s", strings.ToLower(state.Name), suffix) } - if !contentShareConnectionString { - if contentOverVnetEnabled && contentSharePresent { - return fmt.Errorf("WEBSITE_CONTENTAZUREFILECONNECTIONSTRING must be set when WEBSITE_CONTENTSHARE and WEBSITE_CONTENTOVERVNET is specified") - } - state.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] = storageString - } } else { if _, present := state.AppSettings["AzureWebJobsStorage__accountName"]; !present { state.AppSettings["AzureWebJobsStorage__accountName"] = storageString diff --git a/website/docs/r/linux_function_app.html.markdown b/website/docs/r/linux_function_app.html.markdown index f458076d49ca..f90173b93e05 100644 --- a/website/docs/r/linux_function_app.html.markdown +++ b/website/docs/r/linux_function_app.html.markdown @@ -69,11 +69,15 @@ The following arguments are supported: * `app_settings` - (Optional) A map of key-value pairs for [App Settings](https://docs.microsoft.com/azure/azure-functions/functions-app-settings) and custom values. -~> **Note:** for runtime related settings, please use `node_version` in `site_config` to set the node version and use `functions_extension_version` to set the function runtime version, terraform will assign the values to the key `WEBSITE_NODE_DEFAULT_VERSION` and `FUNCTIONS_EXTENSION_VERSION` in app setting. +~> **Note:** For runtime related settings, please use `node_version` in `site_config` to set the node version and use `functions_extension_version` to set the function runtime version, terraform will assign the values to the key `WEBSITE_NODE_DEFAULT_VERSION` and `FUNCTIONS_EXTENSION_VERSION` in app setting. + ~> **Note:** For storage related settings, please use related properties that are available such as `storage_account_access_key`, terraform will assign the value to keys such as `WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`, `AzureWebJobsStorage` in app_setting. -~> **Note:** for application insight related settings, please use `application_insights_connection_string` and `application_insights_key`, terraform will assign the value to the key `APPINSIGHTS_INSTRUMENTATIONKEY` and `APPLICATIONINSIGHTS_CONNECTION_STRING` in app setting. -~> **Note:** for health check related settings, please use `health_check_eviction_time_in_min`, terraform will assign the value to the key `WEBSITE_HEALTHCHECK_MAXPINGFAILURES` in app setting. -~> **NOTE:** Please create a predefined share if you are restricting your storage account to a virtual network by setting `WEBSITE_CONTENTOVERVNET` to 1 in app_setting. + +~> **Note:** For application insight related settings, please use `application_insights_connection_string` and `application_insights_key`, terraform will assign the value to the key `APPINSIGHTS_INSTRUMENTATIONKEY` and `APPLICATIONINSIGHTS_CONNECTION_STRING` in app setting. + +~> **Note:** For health check related settings, please use `health_check_eviction_time_in_min`, terraform will assign the value to the key `WEBSITE_HEALTHCHECK_MAXPINGFAILURES` in app setting. + +~> **Note:** Please create a predefined share if you are restricting your storage account to a virtual network by setting `WEBSITE_CONTENTOVERVNET` to 1 in app_setting. * `auth_settings` - (Optional) A `auth_settings` block as defined below. diff --git a/website/docs/r/windows_function_app.html.markdown b/website/docs/r/windows_function_app.html.markdown index 87c2af296787..f0f43006a86d 100644 --- a/website/docs/r/windows_function_app.html.markdown +++ b/website/docs/r/windows_function_app.html.markdown @@ -68,12 +68,16 @@ The following arguments are supported: --- * `app_settings` - (Optional) A map of key-value pairs for [App Settings](https://docs.microsoft.com/azure/azure-functions/functions-app-settings) and custom values. - -~> **Note:** for runtime related settings, please use `node_version` in `site_config` to set the node version and use `functions_extension_version` to set the function runtime version, terraform will assign the values to the key `WEBSITE_NODE_DEFAULT_VERSION` and `FUNCTIONS_EXTENSION_VERSION` in app setting. + +~> **Note:** For runtime related settings, please use `node_version` in `site_config` to set the node version and use `functions_extension_version` to set the function runtime version, terraform will assign the values to the key `WEBSITE_NODE_DEFAULT_VERSION` and `FUNCTIONS_EXTENSION_VERSION` in app setting. + ~> **Note:** For storage related settings, please use related properties that are available such as `storage_account_access_key`, terraform will assign the value to keys such as `WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`, `AzureWebJobsStorage` in app_setting. -~> **Note:** for application insight related settings, please use `application_insights_connection_string` and `application_insights_key`, terraform will assign the value to the key `APPINSIGHTS_INSTRUMENTATIONKEY` and `APPLICATIONINSIGHTS_CONNECTION_STRING` in app setting. -~> **Note:** for health check related settings, please use `health_check_eviction_time_in_min`, terraform will assign the value to the key `WEBSITE_HEALTHCHECK_MAXPINGFAILURES` in app setting. -~> **NOTE:** Please create a predefined share if you are restricting your storage account to a virtual network by setting `WEBSITE_CONTENTOVERVNET` to 1 in app_setting. + +~> **Note:** For application insight related settings, please use `application_insights_connection_string` and `application_insights_key`, terraform will assign the value to the key `APPINSIGHTS_INSTRUMENTATIONKEY` and `APPLICATIONINSIGHTS_CONNECTION_STRING` in app setting. + +~> **Note:** For health check related settings, please use `health_check_eviction_time_in_min`, terraform will assign the value to the key `WEBSITE_HEALTHCHECK_MAXPINGFAILURES` in app setting. + +~> **Note:** Please create a predefined share if you are restricting your storage account to a virtual network by setting `WEBSITE_CONTENTOVERVNET` to 1 in app_setting. * `auth_settings` - (Optional) A `auth_settings` block as defined below.