0Pricing
Cloud & IT Cert Prep · Lesson

Azure Functions Triggers and Bindings

Write an HTTP-triggered function, add an output binding to write to Azure Queue Storage, and understand the Consumption Plan's automatic scaling model.

Azure Functions Triggers and Bindings is a free Cloud & IT Cert Prep lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cloud & IT Cert Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Are Azure Functions?

Azure Functions is a serverless compute service that lets you run small units of code (functions) in response to events without managing any infrastructure. You pay only for the execution time and memory used while your function runs — there is no cost when the function is idle. Functions are ideal for event-driven tasks, lightweight APIs, scheduled jobs, and integrating cloud services without a persistent server.

Triggers: What Starts a Function

Every Azure Function must have exactly one trigger that defines the event causing it to execute. Common triggers include HTTP (incoming HTTP request), Timer (CRON schedule), Blob Storage (new blob in a container), Queue Storage (new message in a queue), Event Hub (stream of events), Service Bus (queue/topic message), and Cosmos DB (change feed). The trigger receives the event data and passes it to your function code.

// HTTP trigger function (JavaScript/Node.js)
module.exports = async function (context, req) {
  const name = req.query.name || (req.body && req.body.name);
  const message = name ? 'Hello, ' + name : 'Pass a name in the query or body';
  context.res = {
    status: 200,
    body: { message }
  };
};

Function.json: Trigger and Binding Config

In non-compiled languages (JavaScript, Python), a function.json file in each function's directory declares its triggers and bindings. This file maps event sources and outputs to named parameters in your function code. For C# and Java, bindings are declared using attributes/annotations directly in code. The Functions runtime reads the configuration and sets up the connections to Azure services automatically.

// function.json — HTTP trigger + Queue output binding
{
  'bindings': [
    {
      'authLevel': 'function',
      'type': 'httpTrigger',
      'direction': 'in',
      'name': 'req',
      'methods': ['post']
    },
    {
      'type': 'http',
      'direction': 'out',
      'name': 'res'
    },
    {
      'type': 'queue',
      'direction': 'out',
      'name': 'outputQueue',
      'queueName': 'processing-queue',
      'connection': 'AzureWebJobsStorage'
    }
  ]
}

Output Bindings: Writing to Services

Output bindings let your function write data to Azure services (Blob Storage, Queue Storage, Cosmos DB, Event Hub, etc.) without managing SDKs or connection strings. You simply assign a value to the output binding parameter and the Functions runtime handles the write. This dramatically reduces boilerplate code and decouples your function from the specific Azure service implementation details.

// HTTP trigger with Queue output binding (Node.js)
module.exports = async function (context, req) {
  const orderData = req.body;

  // Write to queue via output binding -- no SDK needed!
  context.bindings.outputQueue = JSON.stringify({
    orderId: orderData.id,
    timestamp: new Date().toISOString()
  });

  context.res = { status: 202, body: 'Order queued' };
};

Timer Trigger with CRON Expressions

The Timer trigger runs a function on a schedule defined by a CRON expression. Azure Functions uses a 6-part CRON: {seconds} {minutes} {hours} {day} {month} {day-of-week}. Use 0 0 * * * * for hourly, 0 0 0 * * * for midnight daily, or 0 0 9-17 * * 1-5 for every hour during business hours on weekdays. Timer functions are useful for cleanup jobs, report generation, and health checks.

// Timer trigger — runs every day at 02:00 UTC
// function.json binding:
// {
//   'type': 'timerTrigger',
//   'schedule': '0 0 2 * * *',
//   'name': 'myTimer'
// }

module.exports = async function (context, myTimer) {
  const now = new Date().toISOString();
  context.log('Daily cleanup started at', now);
  // ... perform cleanup logic ...
  context.log('Cleanup completed');
};

Consumption Plan: Serverless Scaling

On the Consumption plan, Azure Functions automatically scales from zero to hundreds of instances based on trigger event rate. You pay only for the number of executions and the GB-seconds of memory consumed — the first 1 million executions per month are free. The Functions host can scale an HTTP trigger up to 200 instances and a queue trigger to the number of queue messages concurrently. Cold start (first execution after idle) adds a brief latency, mitigated by Premium plan's pre-warmed instances.

# View billing details for a function app
az functionapp show \
  --name myFunctionApp \
  --resource-group MyRG \
  --query '{name:name, plan:serverFarmId, state:state}'

# Create a Function App on Consumption plan
az functionapp create \
  --name myFunctionApp \
  --resource-group MyRG \
  --consumption-plan-location eastus \
  --runtime node \
  --runtime-version 18 \
  --storage-account mystorageaccount

Premium and Dedicated Plans

The Premium plan eliminates cold starts by keeping pre-warmed instances, adds VNet integration, and allows longer execution timeouts (up to 60 minutes). The Dedicated (App Service) plan runs functions on the same App Service plan as web apps, useful when you need predictable costs or have existing App Service compute to use. Choose Consumption for true serverless economics; Premium for performance-sensitive or VNet-connected functions.

