Understanding Azure Functions
This lesson explains function apps, triggers and bindings, the Python v2 programming model, the project files and local development.
Learning outcomes
After completing this lesson, you will be able to:
- Describe triggers, input bindings and output bindings.
- Explain the Python v2 programming model.
- Identify the purpose of each project file.
- Choose workloads that suit Azure Functions.
What Azure Functions provides
Azure Functions is a serverless compute service: the developer writes functions, and the platform runs them when something happens, scales the number of instances with demand and, on the serverless plans, bills only for execution. Every function has exactly one trigger, the event that starts it, such as an HTTP request, a timer, a Service Bus message, an Event Grid event or a change in a Cosmos DB container.
Functions suit the glue and edge logic of AI back ends: lightweight APIs, handlers that embed new documents, functions that invalidate caches when data changes, scheduled clean-up jobs and secret rotation. Long-running, stateful or very high-throughput services usually fit Container Apps or AKS better, and multi-step workflows with state can use the Durable Functions extension.
The following diagram maps each component of an application to the hosting option that fits it best.

A function or something else?
Function apps and the host
Functions are deployed in a function app, which is the unit of deployment, configuration and scaling: all functions in an app share its hosting plan, app settings, runtime version and identity. Inside each instance, the Functions host (runtime version 4.x) listens for triggers and, for Python, passes each invocation to a Python worker process that runs the code. The language and version are set on the function app; Python function apps always run on Linux.
Bindings connect a function to other services declaratively. An input binding reads data before the function runs, such as a Cosmos DB item identified by a route parameter, and an output binding writes data when the function returns, such as a message to a Service Bus queue. Bindings remove boilerplate connection code, while the Azure SDKs remain available for anything bindings do not cover. Binding extensions are supplied through an extension bundle declared in host.json.
Function apps
The Python v2 programming model
In the v2 programming model, functions are Python functions decorated with their trigger and bindings in a file named function_app.py. A FunctionApp object registers them. The older v1 model, with a function.json file per function, is still supported but the v2 model is recommended.
import json
import logging
import azure.functions as func
app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)
@app.route(route="health", methods=["GET"], auth_level=func.AuthLevel.ANONYMOUS)
def health(req: func.HttpRequest) -> func.HttpResponse:
return func.HttpResponse("ok")
@app.timer_trigger(schedule="0 */15 * * * *", arg_name="timer")
def purge_expired_sessions(timer: func.TimerRequest) -> None:
logging.info("Purging expired sessions; past due: %s", timer.past_due)Large apps split functions into modules with blueprints: each module creates a func.Blueprint(), decorates its functions on it, and function_app.py registers it with app.register_functions(bp). Timer schedules use six-field NCRONTAB expressions that include seconds, so 0 */15 * * * * means every 15 minutes.
NCRONTAB schedules
Project files and local development
A Python function project contains a small set of files, each with a distinct role. Knowing which file holds which setting answers many configuration questions.
| File | Purpose | Deployed |
|---|---|---|
function_app.py | Function definitions with triggers and bindings | Yes |
host.json | Host configuration for all functions: extension bundle, logging, timeouts, trigger settings | Yes |
requirements.txt | Python packages, installed during deployment | Yes |
local.settings.json | App settings and connection strings for local runs only | No; settings in Azure are configured on the function app |
Azure Functions Core Tools provides the func command: func init --python creates a project, func new adds a function from a template, and func start runs the host locally. Triggers that need storage, such as timers, use the AzureWebJobsStorage setting, which locally can point at the Azurite storage emulator.
func init orders-functions --python
cd orders-functions
func new --name health --template "HTTP trigger" --authlevel anonymous
func startProject files and commands
Choosing Functions for a task
A team needs three components: an endpoint that returns the status of a document processing job from Cosmos DB, a job that deletes expired cache entries every hour, and a 40-minute GPU-based batch transcription of uploaded audio files. Which should be Azure Functions?
The status endpoint is a short HTTP request with a Cosmos DB lookup, a good fit for an HTTP-triggered function with a Cosmos DB input binding. The hourly clean-up fits a timer-triggered function. The 40-minute GPU transcription needs GPU hardware and long execution, which fits a Container Apps job on a GPU workload profile (or AKS) better than a function.
Putting all three in one function app would force the GPU work onto a hosting plan not designed for it. Running the status endpoint in AKS would add operational overhead for a tiny API.
Which project file holds settings used only when running functions locally, and is it deployed?
Show answer
local.settings.json. It is not deployed; settings in Azure are configured as app settings on the function app.
Exam Tips
Remember for the exam
- Each function has exactly one trigger; input and output bindings are optional and declarative.
- The Python v2 model declares functions with decorators in function_app.py.
- host.json configures the host; local.settings.json is for local runs only and is not deployed.
- Timer schedules use six-field NCRONTAB expressions that include seconds.