I have an Azure-Function with the following configuration
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "cosmosDB",
"name": "inputDocument",
"databaseName": "MeasureInputData",
"collectionName": "hubs",
"connectionStringSetting": "measure-cosmosdb_DOCUMENTDB",
"direction": "in",
"sqlQuery": "SELECT * FROM c WHERE c.uuid = {hub}"
}
],
"disabled": false
}
As you can see above, I have the {hub}
in the sqlQuery
passed as a url parameter.
Doing a request like
https://<my-function-url>?code=<my-function-key>&hub=<my-hub-id>
returns the matching hub.
If leaving the value <my-hub-id>
empty
https://<my-function-url>?code=<my-function-key>&hub=
returns an empty object.
The issue is when I don´t provide the hub
parameter in the URL the function crashes.
https://<my-function-url>?code=<my-function-key>
requesting the above returns http status code 500
Shouldn't missing query parameters be handled in some way?
Thanks
It seems the sql will be
SELECT * FROM c WHERE c.uuid =
but not
SELECT * FROM c WHERE c.uuid = "" or SELECT * FROM c WHERE c.uuid = null
when the parameter "hub" missing.
Azure function cosmos db binding will not handle the missing parameter in query. If you want to handle this error, I think we can create another api or function and put(call) the original function url in this new api/function. Then we can handle this error in the new api/function.
If you hope azure function to add this feature, you can raise your idea to the azure function feedback page.