Skip to content

Latest commit

 

History

History
122 lines (76 loc) · 5.24 KB

functions-bindings-http-webhook-output.md

File metadata and controls

122 lines (76 loc) · 5.24 KB
title description ms.topic ms.custom ms.date zone_pivot_groups
Azure Functions HTTP output bindings
Learn how to return HTTP responses in Azure Functions.
reference
devx-track-extended-java, devx-track-js, devx-track-python, devx-track-ts
03/04/2022
programming-languages-set-functions

Azure Functions HTTP output bindings

Use the HTTP output binding to respond to the HTTP request sender (HTTP trigger). This binding requires an HTTP trigger and allows you to customize the response associated with the trigger's request.

The default return value for an HTTP-triggered function is:

  • HTTP 204 No Content with an empty body in Functions 2.x and higher
  • HTTP 200 OK with an empty body in Functions 1.x

::: zone pivot="programming-language-csharp"

Attribute

A return value attribute isn't required when using HttpResponseData. However, when using a ASP.NET Core integration and multi-binding output objects, the [HttpResultAttribute] attribute should be applied to the object property. The attribute takes no parameters. To learn more, see Usage.

[!INCLUDE functions-in-process-model-retirement-note]

A return value attribute isn't required for a class library. C# script instead uses a function.json configuration file as described in the C# scripting guide. To learn more, see Usage.


::: zone-end ::: zone pivot="programming-language-java"

Annotations

In the Java functions runtime library, use the HttpOutput annotation to define an output variable other than the default variable returned by the function. This annotation supports the following settings:

::: zone-end ::: zone pivot="programming-language-javascript,programming-language-typescript"
[!INCLUDE functions-nodejs-model-tabs-description]

Configuration

The options object passed to the output.http() method currently doesn't support any properties for model v4.

The following table explains the binding configuration properties that you set in the function.json file.

Property Description
type Must be set to http.
direction Must be set to out.
name The variable name used in function code for the response, or $return to use the return value.

::: zone-end ::: zone pivot="programming-language-python,programming-language-powershell"

Configuration

The following table explains the binding configuration properties that you set in the function.json file.

Property Description
type Must be set to http.
direction Must be set to out.
name The variable name used in function code for the response, or $return to use the return value.

::: zone-end

Usage

To send an HTTP response, use the language-standard response patterns.

::: zone pivot="programming-language-csharp"

In .NET, the response type depends on the C# mode:

The HTTP triggered function returns an object of one of the following types:

1 This type is only available when using ASP.NET Core integration.

When one of these types is used as part of multi-binding output objects, the [HttpResult] attribute should be applied to the object property. The attribute takes no parameters.

The HTTP triggered function returns a type of IActionResult or Task<IActionResult>.


::: zone-end
::: zone pivot="programming-language-java"

For Java, use an HttpResponseMessage.Builder to create a response to the HTTP trigger. To learn more, see HttpRequestMessage and HttpResponseMessage.

::: zone-end

For example responses, see the trigger examples.

Next steps