Azure function throws server error when running with a missing id for the Cosmos DB input binding
I'm currently working through the "Exercise - Read data with input bindings" unit within the "Chain Azure Functions together using input and output bindings" module.
Adding "&id=docs" to the end of the function url returns the expected JSON with the url.
However when I try "&id=missing", which isn't an id in the Cosmos DB, nothing loads. When I check the filesystem logs I see the following error:
[Error] Executed 'Functions.HttpTrigger1' (Failed, Id=8312e932-bcb7-4cb2-b83f-85a10d88021d, Duration=1413ms)Response status code does not indicate success: NotFound (404); Substatus: 0; ActivityId: 72a2e82e-e53a-4d99-a257-2af7400f2733; Reason: (code : NotFoundmessage : Entity with the specified id does not exist in the system. More info: https://aka.ms/cosmosdb-tsg-not-found
What I expected to happen is the "&id=missing" url page to have the JSON with "No bookmarks found".
Additional info:
I'm using the Microsoft Learn Sandbox with Node.js.
I'm exclusively using the Azure Portal (Not connected to VS or anything like that).
function.js:
{
index.js:
module.exports = function (context, req) {
Attempted solution:
Saw multiple posts suggesting changing the function's runtime version from 4 to 2, but the drop down for that only gives me the option for version 4.