Skip to content

Raise binding.context failure information #276

@julielerman

Description

@julielerman

Environment:
macOS
VS Code 1.21
latest Azure CLI tools
Azure Functions 0.7.0

I'm not sure if this is related to the extension. But I've used it to create a function that has an output binding to a CosmosDB document db. I've deployed the function to the portal and when I test it from there, passing in a json document, the document does get stored into the db. But when I run it in vscode and then call it from postman and pass in the same doc, the document does not get stored.

I can debug into the function and see the document coming in via req.body.

There are no errors. I have debugged into context when I'm at the closing brace and can't find any kind of error code. I've also tried using application insights and a few other ways to monitor the db to see if there's any indication of an attempt to create a document but am not seeing anything.

If I could see what is or isn't happening, then I might be able to fix the problem. Is there something more that the extension could be helping me with?

Here is the function code:

module.exports = function (context, req) {
    context.log('JavaScript HTTP trigger function processed a request.');
   
    try {
        context.bindings.outputDocument=req.body;
      }
      catch(error) {
        context.log(error);
         }
    context.done();
};

Here is the function.json:

{
  "disabled": false,
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    },
    {
      "type": "documentDB",
      "name": "outputDocument",
      "databaseName": "Ninjas",
      "collectionName": "Ninjas",
      "createIfNotExists": true,
       "connection": "datapointscosmosdb",
       "direction": "out"
    }
  ]
}

localsettings.json:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=functionsample;AccountKey=***",
    "datapointscosmosdb": "AccountEndpoint=https://***.documents.azure.com:443/;AccountKey=***"
      }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions