1
votes

I'm developing the simple node.js code for inserting of new document to cosmosDB via Azure function app by using http trigger function. That's simply get the input value from http's parameter and output to cosmosDB(SQL api). About last 2 weeks, it was successfully running but now facing with internal server error. That's why? Is is affect on azure function's runtime minor version update?

->function.json

{
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req"
    },
    {
      "name": "outputDocument",
      "type": "cosmosDB",
      "databaseName": "ToDoList",
      "collectionName": "Items",
      "createIfNotExists": true,
      "connectionStringSetting": "COSMOSDB_CONNECTION",
      "direction": "out"
    }
  ]
}

->index.js

module.exports = function (context, req) {

    context.bindings.outputDocument = JSON.stringify({ 
        name: req.query.name
    });

    context.done();
};

->browsing error INTERNAL SERVER ERROR

1

1 Answers

1
votes

You are right, function runtime update(begin with 2.0.11857) has a breaking change for JavaScript functions. See this issue comment.

We are deprecating support for Node v6, which may affect deployed function apps. Please change WEBSITE_NODE_DEFAULT_VERSION in App Settings to an 8.x version that is >=8.4.0 (for example: 8.11.1).

Have done some tests, it does cause Internal Server Error if I keep WEBSITE_NODE_DEFAULT_VERSION as 6.5.0.

Before 2.0.11857 releases, WEBSITE_NODE_DEFAULT_VERSION is 6.5.0 in both v1 and v2 function. After then, when we upgrade function runtime from ~1 to beta, WEBSITE_NODE_DEFAULT_VERSION changes to 8.11.1 automatically.

Update

Node version changing doesn't work for you, maybe it's cased by cosmosdb extension being broken. You could have a try while I can't reproduce your problem on my side.

Steps to reinstall extension:

  1. Stop your function app.
  2. Visit https://<functionappname>.scm.azurewebsites.net/DebugConsole and navigate to D:\home\site\wwwroot.
  3. Delete the folder bin and extension.csproj.
  4. Go back to function portal and create a cosmosdb trigger to install the extension again.
  5. Start your function app to test.