Azure Functions Overview: Serverless Compute for Event-Driven Tasks

Azure Functions is a serverless compute service where you write individual function code and Azure handles everything else: provisioning, scaling, and billing only for the time your code actually runs. Functions eliminate the need to think about servers, instances, or scaling configuration for short-lived, event-driven tasks. This page covers the core concepts, billing model, available triggers, and the trade-offs that determine when Functions is the right choice.

What serverless actually means

Serverless does not mean no servers — it means servers are abstracted away from you. Azure Functions runs your code on shared compute infrastructure managed entirely by Microsoft. You do not provision instances, configure scaling rules, or patch operating systems. Your function runs, Azure bills for the duration of that run, and then the compute resource returns to the pool.

The operational model is fundamentally different from VMs or App Service. With a VM, you pay whether or not requests are coming in. With Functions on the Consumption plan, you pay only when your code is actively executing. For workloads that run infrequently — a few thousand invocations per day — Functions can cost a fraction of a cent per day.

Triggers: what starts a function

Every Azure Function has exactly one trigger — the event that causes it to execute. Common triggers:

TriggerWhen the function runsCommon use case
HTTPHTTP request receivedREST APIs, webhooks
TimerCRON scheduleNightly jobs, periodic cleanup, scheduled reports
Queue (Storage Queue)Message appears in a queueAsynchronous processing, background tasks
Service BusMessage in Service Bus queue or topicReliable messaging, ordered processing
Blob StorageBlob created or modifiedImage resizing, document processing, ETL
Event HubsEvents ingested to Event HubReal-time telemetry processing, streaming data
Event GridEvent published to a topicReact to Azure resource events, custom events
Cosmos DBDocuments change in a Cosmos DB collectionChange feed processing, data sync

The trigger system is what makes Functions powerful for event-driven architectures. Rather than polling for changes (expensive, slow, complex), you declare what event should cause your code to run and Azure handles the rest.

Your first function: HTTP triggered

A minimal Python HTTP-triggered function:

# function_app.py
import azure.functions as func
import json
import logging

app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)

