10
10
@app .generic_trigger (arg_name = "req" , type = "httpTrigger" , route = "sql_input/{productid}" )
11
11
@app .generic_output_binding (arg_name = "$return" , type = "http" )
12
12
@app .generic_input_binding (arg_name = "products" , type = "sql" ,
13
- command_text = "SELECT * FROM Products WHERE ProductId = @ProductId" ,
14
- command_type = "Text" ,
15
- parameters = "@ProductId={productid}"
16
- connection_string_setting = "AzureWebJobsSqlConnectionString" )
13
+ command_text = "SELECT * FROM Products"
14
+ "WHERE ProductId = @ProductId" ,
15
+ command_type = "Text" ,
16
+ parameters = "@ProductId={productid}" ,
17
+ connection_string_setting = "AzureWebJobsSqlConnectionString" )
17
18
def sql_input (req : func .HttpRequest , products : func .SqlRowList ) -> func .HttpResponse :
18
19
rows = list (map (lambda r : json .loads (r .to_json ()), products ))
19
20
@@ -23,14 +24,16 @@ def sql_input(req: func.HttpRequest, products: func.SqlRowList) -> func.HttpResp
23
24
mimetype = "application/json"
24
25
)
25
26
27
+
26
28
@app .generic_trigger (arg_name = "req" , type = "httpTrigger" , route = "sql_input2/{productid}" )
27
29
@app .generic_output_binding (arg_name = "$return" , type = "http" )
28
30
@app .generic_input_binding (arg_name = "products" , type = "sql" ,
29
- command_text = "SELECT * FROM Products2 WHERE ProductId = @ProductId" ,
30
- command_type = "Text" ,
31
- parameters = "@ProductId={productid}"
32
- connection_string_setting = "AzureWebJobsSqlConnectionString" )
33
- def sql_input (req : func .HttpRequest , products : func .SqlRowList ) -> func .HttpResponse :
31
+ command_text = "SELECT * FROM Products2 "
32
+ "WHERE ProductId = @ProductId" ,
33
+ command_type = "Text" ,
34
+ parameters = "@ProductId={productid}" ,
35
+ connection_string_setting = "AzureWebJobsSqlConnectionString" )
36
+ def sql_input2 (req : func .HttpRequest , products : func .SqlRowList ) -> func .HttpResponse :
34
37
rows = list (map (lambda r : json .loads (r .to_json ()), products ))
35
38
36
39
return func .HttpResponse (
@@ -39,12 +42,15 @@ def sql_input(req: func.HttpRequest, products: func.SqlRowList) -> func.HttpResp
39
42
mimetype = "application/json"
40
43
)
41
44
45
+
42
46
@app .generic_trigger (arg_name = "req" , type = "httpTrigger" )
43
47
@app .generic_output_binding (arg_name = "$return" , type = "http" )
44
48
@app .generic_output_binding (arg_name = "r" , type = "sql" ,
45
- command_text = "[dbo].[Products]" ,
46
- connection_string_setting = "AzureWebJobsSqlConnectionString" )
47
- def sql_output (req : func .HttpRequest , product : func .Out [func .SqlRow ]) -> func .HttpResponse :
49
+ command_text = "[dbo].[Products]" ,
50
+ connection_string_setting = "AzureWebJobs"
51
+ "SqlConnectionString" )
52
+ def sql_output (req : func .HttpRequest , r : func .Out [func .SqlRow ]) \
53
+ -> func .HttpResponse :
48
54
body = json .loads (req .get_body ())
49
55
row = func .SqlRow .from_dict (body )
50
56
r .set (row )
@@ -55,13 +61,14 @@ def sql_output(req: func.HttpRequest, product: func.Out[func.SqlRow]) -> func.Ht
55
61
mimetype = "application/json"
56
62
)
57
63
64
+
58
65
@app .generic_trigger (arg_name = "changes" , type = "sqlTrigger" ,
59
- table_name = "Products" ,
60
- connection_string_setting = "AzureWebJobsSqlConnectionString" )
66
+ table_name = "Products" ,
67
+ connection_string_setting = "AzureWebJobsSqlConnectionString" )
61
68
@app .generic_output_binding (arg_name = "r" , type = "sql" ,
62
- command_text = "[dbo].[Products2]" ,
63
- connection_string_setting = "AzureWebJobsSqlConnectionString" )
69
+ command_text = "[dbo].[Products2]" ,
70
+ connection_string_setting = "AzureWebJobsSqlConnectionString" )
64
71
def sql_trigger (changes , r : func .Out [func .SqlRow ]) -> str :
65
72
row = func .SqlRow .from_dict (json .loads (changes )[0 ]["Item" ])
66
73
r .set (row )
67
- return "OK"
74
+ return "OK"
0 commit comments