# Create a Function App on Premium plan (EP1)
az functionapp plan create \
  --name MyPremiumPlan \
  --resource-group MyRG \
  --location eastus \
  --sku EP1 \
  --is-linux

az functionapp create \
  --name myFunctionAppPremium \
  --resource-group MyRG \
  --plan MyPremiumPlan \
  --runtime python \
  --runtime-version 3.11 \
  --storage-account mystorageaccount

Deploying Azure Functions

Deploy Azure Functions using the Azure Functions Core Tools (func azure functionapp publish), VS Code extension, ZIP deploy via the Azure CLI, or a CI/CD pipeline in Azure Pipelines or GitHub Actions. In production, always deploy from a pipeline rather than a developer machine to ensure tested, tagged versions reach production. The Functions runtime also supports Docker container deployment for full control of the runtime environment.

# Local development: install Core Tools
npm install -g azure-functions-core-tools@4

# Start locally (triggers work against real Azure services)
func start

# Deploy to Azure
func azure functionapp publish myFunctionApp

# Or deploy via Azure CLI (ZIP deploy)
zip -r function.zip . --exclude '.git/*'
az functionapp deployment source config-zip \
  --name myFunctionApp \
  --resource-group MyRG \
  --src function.zip

Application Settings and Key Vault References

Function Apps store configuration in application settings — these appear as environment variables in your function code. Store connection strings, API keys, and secrets as application settings. For production, use Key Vault references so the value is stored in Key Vault and only referenced by name in the app setting, keeping secrets out of the portal and deployment artifacts. Enable a managed identity on the function app to authenticate to Key Vault without credentials.

# Set application settings
az functionapp config appsettings set \
  --name myFunctionApp \
  --resource-group MyRG \
  --settings \
    STORAGE_CONNECTION='@Microsoft.KeyVault(SecretUri=https://mykv.vault.azure.net/secrets/storage-conn/)' \
    COSMOS_DB_URI='https://mycosmosdb.documents.azure.com'

# In function code, read as normal env var
# const storageConn = process.env['STORAGE_CONNECTION'];

Monitoring Functions with Application Insights

Azure Functions integrates with Application Insights automatically when you provide an instrumentation key or connection string. Every function execution is tracked as a request, including duration, success/failure, and custom properties. Use Application Insights' Live Metrics to watch executions in real time during testing, and the Failures blade to diagnose errors with full exception traces and dependency calls.

# Connect Application Insights to a Function App
az functionapp config appsettings set \
  --name myFunctionApp \
  --resource-group MyRG \
  --settings \
    APPLICATIONINSIGHTS_CONNECTION_STRING='InstrumentationKey=xxxxxxxx;...'

# Custom telemetry in function code (Node.js)
const appInsights = require('applicationinsights');
appInsights.setup().start();
const client = appInsights.defaultClient;
client.trackEvent({ name: 'OrderProcessed', properties: { orderId: '123' } });

Concurrency and Scaling Behaviour

For queue-triggered functions, the Functions host processes multiple messages in parallel. Configure batchSize in host.json to control how many messages a single instance processes concurrently. For HTTP triggers, scale-out adds new instances automatically. Use maxConcurrentCalls (Service Bus triggers) or maxPollingInterval (queue triggers) to tune throughput and avoid overwhelming downstream services like databases during scale-out events.

// host.json — tune queue trigger concurrency
{
  'version': '2.0',
  'extensions': {
    'queues': {
      'batchSize': 16,          // messages per instance
      'newBatchThreshold': 8,   // fetch more when < 8 remain
      'maxPollingInterval': '00:00:02',
      'visibilityTimeout': '00:05:00'
    }
  },
  'functionTimeout': '00:10:00'
}

Quick Check

Test your understanding of Microsoft Azure Fundamentals (AZ-900) concepts from this lesson.

Lesson Recap

In this lesson you learned: triggers define the event that starts a function (HTTP, Timer, Queue, Blob, etc.), output bindings let functions write to Azure services without SDK code, and the Consumption plan provides true serverless pay-per-execution scaling from zero. Next up we explore Durable Functions for stateful workflows.

Frequently asked questions

Is the “Azure Functions Triggers and Bindings” lesson free?

Yes — the full text of “Azure Functions Triggers and Bindings” is free to read here on the web, and the Cloud & IT Cert Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cloud & IT Cert Prep course, upgrade to CoddyKit PRO.

What will I learn in “Azure Functions Triggers and Bindings”?

Write an HTTP-triggered function, add an output binding to write to Azure Queue Storage, and understand the Consumption Plan's automatic scaling model. You practise Cloud & IT Cert Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cloud & IT Cert Prep?

No prior experience is required. Cloud & IT Cert Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Azure Functions Triggers and Bindings” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cloud & IT Cert Prep lesson?

Yes. Every Cloud & IT Cert Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Azure Functions Triggers and Bindings
  2. Durable Functions for Stateful Workflows
  3. Azure Logic Apps
  4. Event Grid and Event-Driven Architecture
← Back to Cloud & IT Cert Prep