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_linux_function_app, azurerm_linux_function_app_slot - support for the vnet_image_pull_enabled property. #25249

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5bf320a
adding vnetImagePullEnabled property to linux function app
xiaxyi Mar 14, 2024
4fa4d96
change the default value for ase
xiaxyi Mar 18, 2024
206124e
fix error
xiaxyi Mar 18, 2024
4f7253b
update customize diff func
xiaxyi Mar 18, 2024
62d0f52
update for ase
xiaxyi Mar 19, 2024
f444765
Merge remote-tracking branch 'upstream/main' into appService/addVnetP…
xiaxyi Mar 26, 2024
d958e2c
Merge remote-tracking branch 'upstream/main' into appservice/addVnetP…
xiaxyi Mar 29, 2024
cbbaee5
Merge remote-tracking branch 'upstream/main' into appservice/addVnetP…
xiaxyi Apr 2, 2024
585746d
update test cases to remove the vnetimagepull property
xiaxyi Apr 3, 2024
b3a8079
add 4.0 flag and windows function apps
xiaxyi Apr 3, 2024
c94b55d
fix fmt
xiaxyi Apr 3, 2024
5a6cdf1
fix wrong type issue
xiaxyi Apr 3, 2024
805288d
Merge remote-tracking branch 'upstream/main' into appService/addVnetP…
xiaxyi Apr 5, 2024
e83ec27
fix 4.0 comment for linux function app
xiaxyi Apr 5, 2024
7b5dd68
merging
xiaxyi Apr 5, 2024
36b4b3e
update commit and test case per reviewer's comments
xiaxyi Apr 5, 2024
552e769
sorting imports
xiaxyi Apr 5, 2024
99d5023
fmt
xiaxyi Apr 5, 2024
472f314
Merge remote-tracking branch 'upstream/main' into appservice/addVnetP…
xiaxyi May 28, 2024
1c36adb
add new test cases for the vnet_image_pull_enable property with 4.0 f…
xiaxyi May 30, 2024
ca319a5
Merge remote-tracking branch 'upstream/main' into appservice/addVnetP…
xiaxyi May 30, 2024
caa7c04
Merge remote-tracking branch 'origin/appService/addVnetProperties' in…
xiaxyi May 31, 2024
432dfe5
add 4.0 flag for test cases based on the reviewer's comments
xiaxyi May 31, 2024
a1fa339
add unparam linter
xiaxyi May 31, 2024
4ee6865
Merge remote-tracking branch 'upstream/main' into appservice/addVnetP…
xiaxyi May 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions internal/services/appservice/linux_function_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type LinuxFunctionAppModel struct {
StorageAccounts []helpers.StorageAccount `tfschema:"storage_account"`
Tags map[string]string `tfschema:"tags"`
VirtualNetworkSubnetID string `tfschema:"virtual_network_subnet_id"`
VnetImagePullEnabled bool `tfschema:"vnet_image_pull_enabled"` // Not supported on Consumption plans
ZipDeployFile string `tfschema:"zip_deploy_file"`
PublishingDeployBasicAuthEnabled bool `tfschema:"webdeploy_publish_basic_authentication_enabled"`
PublishingFTPBasicAuthEnabled bool `tfschema:"ftp_publish_basic_authentication_enabled"`
Expand Down Expand Up @@ -297,6 +298,13 @@ func (r LinuxFunctionAppResource) Arguments() map[string]*pluginsdk.Schema {
ValidateFunc: commonids.ValidateSubnetID,
},

"vnet_image_pull_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
Description: "Is container image pull over virtual network enabled? Defaults to `false`.",
},

"zip_deploy_file": {
Type: pluginsdk.TypeString,
Optional: true,
Expand Down Expand Up @@ -523,6 +531,7 @@ func (r LinuxFunctionAppResource) Create() sdk.ResourceFunc {
ClientCertMode: pointer.To(webapps.ClientCertMode(functionApp.ClientCertMode)),
DailyMemoryTimeQuota: pointer.To(functionApp.DailyMemoryTimeQuota), // TODO - Investigate, setting appears silently ignored on Linux Function Apps?
VnetRouteAllEnabled: siteConfig.VnetRouteAllEnabled,
VnetImagePullEnabled: pointer.To(functionApp.VnetImagePullEnabled),
},
}

