Azure

Azure Functions Documentation

Quickstart: Create your first Azure Function

In this tutorial you will create a simple HTTP‑triggered Azure Function using the Azure CLI and VS Code. By the end you’ll have a function that returns a greeting.

1. Prerequisites

2. Create a function app

Open a terminal and run:

az group create --name quickstart-rg --location eastus
az storage account create --name qsstorage$(date +%s) --location eastus --resource-group quickstart-rg --sku Standard_LRS
az functionapp create --resource-group quickstart-rg --consumption-plan-location eastus --runtime node --functions-version 4 --name quickstart-func-$(date +%s) --storage-account qsstorage$(date +%s)

3. Scaffold the function locally

In VS Code:

mkdir quickstart-func
cd quickstart-func
func init . --javascript
func new --template "HTTP trigger" --name HttpExample

4. Add a greeting

Replace the content of HttpExample/index.js with:

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}!`
    };
};

5. Deploy to Azure

Run the following command from the project folder:

func azure functionapp publish quickstart-func-$(date +%s)

6. Test the function

After deployment you will see a URL like https://<app-name>.azurewebsites.net/api/HttpExample. Call it with a query string:

curl https://<app-name>.azurewebsites.net/api/HttpExample?name=Azure

You should receive:

Hello, Azure!

Next steps