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

Support for Azure Functions Flex Consumption #3551

Closed
nzthiago opened this issue Aug 30, 2024 · 11 comments
Closed

Support for Azure Functions Flex Consumption #3551

nzthiago opened this issue Aug 30, 2024 · 11 comments
Assignees
Labels
kind/enhancement Improvements or new features resolution/by-design This issue won't be fixed because the functionality is working as designed

Comments

@nzthiago
Copy link

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

Azure Functions has recently introduced a new hosting plan, called Flex Consumption. In Flex Consumption, many of the standard application settings and site configuration properties used in Bicep, ARM templates, and overall control plane are deprecated or have moved and shouldn't be used when automating function app resource creation. This is is documented here.

This plan's SKU tier is 'FlexConsumption' and name 'FC1'. There is also a brand new functionAppConfig section introduced to the site resource.

I am not sure if these changes break any existing support that Pulumi has for Azure Functions and if these changes need to be special cased for Pulumi to be used for creating Flex Consumption apps but raising this as a feature request for consideration. Happy to help with any questions on this.
 

@nzthiago nzthiago added kind/enhancement Improvements or new features needs-triage Needs attention from the triage team labels Aug 30, 2024
@TechWatching
Copy link

TechWatching commented Sep 2, 2024

@nzthiago Funny you ask, I've just created a Function App on the Flex Consumption plan using the Pulumi with the Azure Native provider and it worked perfectly. I took inspiration from the bicep sample on the Azure sample repository for Flex Consumption plan: the code looks the same, just typescript instead of bicep. The only thing needed was to use the specific version of the API where the new sections were added for the function app.

I intend to publish an article on my blog with the code in a couple of days. I don't know if you would also be interested in a PR on the sample repository you have on GitHub or if you just want to keep bicep and Terraform samples there.

@thomas11
Copy link
Contributor

thomas11 commented Sep 3, 2024

The only thing needed was to use the specific version of the API where the new sections were added for the function app.

Yes, this is the key. Since the functionality was recently added, it's not present in Pulumi's default API version for this resource, but you can import newer API versions. The syntax depends on your programming language, in TypeScript, for instance, it's import * as mysql from "@pulumi/azure-native/dbformysql/v20210501";.

@thomas11 thomas11 added resolution/by-design This issue won't be fixed because the functionality is working as designed and removed needs-triage Needs attention from the triage team labels Sep 3, 2024
@thomas11 thomas11 self-assigned this Sep 3, 2024
@nzthiago
Copy link
Author

nzthiago commented Sep 3, 2024

Thank you both! @TechWatching just to confirm you then deployed a function to the app and it worked end to end, you saw the functions in it and was able to trigger them?

I had a concern about a note I saw here that says The values for AzureWebJobsStorage and FUNCTIONS_EXTENSION_VERSION will be filled by other input arguments and shouldn't be configured separately. While AzureWebJobsStorage is still required, the FUNCTIONS_EXTENSION_VERSION is not anymore for Flex Consumption as it was replaced by a value inside functionAppConfig section in the runtime section. I was concerned this might cause some backend validation issue.

@TechWatching
Copy link

Yes, I created a new function app from a template with a basic HTTP trigger that says hello world, deployed it using the func cli, and sent an HTTP message to it to make sure it ran correctly. Everything worked correctly.

