I have the following json sent to an Azure Function App:
{
"a" : {
"nested" : {
"object" : "hello_world"
}
}
}
Within the function.json I would like to fetch a document based on the object value (hello_world in this example) :
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"post"
]
},
{
"type": "cosmosDB",
"direction": "in",
"name": "doc_in",
"databaseName": "my_db",
"collectionName": "my_collection",
"connectionStringSetting": "AZURE_COSMOS_DB_CONNECTION_STRING",
"sqlQuery": "SELECT * FROM my_db as db WHERE db.my_field = {a.nested.object}"
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
init.py
def main(req: func.HttpRequest, doc_in: func.In[func.Document]) -> func.HttpResponse:
if doc_in:
return func.HttpResponse(
json.dumps({"msg":"A document was found!"}),
status_code=200,
mimetype="application/json"
)
The SELECT * FROM my_db as db WHERE db.my_field = {a.nested.object} query does not work and return a HTTP 404 code and there's no much information in the documentation.
Does someone know how am I supposed to set the input json file into the cosmos query ?
req. Somehow you need to read from the JSON from the input parameter. I'm not sure if it's possible.departmentIdbeing on the first level of the JSON: learn.microsoft.com/en-us/azure/azure-functions/…