Skip to content

Commit aafcea1

Browse files
committed
more feedback, including Pamela
1 parent fa1e7f2 commit aafcea1

File tree

1 file changed

+100
-32
lines changed

1 file changed

+100
-32
lines changed

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

Lines changed: 100 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ By default, the Flex Consumption plan follows a _pay-for-what-you-use_ billing m
4545
::: zone pivot="programming-language-python"
4646
+ [Python 3.11](https://www.python.org/).
4747
::: zone-end
48-
+ A secure HTTP test tool for sending HTTP GET and HTTP POST requests to your function endpoints. For more information, see [HTTP test tools](functions-develop-local.md#http-test-tools).
48+
+ A [secure HTTP test tool](functions-develop-local.md#http-test-tools) for sending HTTP GET and HTTP POST requests to your function endpoints. This article uses `curl`.
4949

5050
## Initialize the project
5151

@@ -58,9 +58,12 @@ You can use the `azd init` command to create a local Azure Functions code projec
5858
azd init --template functions-quickstart-dotnet-azd
5959
cd http
6060
```
61+
62+
This pulls the project files from the [template repository](https://github.com/Azure-Samples/functions-quickstart-dotnet-azd) and initializes the project in the current folder.
63+
6164
[!INCLUDE [functions-quickstart-azd-env](../../includes/functions-quickstart-azd-env.md)]
6265

63-
3. Create a file named _local.settings.json_ in the app's root folder (`/http`), and add this JSON data to the file:
66+
3. Create a file named _local.settings.json_ in the app folder (`http`) that contains this JSON data:
6467

6568
```json
6669
{
@@ -82,32 +85,47 @@ You can use the `azd init` command to create a local Azure Functions code projec
8285
cd http
8386
```
8487

88+
This pulls the project files from the [template repository](https://github.com/Azure-Samples/azure-functions-java-flex-consumption-azd) and initializes the project in the current folder.
89+
8590
[!INCLUDE [functions-quickstart-azd-env](../../includes/functions-quickstart-azd-env.md)]
8691

87-
3. Run this command in the app's root folder (`http`):
92+
3. Create a file named _local.settings.json_ in the app folder (`http`) that contains this JSON data:
8893

89-
```console
90-
func init --worker-runtime java
94+
```json
95+
{
96+
"IsEncrypted": false,
97+
"Values": {
98+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
99+
"FUNCTIONS_WORKER_RUNTIME": "java"
100+
}
101+
}
91102
```
92-
93-
This command restores the _local.settings.json_ file in the app's root folder (`http`), which is required when running locally.
103+
104+
This file is required when running locally.
94105
::: zone-end
95106
::: zone pivot="programming-language-javascript"
96107
1. In your local terminal or command prompt, run this `azd init` command in an empty folder:
97108
98109
```console
99110
azd init --template functions-quickstart-javascript-azd
100111
```
112+
This pulls the project files from the [template repository](https://github.com/Azure-Samples/functions-quickstart-javascript-azd) and initializes the project in the root folder.
101113

102114
[!INCLUDE [functions-quickstart-azd-env](../../includes/functions-quickstart-azd-env.md)]
103115

104-
3. Run this command in the root folder:
116+
3. Create a file named _local.settings.json_ in the root folder that contains this JSON data:
105117

106-
```console
107-
func init --worker-runtime javascript
118+
```json
119+
{
120+
"IsEncrypted": false,
121+
"Values": {
122+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
123+
"FUNCTIONS_WORKER_RUNTIME": "node"
124+
}
125+
}
108126
```
109127

110-
This command restores the _local.settings.json_ file in the root folder, which is required when running locally.
128+
This file is required when running locally.
111129
::: zone-end
112130
::: zone pivot="programming-language-powershell"
113131
1. In your local terminal or command prompt, run this `azd init` command in an empty folder:
@@ -116,43 +134,74 @@ You can use the `azd init` command to create a local Azure Functions code projec
116134
azd init --template functions-quickstart-powershell-azd
117135
cd src
118136
```
137+
This pulls the project files from the [template repository](https://github.com/Azure-Samples/functions-quickstart-powershell-azd) and initializes the project in the root folder.
119138

120139
[!INCLUDE [functions-quickstart-azd-env](../../includes/functions-quickstart-azd-env.md)]
121140

122-
3. Run this command in the app's root folder (`src`):
141+
3. Create a file named _local.settings.json_ in the app folder (`http`) that contains this JSON data:
123142

124-
```console
125-
func init --worker-runtime powershell
143+
```json
144+
{
145+
"IsEncrypted": false,
146+
"Values": {
147+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
148+
"FUNCTIONS_WORKER_RUNTIME": "powershell",
149+
"FUNCTIONS_WORKER_RUNTIME_VERSION": "7.2"
150+
}
151+
}
126152
```
127153

128-
This command restores the _local.settings.json_ file in the app's root folder (`src`), which is required when running locally.
154+
This file is required when running locally.
129155
::: zone-end
130156
::: zone pivot="programming-language-typescript"
131157
1. In your local terminal or command prompt, run this `azd init` command in an empty folder:
132158
133159
```console
134160
azd init --template functions-quickstart-typescript-azd
135161
```
162+
This pulls the project files from the [template repository](https://github.com/Azure-Samples/functions-quickstart-typescript-azd) and initializes the project in the root folder.
136163

137164
[!INCLUDE [functions-quickstart-azd-env](../../includes/functions-quickstart-azd-env.md)]
138165

139-
3. Run this command in the root folder:
166+
3. Create a file named _local.settings.json_ in the root folder that contains this JSON data:
140167

141-
```console
142-
func init --worker-runtime typescript
168+
```json
169+
{
170+
"IsEncrypted": false,
171+
"Values": {
172+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
173+
"FUNCTIONS_WORKER_RUNTIME": "node"
174+
}
175+
}
143176
```
144177

145-
This command restores the _local.settings.json_ file in the root folder, which is required when running locally.
178+
This file is required when running locally.
146179
::: zone-end
147180
::: zone pivot="programming-language-python"
148181
1. In your local terminal or command prompt, run this `azd init` command in an empty folder:
149182
150183
```console
151184
azd init --template functions-quickstart-python-http-azd
152185
```
186+
This pulls the project files from the [template repository](https://github.com/Azure-Samples/functions-quickstart-python-http-azd) and initializes the project in the root folder.
153187

154188
[!INCLUDE [functions-quickstart-azd-env](../../includes/functions-quickstart-azd-env.md)]
155189

190+
3. Create a file named _local.settings.json_ in the root folder that contains this JSON data:
191+
192+
```json
193+
{
194+
"IsEncrypted": false,
195+
"Values": {
196+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
197+
"FUNCTIONS_WORKER_RUNTIME": "python"
198+
}
199+
}
200+
```
201+
202+
This file is required when running locally.
203+
[!INCLUDE [functions-quickstart-azd-env](../../includes/functions-quickstart-azd-env.md)]
204+
156205
3. Run this command in the root folder:
157206

158207
```console
@@ -178,7 +227,14 @@ If Python didn't install the venv package on your Linux distribution, run the fo
178227
sudo apt-get install python3-venv
179228
```
180229

181-
### [Windows](#tab/windows)
230+
### [Windows (bash)](#tab/windows-bash)
231+
232+
```bash
233+
py -m venv .venv
234+
source .venv/scripts/activate
235+
```
236+
237+
### [Windows (Cmd)](#tab/windows-cmd)
182238

183239
```shell
184240
py -m venv .venv
@@ -191,7 +247,7 @@ py -m venv .venv
191247

192248
## Run in your local environment
193249

194-
1. Run this command from your project's root folder in a terminal or command prompt:
250+
1. Run this command from your app folder in a terminal or command prompt:
195251

196252
::: zone pivot="programming-language-csharp, programming-language-powershell,programming-language-python,programming-language-javascript"
197253
```console
@@ -212,15 +268,17 @@ py -m venv .venv
212268

213269
When the Azure Functions host starts in your local project folder, it displays the URL endpoints of the HTTP triggered functions in your project.
214270

215-
1. From your HTTP test tool in a new terminal (or from your browser), call the HTTP GET endpoint, which should look like this URL:
271+
1. In your browser, navigate to the `httpget` endpoint, which should look like this URL:
216272

217273
<http://localhost:7071/api/httpget>
218274

219-
1. From your HTTP test tool in a new terminal, send an HTTP POST request with a JSON payload like in this example:
275+
1. From a new terminal or command prompt window, run this `curl` to send an POST request with a JSON payload to the `httppost` endpoint:
220276

221-
:::code language="http" source="~/functions-quickstart-dotnet-azd/http/test.http" range="9-15" :::
277+
```console
278+
curl -i http://localhost:7071/api/httppost -H "Content-Type: text/json" -d @testdata.json
279+
```
222280

223-
You can find examples of both HTTP requests in the _test.http_ project file.
281+
This command reads JSON payload data from the `testdata.json` project file. You can find examples of both HTTP requests in the `test.http` project file.
224282

225283
1. When you're done, press Ctrl+C in the terminal window to stop the `func.exe` host process.
226284
::: zone pivot="programming-language-python"
@@ -316,21 +374,31 @@ This project is configured to use the `azd up` command to deploy this project to
316374

317375
+ Package and deploy your code to the deployment container (equivalent to [`azd deploy`](/azure/developer/azure-developer-cli/reference#azd-deploy)). The app is then started and runs in the deployed package.
318376

319-
1. After the command completes successfully, you see links to the resources created. Make a copy of the **Function App** name. If you forgot to save the app name, you can always get it again using the `azd env get-values` command and copying `AZURE_FUNCTION_NAME`.
377+
1. After the command completes successfully, you see links to the resources created.
320378

321379
## Invoke the function on Azure
322380

323381
You can now invoke your function endpoints in Azure by making HTTP requests to their URLs using your HTTP test tool or from the browser (for GET requests). When your functions run in Azure, access key authorization is enforced, and you must provide a function access key with your request.
324382

325-
You can use the Core Tools to obtain the URL endpoints of your functions running in Azure, along with their required access key values.
383+
You can use the Core Tools to obtain the URL endpoints of your functions running in Azure.
326384

327-
1. In your local terminal or command prompt, run this `func azure functionapp list-functions` command:
385+
1. In your local terminal or command prompt, run this command to get the URL endpoint values, including access keys:
328386
329-
```console
330-
func azure functionapp list-functions <APP_NAME> --show-keys
387+
### [bash](#tab/bash)
388+
389+
```bash
390+
SET APP_NAME=(azd env get-value AZURE_FUNCTION_NAME)
391+
func azure functionapp list-functions $APP_NAME --show-keys
392+
```
393+
394+
### [Cmd](#tab/bash)
395+
```cmd
396+
for /f "tokens=*" %i in ('azd env get-value AZURE_FUNCTION_NAME') do set APP_NAME=%i
397+
func azure functionapp list-functions %APP_NAME% --show-keys
331398
```
332-
333-
In this example, replace `<APP_NAME>` with the name of the function app created by azd during deployment. Using the `--show-keys` option means that the returned **Invoke URL:** value for each endpoint includes a function-level access key.
399+
---
400+
401+
The `azd env get-value` command gets your function app name from the local environment. Using the `--show-keys` option means that the returned **Invoke URL:** value for each endpoint includes a function-level access key.
334402

335403
1. As before, use your HTTP test tool to validate these URLs in your function app running in Azure.
336404

0 commit comments

Comments
 (0)