Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
HTTP-triggered functions use HTTP output to respond to the HTTP request sender. In most languages, this output is represented as an HTTP output binding. In Go, HTTP responses are written directly with the http.ResponseWriter passed to your HTTP trigger handler rather than with a separate output binding configuration.
The default return value for an HTTP-triggered function is:
HTTP 204 No Contentwith an empty body in Functions 2.x and higherHTTP 200 OKwith an empty body in Functions 1.x
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.
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:
Important
This article uses tabs to support multiple versions of the Node.js programming model. The v4 model is generally available and is designed to have a more flexible and intuitive experience for JavaScript and TypeScript developers. For more details about how the v4 model works, refer to the Azure Functions Node.js developer guide. To learn more about the differences between v3 and v4, refer to the migration guide.
Configuration
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. |
In Go, HTTP output is handled through the standard http.ResponseWriter that's passed to your HTTP trigger handler. You write your response directly using the writer. No separate output binding configuration is needed.
func hello(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, `{"message": "Hello from Go!"}`)
}
Usage
To send an HTTP response, use the language-standard response patterns.
In .NET, the response type depends on the C# mode:
The HTTP triggered function returns an object of one of the following types:
- IActionResult1 (or
Task<IActionResult>) - HttpResponse1 (or
Task<HttpResponse>) - HttpResponseData (or
Task<HttpResponseData>) - JSON serializable types representing the response body for a
200 OKresponse.
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.
For Java, use an HttpResponseMessage.Builder to create a response to the HTTP trigger. To learn more, see HttpRequestMessage and HttpResponseMessage.
For example responses, see the trigger examples.