You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/create-first-function-cli-python.md
+5-27
Original file line number
Diff line number
Diff line change
@@ -141,35 +141,13 @@ In this section, you create a function project and add an HTTP triggered functio
141
141
142
142
The environment now contains various files for the project, including configuration 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.
143
143
144
-
1. The file `function_app.py` can include all functions within your project. Open this file and replace the existing contents with the following code that defines an HTTP triggered function endpoint named `HttpExample`:
144
+
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).
logging.info('Python HTTP trigger function processed a request.')
155
-
156
-
name = req.params.get('name')
157
-
if not name:
158
-
try:
159
-
req_body = req.get_json()
160
-
except ValueError:
161
-
pass
162
-
else:
163
-
name = req_body.get('name')
164
-
165
-
if name:
166
-
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
167
-
else:
168
-
return func.HttpResponse(
169
-
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
170
-
status_code=200
171
-
)
146
+
```console
147
+
func new --name HttpExample --template "HTTP trigger" --authlevel "anonymous"
172
148
```
149
+
150
+
If prompted, choose the **ANONYMOUS** option. `func new` adds an HTTP trigger endpoint named `HttpExample` to the `function_app.py` file, which is accessible without authentication.
173
151
174
152
1. Open the local.settings.json project file and verify that the `AzureWebJobsFeatureFlags` setting has a value of `EnableWorkerIndexing`. This is required for Functions to interpret your project correctly as the Python v2 model. You'll add this same setting to your application settings after you publish your project to Azure.
0 commit comments