Home ›
Azure Core Services ›
Azure Functions
Module 2
Beginner to Intermediate
AZ-204
AZ-900
18 min read
Azure Functions
Azure Functions is Microsoft's serverless computing service — run small pieces of code in the cloud without provisioning or managing any servers. You write the code, define what triggers it, and Azure handles everything else including scaling, patching, and infrastructure.
What you'll learn: What serverless means · What Azure Functions is · Triggers & bindings · Hosting plans · Supported languages · Creating your first function · Durable Functions · Pricing · Real world use cases · Best practices · AZ-204 exam tips
In this tutorial
What is serverless computing?
What are Azure Functions?
Triggers and bindings
Hosting plans
Supported languages
Creating your first function
Durable Functions
Pricing
Real world use cases
Best practices
AZ-204 exam tips
What is serverless computing?
Despite its name, serverless doesn't mean there are no servers — it means you don't have to think about servers. The cloud provider (Microsoft) automatically provisions, scales, and manages all the infrastructure. You only write and pay for your code execution.
Serverless is perfect for event-driven workloads — code that runs in response to something happening — like a file being uploaded, a message arriving, a timer firing, or an HTTP request being received.
💡 Real world analogy: Serverless is like using a taxi instead of owning a car. With a VM or App Service, you own the car — you pay for it 24/7 whether you're driving or not, and you handle maintenance. With serverless, you call a taxi only when you need it and pay only for the journey. No car sitting idle in your garage.
What are Azure Functions?
Azure Functions is Microsoft's serverless compute service that lets you run event-driven code without managing infrastructure. Each function is a small, focused piece of code that does one specific thing — process an image, send an email, validate data, call an API.
Key characteristics of Azure Functions:
1
Event-driven — Functions run in response to triggers. They don't run constantly — they wake up, do their job, and go back to sleep.
2
Automatic scaling — Azure automatically scales your functions from zero to thousands of instances based on demand. No configuration needed.
3
Pay per execution — On the Consumption plan, you pay only when your function runs. The free tier includes 1 million executions per month — making it effectively free for small workloads.
4
Stateless by default — Each function execution is independent. Functions don't remember previous executions (unless you use Durable Functions).
Triggers and bindings
Every Azure Function must have exactly one trigger — this is what causes the function to run. Functions can also have bindings — connections to other services that make it easy to read or write data without writing connection code.
1
HTTP Trigger — Function runs when it receives an HTTP request. Used to build REST APIs, webhooks, and serverless backends. The most common trigger type.
Example: A payment webhook that processes payment notifications from a payment gateway
2
Timer Trigger — Function runs on a schedule defined by a CRON expression. Used for scheduled jobs, cleanup tasks, and periodic reports.
Example: Run every day at midnight to generate daily sales reports
3
Blob Storage Trigger — Function runs when a file is uploaded to or modified in Azure Blob Storage.
Example: Automatically resize images when they're uploaded to a storage container
4
Queue Trigger — Function runs when a message arrives in an Azure Storage Queue or Service Bus queue.
Example: Process order confirmation emails as they arrive in a queue
5
Event Grid Trigger — Function runs when an event is published to Azure Event Grid. Used for reactive, event-driven architectures.
Example: Trigger a function when a new user signs up in another system
6
Cosmos DB Trigger — Function runs when documents are inserted or updated in an Azure Cosmos DB collection.
Example: Sync data to a search index whenever records change in Cosmos DB
Hosting plans
1
Consumption Plan (Serverless) — The true serverless option. Pay per execution. Automatically scales from zero. Free tier includes 1 million executions/month. Functions can run for up to 10 minutes maximum.
Best for: Infrequent, unpredictable workloads
2
Flex Consumption Plan — Microsoft's newest hosting plan (2024). Combines the pay-per-use model of Consumption with faster scaling, VNet support, and configurable instance memory.
Best for: Modern serverless workloads needing VNet integration
3
Premium Plan — Pre-warmed instances eliminate cold starts. Supports VNet integration, unlimited execution duration, and more powerful instances. Billed per second of instance usage.
Best for: Functions requiring no cold starts, VNet connectivity, or long execution times
4
Dedicated (App Service) Plan — Run functions on the same App Service Plan as your web apps. Best when you already have underutilised App Service resources and want to run functions on them at no extra cost.
💡 Cold starts explained: On the Consumption plan, when no requests have come in for a while, Azure shuts down your function instances to save resources. The next request "wakes up" the function — this takes 1-3 seconds and is called a cold start. For user-facing APIs this can feel slow. The Premium Plan keeps instances pre-warmed to eliminate this.
Supported languages
Azure Functions supports multiple programming languages. The runtime version and supported languages as of 2025:
Azure Functions v4 (current) — Supported languages:
C# → .NET 8 (isolated worker model)
JavaScript → Node.js 20 LTS
TypeScript → Node.js 20 LTS
Python → Python 3.11, 3.10
Java → Java 17, 11
PowerShell → PowerShell 7.4
Creating your first function
1
Go to portal.azure.com → Search "Function App" → Click "+ Create"
2
Basics tab:
• Resource Group: rkc-functions-rg
• Function App name: rkc-myfunctions (globally unique)
• Runtime stack: Python 3.11
• Version: 3.11
• Region: Central India
• OS: Linux
• Hosting plan: Consumption (Serverless)
3
Click "Review + Create" → "Create"
4
Once created → Click "Go to resource" → Click "Functions" on the left → Click "+ Create"
5
Select "HTTP trigger" → Name it HttpTrigger1 → Authorization level: Anonymous → Click "Create"
6
Click "Code + Test" → You'll see the default function code → Click "Test/Run" → Enter a name in the request body → Click "Run"
You'll see "Hello, [your name]!" in the response — your first serverless function is running! 🎉
Python HTTP Trigger function example
import azure.functions as func
import logging
app = func.FunctionsApp()
@app.route(route="hello")
def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
name = req.params.get('name')
if not name:
name = 'World'
return func.HttpResponse(
f"Hello, {name}! Welcome to RedKite Cloud.",
status_code=200
)
Durable Functions
Standard Azure Functions are stateless — each execution is independent. Durable Functions is an extension that lets you write stateful functions — functions that remember state across multiple executions and can coordinate with other functions.
1
Orchestrator functions — Define the workflow and coordinate the execution of other functions. They're reliable — if the orchestrator is interrupted, it automatically resumes from where it left off.
2
Activity functions — The individual units of work in a Durable Functions workflow. Each activity does one specific task — call an API, process a file, send an email.
3
Common patterns:
• Function chaining — Execute functions in sequence, passing output of one to the next
• Fan-out/Fan-in — Execute multiple functions in parallel and wait for all to complete
• Human interaction — Pause workflow and wait for human approval before continuing
Pricing
Azure Functions Consumption Plan pricing:
Free grant → 1,000,000 executions/month FREE
Free grant → 400,000 GB-seconds/month FREE
After free grant:
Executions → $0.20 per million executions
Execution time → $0.000016 per GB-second
Example: 5 million executions, 128MB memory, 200ms avg duration
Cost → ~$0.80/month total
Real world use cases
1
Image & video processing — Automatically resize, compress, or watermark images when uploaded to blob storage. Used by e-commerce sites and social platforms.
2
Serverless REST APIs — Build lightweight APIs that scale automatically. Perfect for mobile app backends, IoT data ingestion, and microservices.
3
Scheduled tasks — Run database cleanup, send scheduled emails, generate reports, sync data between systems — all on a timer without a dedicated server.
4
Real-time data processing — Process IoT sensor data, financial transaction streams, or social media feeds as they arrive using Event Hub or Service Bus triggers.
5
Chatbots & AI integrations — Connect messaging platforms (Teams, WhatsApp) to Azure AI services using HTTP-triggered functions as the integration layer.
Best practices
1
Keep functions small and focused — Each function should do one thing. If a function is doing too many things, split it into multiple functions.
2
Avoid long-running functions — On the Consumption plan, functions time out after 10 minutes. For long operations, use Durable Functions or offload work to a background queue.
3
Use managed identities — Never store credentials in function code or settings. Use managed identities to access other Azure services securely.
4
Enable Application Insights — Always connect Application Insights to monitor function executions, errors, performance, and dependencies.
5
Design for idempotency — Your function may be called multiple times for the same event (at-least-once delivery). Design functions so running them multiple times with the same input produces the same result.
AZ-204 exam tips
✅ Know all trigger types — HTTP, Timer, Blob, Queue, Event Grid, Cosmos DB
✅ Understand the difference between triggers and bindings
✅ Know the hosting plans — Consumption, Flex Consumption, Premium, Dedicated
✅ Remember Consumption plan free grant — 1 million executions/month
✅ Understand cold starts and that Premium Plan eliminates them
✅ Know that Consumption plan functions time out after 10 minutes by default
✅ Understand Durable Functions — stateful orchestration, chaining, fan-out/fan-in
✅ Remember Azure Functions is serverless — scales automatically from zero
✅ Know supported languages — C#, JavaScript, TypeScript, Python, Java, PowerShell