Skip to content

Commit ed25281

Browse files
authored
Update defaults for Node.js
1 parent 86bdbe1 commit ed25281

File tree

1 file changed

+11
-28
lines changed

1 file changed

+11
-28
lines changed

articles/azure-functions/create-first-function-cli-node.md

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Create a JavaScript function from the command line - Azure Functions
33
description: Learn how to create a JavaScript function from the command line, then publish the local Node.js project to serverless hosting in Azure Functions.
4-
ms.date: 03/08/2023
4+
ms.date: 12/15/2023
55
ms.topic: quickstart
66
ms.devlang: javascript
77
ms.custom: devx-track-azurecli, devx-track-azurepowershell, mode-api, devx-track-js
@@ -49,27 +49,20 @@ Before you begin, you must have the following prerequisites:
4949
In Azure Functions, a function project is a container for one or more individual functions that each responds to a specific trigger. All functions in a project share the same local and hosting configurations. In this section, you create a function project that contains a single function.
5050

5151
::: zone pivot="nodejs-model-v3"
52-
1. Run the `func init` command, as follows, to create a functions project in a folder named *LocalFunctionProj* with the specified runtime:
52+
1. In a suitable folder, run the [`func init`](functions-core-tools-reference.md#func-init) command, as follows, to create a JavaScript Node.js v3 project in the current folder:
5353

5454
```console
55-
func init LocalFunctionProj --javascript
55+
func init --javascript --model V3
5656
```
57-
58-
1. Navigate into the project folder:
59-
60-
```console
61-
cd LocalFunctionProj
62-
```
63-
64-
This folder contains various files for the project, including configurations files named [local.settings.json](functions-develop-local.md#local-settings-file) and [host.json](functions-host-json.md). Because *local.settings.json* can contain secrets downloaded from Azure, the file is excluded from source control by default in the *.gitignore* file.
57+
This folder now contains various files for the project, including configurations files named [local.settings.json](functions-develop-local.md#local-settings-file) and [host.json](functions-host-json.md). Because *local.settings.json* can contain secrets downloaded from Azure, the file is excluded from source control by default in the *.gitignore* file.
6558

6659
1. Add a function to your project by using the following command, where the `--name` argument is the unique name of your function (HttpExample) and the `--template` argument specifies the function's trigger (HTTP).
6760

6861
```console
6962
func new --name HttpExample --template "HTTP trigger" --authlevel "anonymous"
7063
```
7164

72-
`func new` creates a subfolder matching the function name that contains a code file appropriate to the project's chosen language and a configuration file named *function.json*.
65+
[`func new`](functions-core-tools-reference.md#func-new) creates a subfolder matching the function name that contains a code file appropriate to the project's chosen language and a configuration file named *function.json*.
7366

7467
You may find the [Azure Functions Core Tools reference](functions-core-tools-reference.md) helpful.
7568

@@ -96,30 +89,20 @@ Each binding requires a direction, a type, and a unique name. The HTTP trigger h
9689
::: zone-end
9790

9891
::: zone pivot="nodejs-model-v4"
99-
1. Run the `func init` command, as follows, to create a functions project in a folder named *LocalFunctionProj*:
100-
101-
```console
102-
func init LocalFunctionProj --model V4
103-
```
104-
You're then prompted to choose a worker runtime and a language - choose Node for the first and JavaScript for the second.
105-
106-
2. Navigate into the project folder:
92+
1. In a suitable folder, run the [`func init`](functions-core-tools-reference.md#func-init) command, as follows, to create a JavaScript Node.js v4 project in the current folder:
10793

10894
```console
109-
cd LocalFunctionProj
95+
func init --javascript
11096
```
11197

112-
This folder contains various files for the project, including configurations files named *local.settings.json* and *host.json*. Because *local.settings.json* can contain secrets downloaded from Azure, the file is excluded from source control by default in the *.gitignore* file.
98+
This folder now contains various files for the project, including configurations files named *local.settings.json* and *host.json*. Because *local.settings.json* can contain secrets downloaded from Azure, the file is excluded from source control by default in the *.gitignore* file. Required npm packages are also installed in *node_modules*.
11399

114-
3. Add a function to your project by using the following command:
100+
1. Add a function to your project by using the following command, where the `--name` argument is the unique name of your function (HttpExample) and the `--template` argument specifies the function's trigger (HTTP).
115101

116102
```console
117-
func new
118-
```
119-
120-
Choose the template for "HTTP trigger". You can keep the default name (*httpTrigger*) or give it a new name (*HttpExample*). Your function name must be unique, or you're asked to confirm if your intention is to replace an existing function.
103+
func new --name HttpExample --template "HTTP trigger" --authlevel "anonymous"
121104

122-
You can find the function you added in the *src/functions* directory.
105+
[`func new`](functions-core-tools-reference.md#func-new) creates a file named *HttpExample.js* in the *src/functions* directory, which contains your function's code.
123106

124107
4. Add Azure Storage connection information in *local.settings.json*.
125108
```json

0 commit comments

Comments
 (0)