Run code without managing servers: create a Function App, deploy a function, trigger it from HTTP and timers, give it access to other services with a managed identity, and read its logs.
An Azure Function is code that runs on demand — Azure spins up the environment, runs your function, then tears it down. Why: there is no server to provision, patch, or pay for while idle; on the Consumption plan you pay per execution. Perfect for event-driven work and APIs with uneven traffic.
Functions need the Azure Functions Core Tools for local dev: npm install -g azure-functions-core-tools@4 Create a new local Functions project (JavaScript here)
func init my-funcs --javascriptcd my-funcsA Function App is the container that hosts one or more functions, with its own settings and scaling. Why it needs a storage account: Functions use it for state and logs. This creates the cloud-side app your code will deploy into.
A Function App needs a storage account (reuse or create one)
az functionapp create \
--resource-group learn-rg \
--name learn-funcs-7f3k \
--storage-account learnstore7f3k \
--consumption-plan-location eastus \
--runtime node --runtime-version 20 \
--functions-version 4A trigger is what makes a function run. An HTTP trigger turns the function into a callable URL — the basis of a serverless API. Why: the function handles the logic, Azure handles the web server and scaling, and you pay only per request.
Add an HTTP-triggered function to the local project
func new --name hello --template "HTTP trigger" --authlevel anonymousDeploy the whole project to the Function App
func azure functionapp publish learn-funcs-7f3kThe publish output prints the function's invoke URL to curl.
A timer trigger runs a function on a schedule (a cron job without a server). Why: nightly cleanups, hourly reports, periodic health pings — all without keeping a VM running just to watch the clock. The schedule is a 6-field CRON expression.
Add a timer-triggered function that runs every day at 02:00
func new --name nightly --template "Timer trigger"In the new function's function.json the schedule is set as NCRONTAB, e.g. "schedule": "0 0 2 * * *" (sec min hour day month day-of-week)
func azure functionapp publish learn-funcs-7f3kApp settings are environment variables for your function (connection strings, config). A managed identity lets the function call other Azure services with no secrets in code. Why: store config outside the code, and let Azure issue and rotate the credentials the function uses.
Add an app setting (available as an env var to your code)
az functionapp config appsettings set --resource-group learn-rg \
--name learn-funcs-7f3k --settings "GREETING=hello"Turn on a managed identity, then grant it a role elsewhere
az functionapp identity assign --resource-group learn-rg \
--name learn-funcs-7f3kPID=$(az functionapp identity show --resource-group learn-rg \
--name learn-funcs-7f3k --query principalId --output tsv)az role assignment create --assignee $PID \
--role "Storage Blob Data Reader" \
--scope /subscriptions/SUB_ID/resourceGroups/learn-rgWhen a function misbehaves you need to see its output. You can stream logs live or query them in Application Insights. Why: streaming is the fastest way to watch invocations and errors as they happen during development.
Stream the Function App's logs live
az webapp log tail --resource-group learn-rg --name learn-funcs-7f3k