Azure - Functions

If you are using Azure Functions as a provider, all functions inside the service are Azure Functions.

Configuration

All of the Azure Functions in your serverless service can be found in serverless.yml under the functions property.

# serverless.yml
service: azfx-node-http

provider:
  name: azure
  location: West US

plugins:
  - serverless-azure-functions

functions:
  hello:
    handler: templates/handler.hello
    events:
      - http: true
        authLevel: anonymous # can also be `function` or `admin`

The handler property points to the file (default filename: handler.js) and module containing the code you want to run in your function.

// handler.js
exports.handler = function (params) {};

You can add as many functions as you want within this property.

# serverless.yml
---
functions:
  functionOne:
    handler: handler.functionOne
    description: optional description for your Function
  functionTwo:
    handler: handler.functionTwo
  functionThree:
    handler: handler.functionThree

You can specify an array of functions, which is useful if you separate your functions in to different files:

# serverless.yml
---
functions:
  - ${file(./foo-functions.yml)}
  - ${file(./bar-functions.yml)}
# foo-functions.yml
getFoo:
  handler: handler.foo
deleteFoo:
  handler: handler.foo
#bar-functions-yml
getBar:
  handler: handler.bar
deleteBar:
  handler: handler.bar

Handlers can also be referenced by a file path relative to the root. If your directory structure were something like:

serverless.yml
src/
  handlers/
    foo.js # exported `handler` function
    bar.js # exported `handler` function

Your serverless.yml would look something like:

# serverless.yml
---
functions:
  foo:
    handler: src/handlers/foo.handler
  bar:
    handler: src/handlers/bar.handler
Edit this page

Azure - Functions

If you are using Azure Functions as a provider, all functions inside the service are Azure Functions.

Configuration

All of the Azure Functions in your serverless service can be found in serverless.yml under the functions property.

# serverless.yml
service: azfx-node-http

provider:
  name: azure
  location: West US

plugins:
  - serverless-azure-functions

functions:
  hello:
    handler: templates/handler.hello
    events:
      - http: true
        authLevel: anonymous # can also be `function` or `admin`

The handler property points to the file (default filename: handler.js) and module containing the code you want to run in your function.

// handler.js
exports.handler = function (params) {};

You can add as many functions as you want within this property.

# serverless.yml
---
functions:
  functionOne:
    handler: handler.functionOne
    description: optional description for your Function
  functionTwo:
    handler: handler.functionTwo
  functionThree:
    handler: handler.functionThree

You can specify an array of functions, which is useful if you separate your functions in to different files:

# serverless.yml
---
functions:
  - ${file(./foo-functions.yml)}
  - ${file(./bar-functions.yml)}
# foo-functions.yml
getFoo:
  handler: handler.foo
deleteFoo:
  handler: handler.foo
#bar-functions-yml
getBar:
  handler: handler.bar
deleteBar:
  handler: handler.bar

Handlers can also be referenced by a file path relative to the root. If your directory structure were something like:

serverless.yml
src/
  handlers/
    foo.js # exported `handler` function
    bar.js # exported `handler` function

Your serverless.yml would look something like:

# serverless.yml
---
functions:
  foo:
    handler: src/handlers/foo.handler
  bar:
    handler: src/handlers/bar.handler