Skip to content

Commit

Permalink
update pr based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaxyi committed Nov 13, 2024
1 parent 9b2127c commit f808647
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 32 deletions.
14 changes: 7 additions & 7 deletions internal/services/appservice/linux_function_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type LinuxFunctionAppModel struct {
PublishingFTPBasicAuthEnabled bool `tfschema:"ftp_publish_basic_authentication_enabled"`
Identity []identity.ModelSystemAssignedUserAssigned `tfschema:"identity"`
VnetImagePullEnabled bool `tfschema:"vnet_image_pull_enabled,addedInNextMajorVersion"`
VnetContentShareEnabled bool `tfschema:"website_content_over_vnet"`
VnetContentShareEnabled bool `tfschema:"website_content_share_over_vnet_enabled"`

// Computed
CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
Expand Down Expand Up @@ -308,11 +308,11 @@ func (r LinuxFunctionAppResource) Arguments() map[string]*pluginsdk.Schema {
Description: "The local path and filename of the Zip packaged application to deploy to this Linux Function App. **Note:** Using this value requires either `WEBSITE_RUN_FROM_PACKAGE=1` or `SCM_DO_BUILD_DURING_DEPLOYMENT=true` to be set on the App in `app_settings`.",
},

"website_content_over_vnet": {
"website_content_share_over_vnet_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
Description: "Should the app scale enabled when storage account restricted to a virtual network? Defaults to `false`.",
Description: "Should the traffic between the function app and the storage account be routed through the virtual network when Apps running in a Premium plan use a file share to store content? Defaults to `false`.",
},
}
if features.FourPointOhBeta() {
Expand Down Expand Up @@ -507,15 +507,15 @@ func (r LinuxFunctionAppResource) Create() sdk.ResourceFunc {
if !functionApp.StorageUsesMSI {
suffix := uuid.New().String()[0:4]
_, contentOverVnetEnabled := functionApp.AppSettings["WEBSITE_CONTENTOVERVNET"]
contentOverVnetEnabledSiteSetting := functionApp.VnetContentShareEnabled
contentShareOverVnetEnabledSiteSetting := functionApp.VnetContentShareEnabled
_, contentSharePresent := functionApp.AppSettings["WEBSITE_CONTENTSHARE"]
if _, contentShareConnectionStringPresent := functionApp.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"]; !contentShareConnectionStringPresent {
functionApp.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] = storageString
}

if !contentSharePresent {
if contentOverVnetEnabled || contentOverVnetEnabledSiteSetting {
return fmt.Errorf("the app_setting WEBSITE_CONTENTSHARE must be specified and set to a valid share when WEBSITE_CONTENTOVERVNET is specified")
if contentOverVnetEnabled || contentShareOverVnetEnabledSiteSetting {
return fmt.Errorf("the name of the content share that's set by the `WEBSITE_CONTENTSHARE` must be specified and set to a valid file share when premium function app use a file share to store content which enabled by setting the `website_content_share_over_vnet_enabled` to true")
}
functionApp.AppSettings["WEBSITE_CONTENTSHARE"] = fmt.Sprintf("%s-%s", strings.ToLower(functionApp.Name), suffix)
}
Expand Down Expand Up @@ -1081,7 +1081,7 @@ func (r LinuxFunctionAppResource) Update() sdk.ResourceFunc {
model.Properties.SiteConfig.PublicNetworkAccess = model.Properties.PublicNetworkAccess
}

if metadata.ResourceData.HasChange("website_content_over_vnet") {
if metadata.ResourceData.HasChange("website_content_share_over_vnet_enabled") {
model.Properties.VnetContentShareEnabled = pointer.To(state.VnetContentShareEnabled)
}

Expand Down
17 changes: 8 additions & 9 deletions internal/services/appservice/linux_function_app_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,28 +198,28 @@ func TestAccLinuxFunctionApp_websiteContentOverVnetUpdate(t *testing.T) {

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.websiteContentOverVnet(data, SkuElasticPremiumPlan, "1", false),
Config: r.websiteContentOverVnet(data, SkuElasticPremiumPlan, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("app_settings.WEBSITE_CONTENTSHARE", "app_settings.%", "site_credential.0.password"),
{
Config: r.websiteContentOverVnet(data, SkuElasticPremiumPlan, "1", true),
Config: r.websiteContentOverVnet(data, SkuElasticPremiumPlan, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("app_settings.WEBSITE_CONTENTSHARE", "app_settings.%", "site_credential.0.password"),
{
Config: r.websiteContentOverVnet(data, SkuElasticPremiumPlan, "0", true),
Config: r.websiteContentOverVnet(data, SkuElasticPremiumPlan, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("app_settings.WEBSITE_CONTENTSHARE", "app_settings.%", "site_credential.0.password"),
{
Config: r.websiteContentOverVnet(data, SkuElasticPremiumPlan, "0", false),
Config: r.websiteContentOverVnet(data, SkuElasticPremiumPlan, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -1957,7 +1957,7 @@ resource "azurerm_linux_function_app" "test" {
}

// nolint: unparam
func (r LinuxFunctionAppResource) websiteContentOverVnet(data acceptance.TestData, planSku string, websiteContentAppSetting string, websiteContentSiteConfig bool) string {
func (r LinuxFunctionAppResource) websiteContentOverVnet(data acceptance.TestData, planSku string, websiteContentSiteConfig bool) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand All @@ -1981,18 +1981,17 @@ resource "azurerm_linux_function_app" "test" {
storage_account_access_key = azurerm_storage_account.test.primary_access_key
app_settings = {
WEBSITE_CONTENTOVERVNET = "%s"
WEBSITE_CONTENTSHARE = "shareforfa"
WEBSITE_CONTENTSHARE = "shareforfa"
}
site_config {}
website_content_over_vnet = %t
website_content_share_over_vnet_enabled = %t
lifecycle {
ignore_changes = [webdeploy_publish_basic_authentication_enabled, ftp_publish_basic_authentication_enabled]
}
}
`, r.template(data, planSku), data.RandomInteger, websiteContentAppSetting, websiteContentSiteConfig)
`, r.template(data, planSku), data.RandomInteger, websiteContentSiteConfig)
}

func (r LinuxFunctionAppResource) withCors(data acceptance.TestData, planSku string) string {
Expand Down
20 changes: 10 additions & 10 deletions internal/services/appservice/windows_function_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type WindowsFunctionAppModel struct {
PublishingDeployBasicAuthEnabled bool `tfschema:"webdeploy_publish_basic_authentication_enabled"`
PublishingFTPBasicAuthEnabled bool `tfschema:"ftp_publish_basic_authentication_enabled"`
VnetImagePullEnabled bool `tfschema:"vnet_image_pull_enabled,addedInNextMajorVersion"`
VnetContentShareEnabled bool `tfschema:"website_content_over_vnet"`
VnetContentShareEnabled bool `tfschema:"website_content_share_over_vnet_enabled"`

// Computed
CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
Expand Down Expand Up @@ -306,11 +306,11 @@ func (r WindowsFunctionAppResource) Arguments() map[string]*pluginsdk.Schema {
Description: "The local path and filename of the Zip packaged application to deploy to this Windows Function App. **Note:** Using this value requires `WEBSITE_RUN_FROM_PACKAGE=1` to be set on the App in `app_settings`.",
},

"website_content_over_vnet": {
"website_content_share_over_vnet_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
Description: "Should the app scale enabled when storage account restricted to a virtual network? Defaults to `false`.",
Description: "Should the traffic between the function app and the storage account be routed through the virtual network when Apps running in a Premium plan use a file share to store content? Defaults to `false`.",
},
}
if features.FourPointOhBeta() {
Expand Down Expand Up @@ -508,15 +508,15 @@ func (r WindowsFunctionAppResource) Create() sdk.ResourceFunc {
if !functionApp.StorageUsesMSI {
suffix := uuid.New().String()[0:4]
_, contentOverVnetEnabled := functionApp.AppSettings["WEBSITE_CONTENTOVERVNET"]
contentOverVnetEnabledSiteSetting := functionApp.VnetContentShareEnabled
contentShareOverVnetEnabledSiteSetting := functionApp.VnetContentShareEnabled
_, contentSharePresent := functionApp.AppSettings["WEBSITE_CONTENTSHARE"]
if _, contentShareConnectionStringPresent := functionApp.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"]; !contentShareConnectionStringPresent {
functionApp.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] = storageString
}

if !contentSharePresent {
if contentOverVnetEnabled || contentOverVnetEnabledSiteSetting {
return fmt.Errorf("the app_setting WEBSITE_CONTENTSHARE must be specified and set to a valid share when WEBSITE_CONTENTOVERVNET is specified")
if contentOverVnetEnabled || contentShareOverVnetEnabledSiteSetting {
return fmt.Errorf("the name of the content share that's set by the `WEBSITE_CONTENTSHARE` must be specified and set to a valid file share when premium function app use a file share to store content which enabled by setting the `website_content_share_over_vnet_enabled` to true")
}
functionApp.AppSettings["WEBSITE_CONTENTSHARE"] = fmt.Sprintf("%s-%s", strings.ToLower(functionApp.Name), suffix)
}
Expand Down Expand Up @@ -1042,15 +1042,15 @@ func (r WindowsFunctionAppResource) Update() sdk.ResourceFunc {
if !state.StorageUsesMSI {
suffix := uuid.New().String()[0:4]
_, contentOverVnetEnabled := state.AppSettings["WEBSITE_CONTENTOVERVNET"]
contentOverVnetEnabledSiteSetting := state.VnetContentShareEnabled
contentShareOverVnetEnabledSiteSetting := state.VnetContentShareEnabled
_, contentSharePresent := state.AppSettings["WEBSITE_CONTENTSHARE"]
if _, contentShareConnectionStringPresent := state.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"]; !contentShareConnectionStringPresent {
state.AppSettings["WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"] = storageString
}

if !contentSharePresent {
if contentOverVnetEnabled || contentOverVnetEnabledSiteSetting {
return fmt.Errorf("the value of WEBSITE_CONTENTSHARE must be set to a predefined share when the storage account is restricted to a virtual network")
if contentOverVnetEnabled || contentShareOverVnetEnabledSiteSetting {
return fmt.Errorf("the name of the content share that's set by the `WEBSITE_CONTENTSHARE` must be specified and set to a valid file share when premium function app use a file share to store content which enabled by setting the `website_content_share_over_vnet_enabled` to true")
}
state.AppSettings["WEBSITE_CONTENTSHARE"] = fmt.Sprintf("%s-%s", strings.ToLower(state.Name), suffix)
}
Expand Down Expand Up @@ -1096,7 +1096,7 @@ func (r WindowsFunctionAppResource) Update() sdk.ResourceFunc {
model.Properties.SiteConfig.PublicNetworkAccess = model.Properties.PublicNetworkAccess
}

if metadata.ResourceData.HasChange("website_content_over_vnet") {
if metadata.ResourceData.HasChange("website_content_share_over_vnet_enabled") {
model.Properties.VnetContentShareEnabled = pointer.To(state.VnetContentShareEnabled)
}

Expand Down
4 changes: 1 addition & 3 deletions website/docs/d/linux_function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `webdeploy_publish_basic_authentication_enabled` - Are the default WebDeploy Basic Authentication publishing credentials enabled.

* `website_content_over_vnet` - Is function app scale enabled when the linked storage account is restricted to a virtual network? Defaults to `false`.

!> **Note:** This property will replace the `WEBSITE_CONTENTOVERVNET` in `app_setting`. `website_content_over_vnet` is the recommended one despite both settings work currently.
* `website_content_share_over_vnet_enabled` - Is the traffic between the function app and the storage account be routed through the virtual network when Apps running in a Premium plan use a file share to store content.

---

Expand Down
4 changes: 1 addition & 3 deletions website/docs/d/windows_function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `webdeploy_publish_basic_authentication_enabled` - Are the default WebDeploy Basic Authentication publishing credentials enabled.

* `website_content_over_vnet` - Is function app scale enabled when the linked storage account is restricted to a virtual network? Defaults to `false`.

!> **Note:** This property will replace the `WEBSITE_CONTENTOVERVNET` in `app_setting`. `website_content_over_vnet` is the recommended one despite both settings work currently.
* `website_content_share_over_vnet_enabled` - Is the traffic between the function app and the storage account be routed through the virtual network when Apps running in a Premium plan use a file share to store content.

---

Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/linux_function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ The following arguments are supported:

~> **NOTE:** Setting this value to true will disable the ability to use `zip_deploy_file` which currently relies on the default publishing profile.

* `website_content_share_over_vnet_enabled` - (Optional) Should the traffic between the function app and the storage account be routed through the virtual network when Apps running in a Premium plan use a file share to store content? Defaults to `false`.

!> **Note:** This property will replace the `WEBSITE_CONTENTOVERVNET` in `app_setting`. `website_content_share_over_vnet_enabled` is the recommended one despite both settings work currently.

* `zip_deploy_file` - (Optional) The local path and filename of the Zip packaged application to deploy to this Linux Function App.

~> **Note:** Using this value requires either `WEBSITE_RUN_FROM_PACKAGE=1` or `SCM_DO_BUILD_DURING_DEPLOYMENT=true` to be set on the App in `app_settings`. Refer to the [Azure docs](https://learn.microsoft.com/en-us/azure/azure-functions/functions-deployment-technologies) for further details.
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/windows_function_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ The following arguments are supported:

~> **NOTE:** Setting this value to true will disable the ability to use `zip_deploy_file` which currently relies on the default publishing profile.

* `website_content_share_over_vnet_enabled` - (Optional) Should the traffic between the function app and the storage account be routed through the virtual network when Apps running in a Premium plan use a file share to store content? Defaults to `false`.

!> **Note:** This property will replace the `WEBSITE_CONTENTOVERVNET` in `app_setting`. `website_content_share_over_vnet_enabled` is the recommended one despite both settings work currently.

* `zip_deploy_file` - (Optional) The local path and filename of the Zip packaged application to deploy to this Windows Function App.

~> **Note:** Using this value requires `WEBSITE_RUN_FROM_PACKAGE=1` to be set on the App in `app_settings`. Refer to the [Azure docs](https://learn.microsoft.com/en-us/azure/azure-functions/functions-deployment-technologies) for further details.
Expand Down

0 comments on commit f808647

Please sign in to comment.