Post

Azure Functions Overview

You will need to be familiar with Azure Functions if you are taking the AZ-204 Azure Developer Associate certification exam.

This is some of the exam preparation notes I have taken for Azure Functions.

You can check out my other exam prepation notes for other Azure services covered on the AZ-204 exam here.

Explain functional differences between Azure Functions, Azure Logic Apps, and WebJobs

Azure Functions

  • Serverless solution
  • No need to maintain servers
  • Functions can be triggered based on events that happen against your Azure resources
  • Triggers and bindings
  • Consumption billing
  • Can be orchestrated to invoke other Azure Functions
  • Can be long running with Durable Functions

Azure Logic Apps

  • Serverless solution
  • Serverless workflow integration toool
  • Can be orchestrated to invoke other actions
  • Configured in a GUI
  • Out of the box library of actions you can reuse

WebJobs

  • Azure Functions is built on the WebJobs SDK
  • Both are code first solutions
  • Some of the same triggers in Azure Functions are available in WebJobs
  • WebJobs doesn’t support serverless app model with automatic scaling
  • WebJobs doesn’t support pay-per-use pricing
  • WebJobs doesn’t support integration with Logic Apps
  • In most scenarios, Azure Functions is the preferred option

Describe Azure Functions hosting plan options

Consumption plan

  • Default function timeout of 5 minutes, maximum function timeout of 10 minutes
  • Pay as you go
  • Automatic scaling
  • Function host instances are dynamically added and removed based on the number incoming events

Flexible Consumption plan

  • Default function timeout of 30 minutes, unlimited maximum function timeout (guaranteed for up to 60 mins)
  • Pay as you go
  • Virtual networking supported
  • Function host instances are dynamically added and removed based on the configured per instance concurrency and the number incoming events
  • Pre-provisioned always ready instances can be added to reduce cold starts
  • Scales automatically based on demand

Premium plan

  • Default function timeout of 30 minutes, unlimited maximum function timeout (guaranteed for up to 60 mins)
  • Consider if:
    • Your function apps run continuously, or nearly continuously.
    • You want more control of your instances and want to deploy multiple function apps on the same plan with event-driven scaling.
    • You have a high number of small executions and a high execution bill, but low GB seconds in the Consumption plan.
    • You need more CPU or memory options than are provided by consumption plans.
    • Your code needs to run longer than the maximum execution time allowed on the Consumption plan.
    • You require virtual network connectivity.
    • You want to provide a custom Linux image in which to run your functions.

Dedicated plan

  • Default function timeout of 30 minutes, unlimited maximum function timeout (guaranteed for up to 60 mins)
  • Consider if:
    • You must have fully predictable billing, or you need to manually scale instances.
    • You want to run multiple web apps and function apps on the same plan
    • You need access to larger compute size choices.
    • Full compute isolation and secure network access provided by an App Service Environment (ASE).
    • High memory usage and high scale (ASE).

Container Apps

  • Default function timeout of 30 minutes, unlimited maximum function timeout (guaranteed for up to 60 mins)
  • Consider if:
    • You want to package custom libraries with your function code to support line-of-business apps.
    • You need to migration code execution from on-premises or legacy apps to cloud native microservices running in containers.
    • You want to avoid the overhead and complexity of managing Kubernetes clusters and dedicated compute.
    • You need the high-end processing power provided by dedicated CPU compute resources for your functions.

Describe how Azure Functions scale to meet business needs

Consumption plan slace out

  • Event driven
  • Scales out automatically, even during periods of high load
  • Functions infrastructure scales CPU and memory resources by adding more instances based on the number of incoming trigger events
  • Max # instances per Function App:
    • Windows: 200
    • Linux: 100

Flexible Consumption plan scale out

  • Per-function scaling
  • Event-driven scaling decisions are calculated on a per-function basis, which provides a more deterministic way of scaling the functions in your app
  • Max # instances per Function App:
    • Limited only by total memory usage of all instances across a given region

Premium plan scale out

  • Event driven
  • Scale out automatically based on the number of events that its functions are triggered
  • Max # instances per Plan:
    • Windows: 100
    • Linux: 20-100

Dedicated plan scale out

  • Manual/autoscale
  • Max # instances per Plan:
    • 10-30
    • 100 (ASE)

Container Apps scale out

  • Event driven
  • Scale out automatically by adding more instances of the Functions host, based on the number of events that its functions are triggered on
  • Max # instances
    • 10-300

Explain the key components of a function and how they are structured

  • Triggers (required)
  • Bindings (optional)
    • Data from bindings is provided to the function as parameters
    • Input Bindings
    • Output Bindings
    • host.json
    • local.settings.json
    • functions.json can be used to define bindings
      • dataType
        • binary
        • stream
        • string
      • binding direction
        • For triggers, the direction is always in
        • Input and output bindings use in and out
        • Some bindings support a special direction inout
      • type
        • queueTrigger
        • blob
        • table
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
  "disabled": false,
  "bindings": [
    {
      "type": "queueTrigger",
      "direction": "in",
      "name": "myQueueItem",
      "queueName": "myqueue-items",
      "connection": "MyStorageConnectionAppSetting"
    },
    {
      "tableName": "Person",
      "connection": "MyStorageConnectionAppSetting",
      "name": "tableBinding",
      "type": "table",
      "direction": "out"
    }
  ]
}

Create triggers and bindings to control when a function runs and where the output is directed

Connect a function to services in Azure

Create a function by using Azure Functions Core Tools

Further Reading

This post is licensed under CC BY 4.0 by the author.