I am trying to run the Azure trigger function with Cosmos DB input binding. I would like the http trigger URL to include several parameters in the query string that are bound to the Cosmos database binding SQL query. I try to use the following bindings in function.json, but it does not work (the function does not even start):
{
"direction": "in",
"type": "httpTrigger",
"authLevel": "anonymous",
"name": "req",
"methods": [ "get" ],
"route": "users/{age=age?}/{gender=gender?}"
},
{
"direction": "in",
"type": "documentDB",
"name": "users",
"databaseName": "Database",
"collectionName": "Users",
"sqlQuery": "SELECT * FROM x where x.age = {age} and x.gender = {gender}",
"connection": "COSMOSDB_CONNECTION_STRING"
},
According to this answer, the route restriction is users/{age=age?}/{gender=gender?}valid for the web API and, in accordance with, you can use any web API route restriction with your parameters. Ultimately, I would like to make a GET request for an Azure function that looks like api/users?age=30&gender=male. How to do it?