The Azure Functions plugin also supports additional input and output bindings.
These work by setting the direction explicitly. The properties go under the
x-azure-settings
property and match the same properties expected in the
function.json
, with the exception of "type" which is the first property's key.
You can learn about all the bindings Azure has to offer here on the official documentation.
This is an example of outputting data to Document DB.
# serverless.yml
functions:
example:
handler: handler.hello
events:
- queue: hello
x-azure-settings:
name: item #<string>, default - "myQueueItem", specifies which name it's available on `context.bindings`
connection: AzureWebJobsStorage #<string>, default - "AzureWebJobsStorage", environment variable which contains Storage Account Connection String
- documentDB:
x-azure-settings:
name: record # Name of input parameter in function signature>",
databaseName: myDocs # "<Name of the DocumentDB database>",
collectionName: todo # "<Name of the DocumentDB collection>",
createIfNotExists: true
connection: docDBAppSetting # "<Name of app setting with connection string - see below>",
direction: out
// handler.js
'use strict';
module.exports.hello = function(context, item) {
context.log("Received item: ${item}");
context.bindings.record = {
hello: "world"
}
context.done();
};
developers
Made with love in San Francisco + Atlanta, Austria, Germany, Pakistan, Poland, Nebraska & Thailand
Serverless, Inc. © 2018