Expand Down Expand Up @@ -763,6 +772,7 @@ func (r LinuxFunctionAppResource) Read() sdk.ResourceFunc {
state.CustomDomainVerificationId = pointer.From(props.CustomDomainVerificationId)
state.DefaultHostname = pointer.From(props.DefaultHostName)
state.PublicNetworkAccess = !strings.EqualFold(pointer.From(props.PublicNetworkAccess), helpers.PublicNetworkAccessDisabled)
state.VnetImagePullEnabled = pointer.From(props.VnetImagePullEnabled)

servicePlanId, err := commonids.ParseAppServicePlanIDInsensitively(*props.ServerFarmId)
if err != nil {
Expand Down Expand Up @@ -929,6 +939,10 @@ func (r LinuxFunctionAppResource) Update() sdk.ResourceFunc {
}
}

if metadata.ResourceData.HasChange("vnet_image_pull_enabled") {
model.Properties.VnetImagePullEnabled = pointer.To(state.VnetImagePullEnabled)
}

if metadata.ResourceData.HasChange("client_certificate_enabled") {
model.Properties.ClientCertEnabled = pointer.To(state.ClientCertEnabled)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3315,6 +3315,7 @@ resource "azurerm_linux_function_app" "test" {

ftp_publish_basic_authentication_enabled = false
webdeploy_publish_basic_authentication_enabled = false
vnet_image_pull_enabled = true

tags = {
terraform = "true"
Expand Down Expand Up @@ -3462,6 +3463,8 @@ resource "azurerm_linux_function_app" "test" {

vnet_route_all_enabled = true
}
vnet_image_pull_enabled = true

}
`, r.storageContainerTemplate(data, SkuElasticPremiumPlan), data.RandomInteger)
}
Expand Down Expand Up @@ -4154,6 +4157,7 @@ resource "azurerm_linux_function_app" "test" {
service_plan_id = azurerm_service_plan.test.id
virtual_network_subnet_id = azurerm_subnet.test1.id

vnet_image_pull_enabled = true
storage_account_name = azurerm_storage_account.test.name
storage_account_access_key = azurerm_storage_account.test.primary_access_key

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type LinuxFunctionAppSlotModel struct {
SiteConfig []helpers.SiteConfigLinuxFunctionAppSlot `tfschema:"site_config"`
Tags map[string]string `tfschema:"tags"`
VirtualNetworkSubnetID string `tfschema:"virtual_network_subnet_id"`
VnetImagePullEnabled bool `tfschema:"vnet_image_pull_enabled"` // Not supported on Consumption plans
CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
HostingEnvId string `tfschema:"hosting_environment_id"`
DefaultHostname string `tfschema:"default_hostname"`
Expand Down Expand Up @@ -280,6 +281,13 @@ func (r LinuxFunctionAppSlotResource) Arguments() map[string]*pluginsdk.Schema {
Optional: true,
ValidateFunc: commonids.ValidateSubnetID,
},

"vnet_image_pull_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
Description: "Is container image pull over virtual network enabled? Defaults to `false`.",
},
}
}

Expand Down Expand Up @@ -517,6 +525,7 @@ func (r LinuxFunctionAppSlotResource) Create() sdk.ResourceFunc {
ClientCertMode: pointer.To(webapps.ClientCertMode(functionAppSlot.ClientCertMode)),
DailyMemoryTimeQuota: pointer.To(functionAppSlot.DailyMemoryTimeQuota),
VnetRouteAllEnabled: siteConfig.VnetRouteAllEnabled, // (@jackofallops) - Value appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681
VnetImagePullEnabled: pointer.To(functionAppSlot.VnetImagePullEnabled),
},
}

Expand Down Expand Up @@ -735,6 +744,7 @@ func (r LinuxFunctionAppSlotResource) Read() sdk.ResourceFunc {
state.CustomDomainVerificationId = pointer.From(props.CustomDomainVerificationId)
state.DefaultHostname = pointer.From(props.DefaultHostName)
state.PublicNetworkAccess = !strings.EqualFold(pointer.From(props.PublicNetworkAccess), helpers.PublicNetworkAccessDisabled)
state.VnetImagePullEnabled = pointer.From(props.VnetImagePullEnabled)

if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
state.HostingEnvId = pointer.From(hostingEnv.Id)
Expand Down Expand Up @@ -923,6 +933,10 @@ func (r LinuxFunctionAppSlotResource) Update() sdk.ResourceFunc {
}
}

if metadata.ResourceData.HasChange("vnet_image_pull_enabled") {
model.Properties.VnetImagePullEnabled = pointer.To(state.VnetImagePullEnabled)
}

storageString := state.StorageAccountName
if !state.StorageUsesMSI {
if state.StorageKeyVaultSecretID != "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2461,6 +2461,8 @@ resource "azurerm_linux_function_app_slot" "test" {
vnet_route_all_enabled = true
}

vnet_image_pull_enabled = true

tags = {
terraform = "true"
Env = "AccTest"
Expand Down Expand Up @@ -2502,6 +2504,9 @@ resource "azurerm_linux_function_app_slot" "test" {
virtual_network_subnet_id = azurerm_subnet.test.id
}
}

vnet_image_pull_enabled = true

}
`, r.template(data, planSku), data.RandomInteger)
}
Expand Down Expand Up @@ -2640,6 +2645,7 @@ resource "azurerm_linux_function_app_slot" "test" {

vnet_route_all_enabled = true
}
vnet_image_pull_enabled = true
}
`, r.storageContainerTemplate(data, SkuElasticPremiumPlan), data.RandomInteger)
}
Expand Down Expand Up @@ -3226,6 +3232,8 @@ resource "azurerm_linux_function_app_slot" "test" {
storage_account_access_key = azurerm_storage_account.test.primary_access_key

site_config {}

vnet_image_pull_enabled = true
}

`, r.template(data, planSku), data.RandomInteger, data.RandomInteger)
Expand Down Expand Up @@ -3286,6 +3294,9 @@ resource "azurerm_linux_function_app_slot" "test" {
virtual_network_subnet_id = azurerm_subnet.test1.id

site_config {}

vnet_image_pull_enabled = true

}
`, r.template(data, planSku), data.RandomInteger, data.RandomInteger)
}
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 @@ -139,6 +139,10 @@ The following arguments are supported:

~> **Note:** Assigning the `virtual_network_subnet_id` property requires [RBAC permissions on the subnet](https://docs.microsoft.com/en-us/azure/app-service/overview-vnet-integration#permissions)

* `vnet_image_pull_enabled` - (Optional) Should the traffic for the image pull be routed over virtual network enabled. Defaults to `false`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rephrase this to

Suggested change
* `vnet_image_pull_enabled` - (Optional) Should the traffic for the image pull be routed over virtual network enabled. Defaults to `false`.
* `vnet_image_pull_enabled` - (Optional) Specifies whether traffic for the image pull should be routed over virtual network. Defaults to `false`.


~> **Note:** The feature can also be enabled via the app setting `WEBSITE_PULL_IMAGE_OVER_VNET`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when a user sets this through the app settings block. Will they get a diff? Also what is the behaviour vice versa?

It looks like this property might need to be managed like WEBSITE_VNET_ROUTE_ALL/vnet_route_all_enabled


* `webdeploy_publish_basic_authentication_enabled` - (Optional) Should the default WebDeploy Basic Authentication publishing credentials enabled. Defaults to `true`.

~> **NOTE:** Setting this value to true will disable the ability to use `zip_deploy_file` which currently relies on the default publishing profile.
Expand Down
6 changes: 5 additions & 1 deletion website/docs/r/linux_function_app_slot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ The following arguments are supported:
~> **NOTE on regional virtual network integration:** The AzureRM Terraform provider provides regional virtual network integration via the standalone resource [app_service_virtual_network_swift_connection](app_service_virtual_network_swift_connection.html) and in-line within this resource using the `virtual_network_subnet_id` property. You cannot use both methods simultaneously. If the virtual network is set via the resource `app_service_virtual_network_swift_connection` then `ignore_changes` should be used in the function app slot configuration.

~> **Note:** Assigning the `virtual_network_subnet_id` property requires [RBAC permissions on the subnet](https://docs.microsoft.com/en-us/azure/app-service/overview-vnet-integration#permissions)


* `vnet_image_pull_enabled` - (Optional) Should the traffic for the image pull be routed over virtual network enabled. Defaults to `false`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `vnet_image_pull_enabled` - (Optional) Should the traffic for the image pull be routed over virtual network enabled. Defaults to `false`.
* `vnet_image_pull_enabled` - (Optional) Specifies whether traffic for the image pull should be routed over virtual network. Defaults to `false`.


~> **Note:** The feature can also be enabled via the app setting `WEBSITE_PULL_IMAGE_OVER_VNET`.

* `webdeploy_publish_basic_authentication_enabled` - (Optional) Should the default WebDeploy Basic Authentication publishing credentials enabled. Defaults to `true`.

---
Expand Down
Loading