-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
function_app_resource can't deploy a function app with a backing storage account protected via private endpoint #10990
Comments
Had this recently and it's an Azure rather than terraform issue. It does mean you need a multi-stage approach to deployment though...
The reasoning is that when you deploy the function app telling it is on the vnet, it is not actually on the vnet yet - this confuses the Azure backplane |
Hi @phatcher that used to be the case, and I even wrote about it in the update to my post here: Azure Functions: use Blob Trigger with Private Endpoint. But since the introduction of the You can try the following Azure ARM template, created by @gabesmsft, to deploy a Function App, with VNET integration using a backing storage account protected via private endpoint, without issues https://github.com/cmendible/FunctionAppWithStorageEndpointsARM or you can build my version of the provider with the "dirty" fix (cmendible@bceefa4) and apply the provided terraform configuration and it'll deploy a Function App, as described, in one go and without issues. |
@cmendible Thanks for that, explains the behaviour I had - I spent a number of hours recently with MS support trying to get it to work. For Linux docker apps I found you also need the The changes should also be made on the slot resources as well. |
Yep those values are set here: by the provider when you set the following properties in the terraform configuration: storage_account_name = azurerm_storage_account.sa.name
storage_account_access_key = azurerm_storage_account.sa.primary_access_key also the value of |
The portal/arm template set I was also wondering whether the provider should support RBAC storage account access OOB rather than using the access key i.e. have it grant the |
I'm experiencing an issue deploying an azure function on ASE v3, and it seems again related to the way the provider set the parameters on the app as explained above. This is the error which is shown by the control plan of Azure when trying to deploy:
Useless to say WEBSITE_VNET_ROUTE_ALL is set to 1 in my terraform code Overall experience deploying Azure functions is terrible, someone really needs to look into it please |
It would be great if you could override those... I've been chasing ghosts until I noticed that TF is actually overriding my values there. Is this worth an own issue? |
The same issue exists with the |
…ng storage account protected via private endpoint hashicorp#10990
The PR I submitted ahould also help with this one. I'll try to add another ASAP. |
Did you create an issue for this one? |
I did not hence the question before I create some inflationary issue :) |
@cmendible Any idea when this fix will make it to the next version of the azurerm provider? |
waiting for @jackofallops's review on PR #14521 |
Hi @cmendible , Having further look, it seems the 2.77.0 had some updates around WEBSITE_CONTENTSHARE, WEBSITE_CONTENTAZUREFILECONNECTIONSTRING in the app settings. Wondering if the error in v2.89.0 around creation of file share are because of the changes introduced in 2.77.0 or something with the rbac on the azure files itself? |
Issue was not related to RBAC but with how the provider configures the Function App Settings. Values such as: WEBSITE_VNET_ROUTE_ALL = "1"
WEBSITE_CONTENTOVERVNET = "1" must be respected at creation time and that is being addressed here: #14638 |
ah okay. Thanks @cmendible |
This functionality has been released in v2.90.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
@cmendible Looks like the CONTENTSHARE value in the function app is no longer the function name appended with "-content". The latest version is appending a random GUID. Do you know how we can assign this value at the time the function app is provisioned? |
Hi @danielrobinson95 - the use of If you need to specifically use the |
Thanks for the reply @jackofallops. Unfortunately, this does not work. I've explicitly defined both |
@jackofallops I just retested on v2.91.0 and this is still not working. |
@jackofallops just tests provider v2.93.1 and this is not working. Setting WEBSITE_CONTENTSHARE is a must in order to deploy Azure Functions with a Private Endpoint protected Storage Account. I'll continue discussion here: #14167 |
WEBSITE_CONTENTSHARE seems only aupported by Windows workloads. How to get around this when using Linux workloads? https://docs.microsoft.com/en-us/azure/azure-functions/functions-app-settings#website_contentshare |
Works for both Windows & Linux. You can try the ARM / bicep configuration provided here: https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.web/function-app-storage-private-endpoints/main.bicep |
This still does not work for me, either using private endpoint or service endpoint restricting a specific VNet. It was working with AzureRM provider version 2.67.0 The functions are deployed with a linux App Service Plan: The functions are working fine, and deploy was successful with 2.67.0 (bith first deploy and subsequent updates). Could someone please look at this? |
Following for resolution, however I wanted to post some notes on what we saw as well.
Is it recommended to move to the OS specific versions of the the function_app resources or do those have similar issues? |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Terraform (and AzureRM Provider) Version
Terraform v0.13.5
Affected Resource(s)
function_app_resource
and possiblyapp_service_resource
Terraform Configuration Files
Using the configuration files found in this repo will result in and 403 error while trying to deploy the Azure Function: https://github.com/cmendible/azure.samples/tree/function_private_sa_403/function_sa_private_endpoint.v2/deploy
main.tf code:
Expected Behaviour
The Azure Function App should be deployed without issues when the backing storage account is protected via private endpoint
Actual Behaviour
The Azure Function App deployment fails with a 403 exception.
The problem is caused by the way
app_settings
are used by the provider. To be able to deploy an Azure Function connected to a backing storage account protected via private endpoint the followingapp_settings
must be set when the app is created:Current provider implementation only sets storage account (basic) related
app_settings
when creating the app:https://github.com/terraform-providers/terraform-provider-azurerm/blob/bb82a8e3c343add6abb011256779a619811cb954/azurerm/internal/services/web/function_app_resource.go#L298
That behavior blocks the correct deployment of the Function App. To prove it I created a fork and implemented a quick & dirty workaround : cmendible@bceefa4 expanding all
app_settings
before the function app is created. The resulting provider deployed the function app as expected.The question is why aren't the
app_settings
respected when the function is first deployed, but updated after creation? What would be the best way to fix this? Should we create variables for the 3 parameters shown above and make them part of the basic settings?Steps to Reproduce
terraform apply
Important Factoids
References
The text was updated successfully, but these errors were encountered: