azure-webjobs-sdk-extensions: Query parameter not resolved in SqlQuery statement

Users want to get a query parameter to resolve in a CosmosDB input binding expression:

"SELECT * FROM c.users WHERE c.CustomerId like {Query.customerId}

But it doesn’t work per this: https://github.com/Azure/azure-functions-host/issues/2554#issuecomment-392084583

Would be good to support for consistency with other bindings

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 6
  • Comments: 15 (2 by maintainers)

Most upvoted comments

@jeffhollan It’s been a while since first raised via https://github.com/Azure/azure-functions-host/issues/2554 but customers running into it from time to time still… Workarounds:

  • Use route paths
  • Bind to DocumentClient
  • Maintain your own static DocumentClient instance…

None are as nice as Query Params if Query Params is your project’s default though

I was trying hard to find answers and just figure out it has bee fixed already. User can just refer to the query parameter use its key in sqlQuery as route parameter. No need “Query.” prefix.

say http://yourapi/a/b/c?myparam=myid

“sqlQuery”: “SELECT * FROM c WHERE c.id = {myparam}”

I don’t find a document tell this, or anyone come here to close the ticket, that’s terrible…

Neither SqlQuery = "SELECT * FROM c WHERE c.User = {Query.user}" nor SqlQuery = "SELECT * FROM c WHERE c.User = {user}" worked with an url of http://yourapi/a?user=myid. I’m using the latest SDK, Microsoft.Azure.WebJobs.Extensions.CosmosDB 3.0.10. Route path is still the way to go.