mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Cleaned up the formatting, corrected some typos, updated the credentials guide to cover interactive login, and cleaned up the quick start.
2.0 KiB
2.0 KiB
Read this on the main serverless docs site
Other Bindings
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.
Example
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();
};