The documentation you mention is about the Azure Classic Provider, a different provider than the Azure Native provider (Azure Classic provider is this repository which is different from this repository. The Azure Classic provider is a bridge from Terraform AzureRM provider, so I guess that if it works fine with the Azure RM Terraform provider (which I don't know and I did not verify) it should also work with the Pulumi Azure Classic provider.

I made it work with the Azure Native provider (native meaning is generated directly from the Azure APIs, and as a consequence has a similar API as Bicep and contains all the API versions). The documentation for the Azure Native provider is here, but you won't see the new properties because the documentation only displays one API version (as far as I know, it's not possible on the documentation to see all the API versions, I don't know @thomas11 if it's something planned but that's something missing).

I will try to find some time very soon to publish my code to some GitHub repository and an article explaining how to implement a Function App on the Flex Consumption Plan using Azure Native provider.

@davidobrien1985
Copy link

@TechWatching I used import * as azure_native_web from "@pulumi/azure-native/web/v20231201"; to then create a Flex Consumption app like this.
new azure_native_web.WebApp(scanflex-fn,.....

@nzthiago is working with me to figure out why in my case for example AzureWebJobsStorage was not automatically set and the app is not launching as expected.

@TechWatching
Copy link

Here you go @davidobrien1985 👉 https://github.com/TechWatching/AzureFunctionsFlexConsumptionPlan
I'm using a system assigned Managed Identity with the data contributor role on the blob storage, so that might not be exactly the same case as yours. I have manually set the AzureWebJobsStorage__accountName setting,

To deploy the code, you have to be in the Function folder and run the command func azure functionapp publish "func-flexconsumption-dev******** (replace with the function app name coming from the functionAppName stack output)
To test everything is working correctly, make a get request on the functionEndpoint stack output.

@TechWatching
Copy link

@nzthiago @davidobrien1985 And here is the blog post: https://techwatching.dev/posts/flex-consumption-plan
I hope it can help you.

@nzthiago
Copy link
Author

nzthiago commented Sep 5, 2024

@TechWatching great write up! Thank you. I think for the purpose of this feature request (support Flex Consumption in Pulumi Azure Native) it seems to already be addressed we can close this issue. By the way, support for Azure RM Terraform provider is under development, but not quite there yet. Once it's out then it seems Pulumi Azure Classic will start working too.

@nzthiago nzthiago closed this as completed Sep 5, 2024
@flo-sch
Copy link

flo-sch commented Dec 4, 2024

Just wanted to say merci @TechWatching for taking the time to share this 💎

I also tried using SystemAssignedIdentity as authentication type for the deployment of a flex consumption functionapp (node runtime in my case)
The function was created successfully, and deployment worked, but could not trigger it since the host runtime was unhealthy.

Starting the function app deployment...
[...] Received Token using system assigned identity
Uploaded package to storage blob. Deployment is partially successful from here.
[...] Reset all workers was successful.
[...] Finished deployment pipeline.
FunctionHostSyncTrigger, statusCode = InternalServerError
Checking the app health...Deployment was successful but the app appears to be unhealthy, please check the app logs.

I landed here after a few hours of struggle, the AzureWebJobsStorage__accountName appSetting was the missing part, adding that fixes it.
Alternatively, setting AzureWebJobsStorage with a full connectionString to the storage account also works, even if not used by the rest of the configuration 🤷

@erwinkramer
Copy link

the FUNCTIONS_EXTENSION_VERSION is not anymore for Flex Consumption as it was replaced by a value inside functionAppConfig section in the runtime section.

@nzthiago

Removing FUNCTIONS_EXTENSION_VERSION breaks my function app with message We were not able to load some functions in the list due to errors. Refresh the page to try again. See details (no details). Just adding FUNCTIONS_EXTENSION_VERSION back again with value ~4 solves it.

This is not Pulumi related but just tested in Azure portal.

If you look at the docs here: https://learn.microsoft.com/en-us/azure/templates/microsoft.web/sites?pivots=deployment-language-bicep#functionsruntime - it specifies: Function app runtime version. Example: 8 (for dotnet-isolated) - but how is version 8 of dot net (which you should specify there) related to function runtime 4? There is no relation and thus FUNCTIONS_EXTENSION_VERSION is still needed (as i've proven by breaking it).

@erwinkramer
Copy link

added link here Azure/azure-functions-host#10714

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features resolution/by-design This issue won't be fixed because the functionality is working as designed
Projects
None yet
Development

No branches or pull requests

6 participants