Skip to content

Commit 645a255

Browse files
committed
v4.x -> v4
also wow warning is a loud color. let's do note
1 parent 9c13102 commit 645a255

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

articles/azure-functions/functions-node-upgrade-v4.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
---
2-
title: Upgrade to Azure Functions Node.js programming model v4.x
3-
description: This article shows you how to upgrade your existing function apps running on version 3.x of the Node.js programming model to version 4.x.
2+
title: Upgrade to Azure Functions Node.js programming model v4
3+
description: This article shows you how to upgrade your existing function apps running on v3 of the Node.js programming model to v4.
44
ms.service: azure-functions
55
ms.date: 03/15/2023
66
ms.devlang: javascript, typescript
77
ms.topic: how-to
88
---
99

10-
# Upgrade to Azure Functions Node.js programming model v4.x
10+
# Upgrade to Azure Functions Node.js programming model v4
1111

12-
The Node.js programming model for Azure Functions defines how you author serverless code in JavaScript or TypeScript. The version of the programming model matches the version of the [`@azure/functions`](https://www.npmjs.com/package/@azure/functions) npm package that should be included with your app. This article discusses the differences between both versions and how to upgrade an existing v3.x app. If you want to create a brand new v4.x app, see the tutorial for either [VS Code](./create-first-function-cli-node.md) or [Azure Functions Core Tools](./create-first-function-vs-code-node.md).
12+
The Node.js programming model for Azure Functions defines how you author serverless code in JavaScript or TypeScript. The version of the programming model matches the version of the [`@azure/functions`](https://www.npmjs.com/package/@azure/functions) npm package that should be included with your app. This article discusses the differences between both versions and how to upgrade an existing v3 app. If you want to create a brand new v4 app, see the tutorial for either [VS Code](./create-first-function-cli-node.md) or [Azure Functions Core Tools](./create-first-function-vs-code-node.md).
1313

1414
> [!NOTE]
15-
> v4.x of the Node.js programming model is currently in public preview. This version number is _not_ the same thing as the Azure Functions [runtime version](./functions-versions.md), which is coincidentally using "4" as its latest major version. Lastly, you can't mix v3.x and v4.x of the programming models.
15+
> v4 of the Node.js programming model is currently in public preview. This version number is _not_ the same thing as the Azure Functions [runtime version](./functions-versions.md), which is coincidentally using "4" as its latest major version. Lastly, you can't mix v3 and v4 of the programming models.
1616
1717
## Motivation
1818

19-
v4.x was designed with the following goals in mind:
19+
v4 was designed with the following goals in mind:
2020

2121
- Provide a familiar and intuitive experience to Node.js developers
2222
- Make the file structure flexible with support for full customization
2323
- Switch to a code-centric approach for defining function configuration
2424

2525
## Prerequisites
2626

27-
Before you start upgrading your app, v4.x of the Node.js programming model is only supported with the following minimum versions:
27+
Before you start upgrading your app, v4 of the Node.js programming model is only supported with the following minimum versions:
2828

2929
- [`@azure/functions`](https://www.npmjs.com/package/@azure/functions) npm package v4.0.0-alpha.8+
3030
- [Node.js](https://nodejs.org/en/download/releases/) v18+
@@ -34,17 +34,17 @@ Before you start upgrading your app, v4.x of the Node.js programming model is on
3434

3535
## npm package
3636

37-
For the first time, the [`@azure/functions`](https://www.npmjs.com/package/@azure/functions) npm package contains the primary source code that backs the Node.js programming model for Azure Functions. Previously, that code shipped directly in Azure and the npm package only had the TypeScript types. Moving forward both JavaScript and TypeScript users need to include this package in their app. v3.x apps _can_ include the npm package, but it isn't required.
37+
For the first time, the [`@azure/functions`](https://www.npmjs.com/package/@azure/functions) npm package contains the primary source code that backs the Node.js programming model for Azure Functions. Previously, that code shipped directly in Azure and the npm package only had the TypeScript types. Moving forward both JavaScript and TypeScript users need to include this package in their app. v3 apps _can_ include the npm package, but it isn't required.
3838

3939
> [!TIP]
40-
> _**Action Item**_: Make sure the `@azure/functions` package is listed in the `dependencies` section (not `devDependencies`) of your `package.json` file. You can install v4.x with the command
40+
> _**Action Item**_: Make sure the `@azure/functions` package is listed in the `dependencies` section (not `devDependencies`) of your `package.json` file. You can install v4 with the command
4141
> ```
4242
> npm install @azure/functions@preview
4343
> ```
4444
4545
## App entry point
4646
47-
v4.x of the programming model lets you structure your code however you want. The only files you need at the root of your app are `host.json` and `package.json`. Otherwise, you define the file structure by setting the `main` field in your `package.json` file. The `main` field can be set to a single file or multiple files by using a [glob pattern](https://wikipedia.org/wiki/Glob_(programming)). Common values for the `main` field may be:
47+
v4 of the programming model lets you structure your code however you want. The only files you need at the root of your app are `host.json` and `package.json`. Otherwise, you define the file structure by setting the `main` field in your `package.json` file. The `main` field can be set to a single file or multiple files by using a [glob pattern](https://wikipedia.org/wiki/Glob_(programming)). Common values for the `main` field may be:
4848
- TypeScript
4949
- `dist/src/index.js`
5050
- `dist/src/functions/*.js`
@@ -57,7 +57,7 @@ v4.x of the programming model lets you structure your code however you want. The
5757
5858
## Order of arguments
5959
60-
The trigger input is now the first argument to your function handler instead of the invocation context. The invocation context, now the second argument, was simplified in v4.x and isn't as required as the trigger input - it can be left off if you aren't using it.
60+
The trigger input is now the first argument to your function handler instead of the invocation context. The invocation context, now the second argument, was simplified in v4 and isn't as required as the trigger input - it can be left off if you aren't using it.
6161
6262
> [!TIP]
6363
> _**Action Item**_: Switch the order of your arguments. For example if you are using an http trigger, switch `(context, request)` to either `(request, context)` or just `(request)` if you aren't using the context.
@@ -67,9 +67,9 @@ The trigger input is now the first argument to your function handler instead of
6767
Say goodbye 👋 to `function.json` files! All of the configuration that you were previously specifying in a `function.json` file is now defined directly in your TypeScript or JavaScript files. In addition, many properties now have a default so that you don't have to specify them every time.
6868
6969
> [!WARNING]
70-
> You can't mix the v3.x and v4.x programming models. As soon as you register one v4.x function in your app, any v3.x functions registered in `function.json` files will be ignored.
70+
> You can't mix the v3 and v4 programming models. As soon as you register one v4 function in your app, any v3 functions registered in `function.json` files will be ignored.
7171
72-
# [v4.x](#tab/v4)
72+
# [v4](#tab/v4)
7373
7474
```javascript
7575
const { app } = require("@azure/functions");
@@ -90,7 +90,7 @@ app.http('helloWorld1', {
9090
9191
No `function.json` file! ✨
9292

93-
# [v3.x](#tab/v3)
93+
# [v3](#tab/v3)
9494

9595
```javascript
9696
module.exports = async function (context, req) {
@@ -142,18 +142,18 @@ The `context` object has been simplified to reduce duplication and make it easie
142142

143143
The primary input is also called the "trigger" and is the only required input or output. You must have one and only one trigger.
144144

145-
# [v4.x](#tab/v4)
145+
# [v4](#tab/v4)
146146

147-
v4.x only supports one way of getting the trigger input, as the first argument.
147+
v4 only supports one way of getting the trigger input, as the first argument.
148148

149149
```javascript
150150
async function helloWorld1(request, context) {
151151
const onlyOption = request;
152152
```
153153
154-
# [v3.x](#tab/v3)
154+
# [v3](#tab/v3)
155155
156-
v3.x supports several different ways of getting the trigger input.
156+
v3 supports several different ways of getting the trigger input.
157157
158158
```javascript
159159
async function helloWorld1(context, request) {
@@ -169,19 +169,19 @@ async function helloWorld1(context, request) {
169169
170170
### Setting the primary output
171171
172-
# [v4.x](#tab/v4)
172+
# [v4](#tab/v4)
173173
174-
v4.x only supports one way of setting the primary output, through the return value.
174+
v4 only supports one way of setting the primary output, through the return value.
175175
176176
```javascript
177177
return {
178178
body: `Hello, ${name}!`
179179
};
180180
```
181181
182-
# [v3.x](#tab/v3)
182+
# [v3](#tab/v3)
183183
184-
v3.x supports several different ways of setting the primary output.
184+
v3 supports several different ways of setting the primary output.
185185
186186
```javascript
187187
// Option 1
@@ -211,9 +211,9 @@ return {
211211
212212
### Create a test context
213213
214-
v3.x doesn't support creating an invocation context outside of the Azure Functions runtime, making it difficult to author unit tests. v4.x allows you to create an instance of the invocation context, although the information during tests isn't detailed unless you add it yourself.
214+
v3 doesn't support creating an invocation context outside of the Azure Functions runtime, making it difficult to author unit tests. v4 allows you to create an instance of the invocation context, although the information during tests isn't detailed unless you add it yourself.
215215
216-
# [v4.x](#tab/v4)
216+
# [v4](#tab/v4)
217217
218218
```javascript
219219
const testInvocationContext = new InvocationContext({
@@ -222,7 +222,7 @@ const testInvocationContext = new InvocationContext({
222222
});
223223
```
224224
225-
# [v3.x](#tab/v3)
225+
# [v3](#tab/v3)
226226
227227
Not possible 😮
228228
@@ -234,7 +234,7 @@ The http request and response types are now a subset of the [fetch standard](htt
234234
235235
### HttpRequest
236236
237-
# [v4.x](#tab/v4)
237+
# [v4](#tab/v4)
238238
- _**Body**_. You can access the body using a method specific to the type you would like to receive:
239239
```javascript
240240
const body = await request.text();
@@ -252,7 +252,7 @@ The http request and response types are now a subset of the [fetch standard](htt
252252
const name = request.query.get('name');
253253
```
254254
255-
# [v3.x](#tab/v3)
255+
# [v3](#tab/v3)
256256
- _**Body**_. You can access the body in several ways, but the type returned isn't always consistent:
257257
```javascript
258258
// returns a string, object, or Buffer
@@ -278,7 +278,7 @@ The http request and response types are now a subset of the [fetch standard](htt
278278
279279
### HttpResponse
280280
281-
# [v4.x](#tab/v4)
281+
# [v4](#tab/v4)
282282
- _**Status**_:
283283
```javascript
284284
return { status: 200 };
@@ -299,7 +299,7 @@ The http request and response types are now a subset of the [fetch standard](htt
299299
};
300300
```
301301
302-
# [v3.x](#tab/v3)
302+
# [v3](#tab/v3)
303303
- _**Status**_. A status can be set in several different ways:
304304
```javascript
305305
context.res.status(200);

articles/azure-functions/functions-reference-node.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ zone_pivot_groups: functions-nodejs-model
1515
This guide is an introduction to developing Azure Functions using JavaScript or TypeScript. The article assumes that you've already read the [Azure Functions developer guide](functions-reference.md).
1616

1717
> [!IMPORTANT]
18-
> The content of this article changes based on your choice of the Node.js programming model in the selector at the top of this page. The version you choose should match the version of the [`@azure/functions`](https://www.npmjs.com/package/@azure/functions) npm package you are using in your app. If you do not have that package listed in your `package.json`, the default is v3.x. Learn more about the differences between v3.x and the new v4.x programming model in the [upgrade guide](./functions-node-upgrade-v4.md). v4.x is currently in public preview.
18+
> The content of this article changes based on your choice of the Node.js programming model in the selector at the top of this page. The version you choose should match the version of the [`@azure/functions`](https://www.npmjs.com/package/@azure/functions) npm package you are using in your app. If you do not have that package listed in your `package.json`, the default is v3. Learn more about the differences between v3 and the new v4 programming model in the [upgrade guide](./functions-node-upgrade-v4.md). v4 is currently in public preview.
1919
2020
As a JavaScript developer, you might also be interested in one of the following articles:
2121

@@ -27,7 +27,7 @@ As a JavaScript developer, you might also be interested in one of the following
2727

2828
The "programming model" as discussed in this article loosely represents the Node.js layer of Azure Functions. If you are authoring code in JavaScript or TypeScript, the code patterns you use are governed by the programming model. For example, it defines how you register a function, get a function's input, or interact with the invocation context. The programming model version is strictly tied to the version of the [`@azure/functions`](https://www.npmjs.com/package/@azure/functions) npm package and is _not_ the same thing as the Azure Functions [runtime version](./functions-versions.md), even if the major version numbers are coincidentally similar.
2929

30-
> [!WARNING]
30+
> [!NOTE]
3131
> You can only use one major version of the programming model at a time.
3232
3333
### Supported Versions
@@ -261,12 +261,12 @@ app.http('httpTrigger1', {
261261
});
262262
```
263263

264-
> [!WARNING]
265-
> You can't mix the v3.x and v4.x programming models. As soon as you register one v4.x function in your app, any v3.x functions registered in `function.json` files will be ignored.
264+
> [!NOTE]
265+
> You can't mix the v3 and v4 programming models. As soon as you register one v4 function in your app, any v3 functions registered in `function.json` files will be ignored.
266266
267267
## Inputs and outputs
268268

269-
Your function is required to have exactly one primary input called the trigger. It may also have secondary inputs, a primary output called the return output, and/or secondary outputs. Inputs and outputs are also referred to as bindings outside the context of the Node.js programming model. Before v4.x of the model, these bindings were configured in `function.json` files.
269+
Your function is required to have exactly one primary input called the trigger. It may also have secondary inputs, a primary output called the return output, and/or secondary outputs. Inputs and outputs are also referred to as bindings outside the context of the Node.js programming model. Before v4 of the model, these bindings were configured in `function.json` files.
270270

271271
### Trigger input
272272

0 commit comments

Comments
 (0)