Skip to content

Commit 052f8e1

Browse files
authored
Merge pull request #122609 from ankardon/correct-python-db-article
correct python code for db-connected function app
2 parents 1e8acbf + d4db44f commit 052f8e1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

articles/azure-functions/functions-add-output-binding-azure-sql-vs-code.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,16 @@ Update *HttpExample\\function_app.py* to match the following code. Add the `toDo
223223
import azure.functions as func
224224
import logging
225225
from azure.functions.decorators.core import DataType
226+
import uuid
226227

227228
app = func.FunctionApp()
228229

229230
@app.function_name(name="HttpTrigger1")
230231
@app.route(route="hello", auth_level=func.AuthLevel.ANONYMOUS)
231-
@app.generic_output_binding(arg_name="toDoItems", type="sql", CommandText="dbo.ToDo", ConnectionStringSetting="SqlConnectionString"
232-
data_type=DataType.STRING)
232+
@app.generic_output_binding(arg_name="toDoItems", type="sql", CommandText="dbo.ToDo", ConnectionStringSetting="SqlConnectionString",data_type=DataType.STRING)
233233
def test_function(req: func.HttpRequest, toDoItems: func.Out[func.SqlRow]) -> func.HttpResponse:
234234
logging.info('Python HTTP trigger function processed a request.')
235-
name = req.params.get('name')
235+
name = req.get_json().get('name')
236236
if not name:
237237
try:
238238
req_body = req.get_json()
@@ -242,7 +242,7 @@ def test_function(req: func.HttpRequest, toDoItems: func.Out[func.SqlRow]) -> fu
242242
name = req_body.get('name')
243243

244244
if name:
245-
toDoItems.set(func.SqlRow({"id": uuid.uuid4(), "title": name, "completed": false, url: ""}))
245+
toDoItems.set(func.SqlRow({"Id": str(uuid.uuid4()), "title": name, "completed": False, "url": ""}))
246246
return func.HttpResponse(f"Hello {name}!")
247247
else:
248248
return func.HttpResponse(

0 commit comments

Comments
 (0)