1111# Learn more at aka.ms/pythonprogrammingmodel
1212
1313# The input binding executes the `SELECT * FROM Products WHERE Cost = @Cost` query.
14- # The Parameters argument passes the `{cost}` specified in the URL that triggers the function,
14+ # The parameters argument passes the `{cost}` specified in the URL that triggers the function,
1515# `getproducts/{cost}`, as the value of the `@Cost` parameter in the query.
16- # CommandType is set to `Text`, since the constructor argument of the binding is a raw query.
16+ # command_type is set to `Text`, since the constructor argument of the binding is a raw query.
1717@app .function_name (name = "GetProducts" )
1818@app .route (route = "getproducts/{cost}" )
19- @app .generic_input_binding (arg_name = "products" , type = "sql" ,
20- CommandText = "SELECT * FROM Products WHERE Cost = @Cost" ,
21- CommandType = "Text" ,
22- Parameters = "@Cost={cost}" ,
23- ConnectionStringSetting = "SqlConnectionString" ,
24- data_type = DataType .STRING )
19+ @app .sql_input (arg_name = "products" ,
20+ command_text = "SELECT * FROM Products WHERE Cost = @Cost" ,
21+ command_type = "Text" ,
22+ parameters = "@Cost={cost}" ,
23+ connection_string_setting = "SqlConnectionString" )
2524def get_products (req : func .HttpRequest , products : func .SqlRowList ) -> func .HttpResponse :
2625 rows = list (map (lambda r : json .loads (r .to_json ()), products ))
2726
@@ -36,10 +35,9 @@ def get_products(req: func.HttpRequest, products: func.SqlRowList) -> func.HttpR
3635# have the new name and cost.
3736@app .function_name (name = "AddProduct" )
3837@app .route (route = "addproduct" )
39- @app .generic_output_binding (arg_name = "product" , type = "sql" ,
40- CommandText = "[dbo].[Products]" ,
41- ConnectionStringSetting = "SqlConnectionString" ,
42- data_type = DataType .STRING )
38+ @app .sql_output (arg_name = "product" ,
39+ command_text = "[dbo].[Products]" ,
40+ connection_string_setting = "SqlConnectionString" )
4341def add_product (req : func .HttpRequest , product : func .Out [func .SqlRow ]) -> func .HttpResponse :
4442 body = json .loads (req .get_body ())
4543 row = func .SqlRow .from_dict (body )
@@ -54,9 +52,8 @@ def add_product(req: func.HttpRequest, product: func.Out[func.SqlRow]) -> func.H
5452# The function gets triggered when a change (Insert, Update, or Delete)
5553# is made to the Products table.
5654@app .function_name (name = "ProductsTrigger" )
57- @app .generic_trigger (arg_name = "products" , type = "sqlTrigger" ,
58- TableName = "Products" ,
59- ConnectionStringSetting = "SqlConnectionString" ,
60- data_type = DataType .STRING )
55+ @app .sql_trigger (arg_name = "products" ,
56+ table_name = "Products" ,
57+ connection_string_setting = "SqlConnectionString" )
6158def products_trigger (products : str ) -> None :
6259 logging .info ("SQL Changes: %s" , json .loads (products ))
0 commit comments