serverless / serverless-azure-functions

Serverless Azure Functions Plugin – Add Azure Functions support to the Serverless Framework
MIT License
267 stars 162 forks source link

fix: Updates default http output binding #308

Closed wbreza closed 5 years ago

wbreza commented 5 years ago

This updates the default value for the name of the HTTP output binding from $return to $res to work around an issue that existing within the Azure core tools http runtime..

A bug exists in the Azure core tools http runtime that evaluates $return binding incorrectly which causes serialization issues when returning arrays within an HTTP response. https://github.com/Azure/azure-functions-nodejs-worker/issues/228

wbreza commented 5 years ago

@jon-lewis Even though the default has changed to res this can always be overriden in your serverless.yml as needed for your implementation.

You can modify your handler definition to include the output binding. When you handler specifies its own output binding then the default is ignored.

  health:
    handler: src/handlers/health.handler
    events:
      - http: true
        x-azure-settings:
          methods:
            - GET
          authLevel : function
      - http: true
        x-azure-settings:
          direction: out
          name: res

Hope this helps.

jon-lewis commented 4 years ago

Perfect. I did test this out and the following settings worked for me.

- http: true
  x-azure-settings:
    direction: out
    name: $return