serverless / serverless-azure-functions

Serverless Azure Functions Plugin – Add Azure Functions support to the Serverless Framework
MIT License
266 stars 162 forks source link

Add support for Azure Functions v4 #592

Open sathishmohan-ps opened 2 years ago

sathishmohan-ps commented 2 years ago

This is a Feature Proposal

Description

Microsoft team launched Azure Functions 4.0 (GA) across Windows and Linux back in November, 2021. Could you please add support for latest version. serverless-azure-functions plugin allows us to deploy azure functions v3.5.2. We couldn't able to move to the latest version.

marcelvandesteeg commented 2 years ago

What would be required to implement this and add support for .NET 6?

VictorioBerra commented 2 years ago

I would also like to see this.

mwesigab commented 2 years ago

Waiting on this one too.

gligorkot commented 2 years ago

Following - we're wanting to use v4 as well for Node 16 support.

stefan-h-singer commented 2 years ago

Azure is ending support for Node12 soon, but using serverless-azure-functions we cannot upgrade our project to Node16. Is anyone working on this?

pgrzesik commented 2 years ago

Hello folks, I’ve recently got access to this project and in the coming weeks I will try to investigate this issue (among a few other open initiatives). If you have any insights about this particular feature, please share it, it will be much appreciated 🙇

kevin-boutin commented 2 years ago

@stefan-h-singer it's a pretty easy thing to change. There is a pull request for nodejs14 that will get you a start.

pgrzesik commented 2 years ago

Hello folks 👋 I started digging a bit and it seems like it's possible to use v4 even in the current version. It looks like it's not documented though 😓 You can do so by setting functionApp.extensionVersion on provider like this:

provider:
  name: azure
  functionApp:
    extensionVersion: '~4'

It worked without issues for me, but you might want to first test it out on non-prod environment. In the next major version of the plugin it should be set to ~4 by default.

kevin-boutin commented 2 years ago

Hello folks 👋 I started digging a bit and it seems like it's possible to use v4 even in the current version. It looks like it's not documented though 😓 You can do so by setting functionApp.extensionVersion on provider like this:

provider:
  name: azure
  functionApp:
    extensionVersion: '~4'

It worked without issues for me, but you might want to first test it out on non-prod environment. In the next major version of the plugin it should be set to ~4 by default.

I can confirm this does work. I've been doing this for months now.

gligorkot commented 1 year ago

@pgrzesik do you know if there's any maintainers of this project? You were the last one to comment so just checking :)

meet-fw commented 1 year ago

This solution works with runtime: nodejs14, The current maintainers are not accepting changes so If you want to use runtime: nodejs16 or runtime: nodejs18 then I'll recommend forking the package or implementing patch-package module which I did and make following changes to it:

diff --git a/node_modules/serverless-azure-functions/lib/config/runtime.d.ts b/node_modules/serverless-azure-functions/lib/config/runtime.d.ts
index 0a95c59..a7743a3 100644
--- a/node_modules/serverless-azure-functions/lib/config/runtime.d.ts
+++ b/node_modules/serverless-azure-functions/lib/config/runtime.d.ts
@@ -2,6 +2,7 @@ export declare enum Runtime {
     NODE10 = "nodejs10",
     NODE12 = "nodejs12",
     NODE14 = "nodejs14",
+    NODE16 = "nodejs16",
     PYTHON36 = "python3.6",
     PYTHON37 = "python3.7",
     PYTHON38 = "python3.8",
@@ -35,6 +36,7 @@ export declare const dockerImages: {
     nodejs10: string;
     nodejs12: string;
     nodejs14: string;
+    nodejs16: string;
     "python3.6": string;
     "python3.7": string;
     "python3.8": string;
diff --git a/node_modules/serverless-azure-functions/lib/config/runtime.js b/node_modules/serverless-azure-functions/lib/config/runtime.js
index 6b8c5a0..fc86cfd 100644
--- a/node_modules/serverless-azure-functions/lib/config/runtime.js
+++ b/node_modules/serverless-azure-functions/lib/config/runtime.js
@@ -15,6 +15,7 @@ var Runtime;
     Runtime["NODE10"] = "nodejs10";
     Runtime["NODE12"] = "nodejs12";
     Runtime["NODE14"] = "nodejs14";
+    Runtime["NODE16"] = "nodejs16";
     Runtime["PYTHON36"] = "python3.6";
     Runtime["PYTHON37"] = "python3.7";
     Runtime["PYTHON38"] = "python3.8";
@@ -25,6 +26,7 @@ exports.supportedRuntimes = [
     Runtime.NODE10,
     Runtime.NODE12,
     Runtime.NODE14,
+    Runtime.NODE16,
     Runtime.PYTHON36,
     Runtime.PYTHON37,
     Runtime.PYTHON38,
@@ -121,6 +123,7 @@ exports.dockerImages = {
     nodejs10: "NODE|10",
     nodejs12: "NODE|12",
     nodejs14: "NODE|14",
+    nodejs16: "NODE|16",
     "python3.6": "PYTHON|3.6",
     "python3.7": "PYTHON|3.7",
     "python3.8": "PYTHON|3.8",
gligorkot commented 1 year ago

@meet-fw if you use the master branch, it actually has node 16 and node 18 support merged in already, just no new release tagged just yet.

You can use this in package.json for your dependency (obviously need to be careful if the master branch moves, but you can always fork it at the current spot and use it from your forked repo):

"serverless-plugin-optimize": "github:serverless/serverless-azure-functions.git#master",