@app.route(route="hello")
def hello_http(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('HTTP trigger function processed a request.')

    name = req.params.get('name') or 'world'

    return func.HttpResponse(
        json.dumps({"message": f"Hello, {name}!"}),
        mimetype="application/json",
        status_code=200
    )

Deploy with the Azure Functions Core Tools or CLI:

# Install Azure Functions Core Tools
npm install -g azure-functions-core-tools@4 --unsafe-perm true

# Create a new Function App in Azure
az functionapp create \
  --resource-group my-rg \
  --consumption-plan-location eastus \
  --runtime python \
  --runtime-version 3.11 \
  --functions-version 4 \
  --name my-unique-func-app \
  --storage-account mystorageaccount

# Deploy from your local project directory
func azure functionapp publish my-unique-func-app

Hosting plans: Consumption, Premium, and Dedicated

The hosting plan determines how your functions are billed and what performance characteristics they have:

Consumption plan

Pay only for execution time and memory consumed. Scales to zero between invocations — no charge when idle. Maximum execution duration: 10 minutes. Risk of cold starts when the runtime has been idle. Best for workloads with intermittent, unpredictable traffic or very infrequent jobs.

Flex Consumption plan (newer)

Microsoft’s updated Consumption model with faster scaling, per-instance concurrency control, and virtual network integration. Similar billing to Consumption but with improved cold start behaviour. Recommended over the original Consumption plan for new functions deployments as of 2024.

Premium plan

Pre-warmed instances eliminate cold starts. Minimum one always-running instance (you pay for it even when no functions execute). Maximum unlimited execution duration. VNet integration for private resource access. Best for functions that need consistent low-latency response times or access private Azure resources.

Dedicated (App Service) plan

Functions run on the same App Service Plan you configure — no cold starts, unlimited duration, predictable cost. Best for long-running functions or when you already have an App Service Plan with spare capacity. Loses the cost-per-execution billing model entirely.

Bindings: reading from and writing to services

Azure Functions has a bindings system that simplifies connecting functions to Azure services. Instead of writing code to open a Storage Queue connection, poll for messages, and acknowledge them, you declare a Queue trigger in the function definition and Azure handles the infrastructure:

@app.queue_trigger(arg_name="msg", queue_name="work-queue",
                   connection="AzureWebJobsStorage")
def process_queue_item(msg: func.QueueMessage) -> None:
    logging.info(f"Processing message: {msg.get_body().decode('utf-8')}")

    # Your processing logic here
    # Azure automatically acknowledges the message when the function returns
    # If the function throws an exception, the message returns to the queue

Output bindings write to services without manual connection management:

@app.route(route="create-task")
@app.queue_output(arg_name="outputQueueItem",
                  queue_name="work-queue",
                  connection="AzureWebJobsStorage")
def http_create_task(
    req: func.HttpRequest,
    outputQueueItem: func.Out[str]
) -> func.HttpResponse:

    task_data = req.get_json()
    outputQueueItem.set(json.dumps(task_data))

    return func.HttpResponse("Task queued", status_code=202)

The output binding queues the message automatically when the function returns. No queue client code, no connection string management in the function body.

When Functions is the right choice

  • Short-lived event processing (image resizing, document conversion, notification sending)
  • Scheduled tasks that run on a CRON schedule (nightly cleanup, daily reports)
  • Webhook handlers for external service events
  • Asynchronous background work triggered from a queue
  • Glue code between other Azure services (reacting to Event Grid events, bridging Service Bus to a database)

Functions is a poor choice for:

  • Long-running processing (over 10 minutes on Consumption plan)
  • Low-latency APIs where consistent sub-100ms response times are required (cold starts make this unpredictable on Consumption)
  • Stateful workflows where data must persist across function invocations (use Durable Functions for this)

Common Azure Functions mistakes

  1. Not accounting for cold starts in latency-sensitive APIs. If your Function-based API needs to respond within 200ms reliably, the Consumption plan’s cold starts (which can exceed 5 seconds) make that impossible without a Premium plan with pre-warmed instances.
  2. Storing state in memory between invocations. On the Consumption plan, the function runtime can be torn down after any invocation. Static variables or in-memory caches do not persist reliably. Store state in a database, Blob Storage, or Azure Cache for Redis — not in the function process memory.
  3. Triggering functions directly from other functions with HTTP calls. Calling one function’s HTTP endpoint from inside another function creates tight coupling and means both functions are running simultaneously, increasing cost. Use a Service Bus queue or Event Grid topic between them — one function drops a message, the other picks it up asynchronously.

Frequently asked questions

Does Azure Functions have a cold start problem?

Yes, on the Consumption plan. When a function has not been invoked recently, the runtime is shut down. The next invocation starts a new runtime instance, which takes 1–10 seconds depending on the language and function size. .NET and Java have longer cold starts than JavaScript or Python. The Premium plan keeps instances warm to eliminate cold starts. The Dedicated plan (App Service) has no cold starts because the function always runs on allocated compute.

How is Azure Functions billed on the Consumption plan?

You pay for execution count and GB-seconds of memory consumed. The first 1 million executions per month are free, and 400,000 GB-seconds are free. After that, executions cost $0.20 per million, and GB-seconds cost $0.000016 per GB-second. A function using 256 MB that runs for 500ms costs roughly 0.000002 GB-seconds — extremely cheap for occasional workloads.

Can Azure Functions run for more than 10 minutes?

On the Consumption plan, the default timeout is 5 minutes, configurable to a maximum of 10 minutes. On the Premium plan, the timeout is configurable up to 60 minutes. On a Dedicated (App Service) plan, functions can run indefinitely. For long-running workflows, use Durable Functions — an extension that orchestrates multi-step, long-running processes using durable state without holding a thread open.

Last verified: 19 March 2026 Cloud services change frequently. Verify details against official documentation before making infrastructure decisions.