Azure Functions – HTTP Trigger

What is an HTTP Trigger?

An HTTP trigger enables your function to be invoked via an HTTP request. This is ideal for building REST APIs, webhooks, or any endpoint that needs to be called over HTTP.

Key Features

Create a New HTTP‑triggered Function

Run the following Azure CLI command:

az functionapp create \
    --resource-group MyResourceGroup \
    --consumption-plan-location westus2 \
    --runtime node \
    --functions-version 4 \
    --name MyHttpFunctionApp

Sample Function Code (JavaScript)

module.exports = async function (context, req) {
    const name = (req.query.name || (req.body && req.body.name)) || "World";
    context.res = {
        // status: 200, /* Defaults to 200 */
        body: `Hello, ${name}!`,
        headers: {
            "Content-Type": "text/plain"
        }
    };
};

Try It Live

Deploying the Function

After developing locally, publish with:

func azure functionapp publish MyHttpFunctionApp