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_function_app - fix regressions in function app storage #13580

Merged
merged 3 commits into from
Oct 5, 2021

Conversation

jackofallops
Copy link
Member

fixes #13536
fixes #13566

@jackofallops jackofallops added the service/functions Function Apps label Oct 1, 2021
@jackofallops jackofallops added this to the v2.80.0 milestone Oct 1, 2021
@jackofallops jackofallops requested a review from a team October 1, 2021 14:00
@jackofallops jackofallops self-assigned this Oct 1, 2021
@github-actions github-actions bot added the size/M label Oct 1, 2021
Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

LGTM! Just looking for a confirmation on one piece that is being removed

@@ -356,7 +350,7 @@ func getBasicFunctionAppAppSettings(d *pluginsdk.ResourceData, appServiceTier, e
// 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(d.Get("os_type").(string), "linux")) &&
(strings.EqualFold(appServiceTier, "dynamic") || strings.HasPrefix(strings.ToLower(appServiceTier), "elastic")) {
Copy link
Member

Choose a reason for hiding this comment

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

Just looking to confirm that we don't need to check for elastic anymore? Is there any chance someone has that still?

Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I know, Azure Files is only required for Consumption (Windows) and Elastic Premium (Windows / Linux). I think it is correct to leave this conditional expression as elastic. See also #13218 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi both, from the docs:

Only used when deploying to a Premium plan or to a Consumption plan running on Windows. Not supported for Consumptions plans running Linux.

I initially misinterpreted this as ElasticPremium also, however, this is actually App Service Premium Plans. For context see #13566.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is very confusing, but the Premium V2 / V3 of the App Service Plan and the Azure Functions Premium Plan are completely different services. The Premium Plan in this document refers to the latter.

If the File Share setting is added to the App Service Plan (Premium V2 / V3), the current working application may be lost. This is a very dangerous change and the application I manage is also affected.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is very confusing,

You are not wrong there. 🙃

The resource has always previously sent the content details for premium SKU's, and elasticpremium plans see here

The change in 2.77 was intended to align the resource behaviour with the docs, but appears to have created the issue in 13218 where these settings were being sent where they had previously not been. Are you reporting that the Premium plans did not get these settings as intended?

The other change in this PR addresses the change of setting for the share directory, which is a bug in the 2.77 implementation which attempted to maintain any existing value configured. (see 13536) If the property already exists in the Function App AppSettings, then it will be used and not added/created. Additionally this is intended to address a related bug whereby the provider created the share with a -content suffix that prevented proper operation of slots. This will also mean that if the share property is set for a Premium Plan, it will be honoured/maintained and not overwritten.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think your change in #13349 is correct. I actually created and tested the resource, and it behaved as intended. Isn't the only thing this PR needs to do is fix the problem of WEBSITE_CONTENTSHARE not being reused?

The only thing I would strongly argue is that the App Service Plan (Premium V2 / Premium V3) does not require Azure Files configuration. At least, when I tested using this branch's code against Azure Functions running on Premium V2, I saw that unnecessary Azure Files settings (WEBSITE_CONTENTSHARE and WEBSITE_CONTENTAZUREFILECONNECTIONSTRING) were added and the application was lost. I can share the definition if you want to reproduce it on your device.

In my opinion, for each tier (Consumption / App Service Plan / Premium Plan), the test cases need to be checked for the existence of WEBSITE_CONTENTSHARE and WEBSITE_CONTENTAZUREFILECONNECTIONSTRING.

The resource has always previously sent the content details for premium SKU's, and elasticpremium plans see here

Yes, that change will break your application if you are already using Premium V2 / V3. I have confirmed that it breaks with this comment. This buggy code has been fixed in v2.77.

Copy link
Contributor

Choose a reason for hiding this comment

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

As for #13566, it is different from this issue.

Azure Functions has an option to operate without File Share, so I think it's more appropriate to add a property (e.g. disabled_builtin_file_share or etc) to not auto-set WEBSITE_CONTENTSHARE and WEBSITE_CONTENTAZUREFILECONNECTIONSTRING.

https://docs.microsoft.com/en-us/azure/azure-functions/storage-considerations#create-an-app-without-azure-files

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for your insight @shibayan - I'm taking this back to the drawing board to work it back through...

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated to correct the behaviour for PremiumV2/V3 (i.e. not send) and added the reuse of an existing value if defined (in case users do have it defined). I believe this is going to be sufficient for this stage, as presently this resource is not usable since 2.77 because of the share recreation bug. I'm reticent to introduce another property at this stage that will further affect behaviour of the resource. Upon re-reading, I believe 13566 to be a symptom of the share recreation bug, so should be resolved by this PR in any case.

fwiw - I'm in the process of completely rewriting this resource for the beta / v3.0, so I've made notes for addressing this properly there. I'll also be speaking to the Service Team on this as soon as possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for the quick response. I've checked the changed code and I'm sure it works ideally with Provider v2.x.

@jackofallops
Copy link
Member Author

Tests looking OK, (2 transient / unrelated failures)
image

@jackofallops jackofallops merged commit be45d87 into main Oct 5, 2021
@jackofallops jackofallops deleted the b/function-app-linux-storage-regression branch October 5, 2021 15:19
jackofallops added a commit that referenced this pull request Oct 5, 2021
@github-actions
Copy link

github-actions bot commented Oct 8, 2021

This functionality has been released in v2.80.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!

@github-actions
Copy link

github-actions bot commented Nov 7, 2021

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants