Up:: Microsoft Azure Developer Associate AZ-204 2023

Azure Functions

Azure Functions is a FaaS (Function as a Service)

  • A function App
    • A Function
      • Trigger (Only one)
      • Input Bindings (Parameters)
      • Output Bindings (Return Data)
  • Requires Storage account to operate
    • Blob Storage
    • Azure Files
    • Queue Storage
    • Table Storage
  • Anatomy
    • function.json
      • Configurations
    • index.js
      • Code
    • host.json
      • Global app configurations
    • .funcignore
      • Files to ignore
  • Authorization Levels
    • anonynmous - No API key
    • function - function level key
    • admin - master (app) key
    • Change authorization on selecting trigger
  • Debugging
    • Streaming Logs
      • Near real time
        • Built-in log stream
        • Live Metrics Stream
  • Key Concepts
    • Lightweight and can be serverless
    • Easier to write and deploy
    • fast to execute because there is no large application
      • cold starts should be taken into account
    • triggered when an event is fired
    • no need for infrastructure and have zero maintenance
    • built, tested and deployed using Azure Portal on a browser
    • easy to upgrade (subjected to code)
    • industry standard to communicate with APIs, databases and services
    • pay while function is running
    • Scales to meet demand
    • Can scale to Zero Cost
    • Built in monitoring with Azure Monitor
    • Built in CI/CD via Azure DevOps
    • Event-driven will be triggered based on event data and will emit event data
  • Use Cases
    • Business Use Cases
    • Technical Use Cases
    • Best suited for smaller apps that have events that can work independantly of othe websites
  • VSCode Extension
    • Install via Extensions
    • Can manage all function stuff via extension
  • Runtimes
    • Application runtime is a compute environment configured to run application code
      • .Net
      • Java
      • Node.js
      • Powershell Core
      • Python
      • Custom Handler for code which does not have the runtime available
    • Just Docker Containers
      • View on Docker Hub
  • Hosting
    • Windows vs Linux
      • Differences
        • performance
        • functionality
        • features
  • Templates
    • For Common Scenarios
      • Http Trigger
      • Timer
      • Blob Storage
      • Cosmos DB
      • Queue Storage
      • Event Grid
        • Many Azure Services can be triggered via event grid
        • Event Grid is serverless event bus integrated with Azure Services
      • Event Hub
      • Service Bus Queue
      • Service Bus Topics - Pub/Sub
      • SendGrid
  • Function Configuration
    • function.json
      • type
      • direction
      • name
  • Hosts Configuration
    • hosts.json
      • global configuration
      • LOT of configuration options
  • Plan Services
    • 3 available plans
      • Consumption Plan (Serverless) - Cold Starts
      • Premium Plan (Functions Premium) - Pre-Warmed
      • App Service Plan - VM Sharing
  • Triggers and Bindings
    • Trigger - Specific type of event which causes the function to run
      • defines how function is invoked, can have only one
    • Supported Bindings
      • Blob Storage
      • Cosmo DB
      • Azure SQL
      • Dapr
      • Event Grid
      • Event Hub
      • Http and WebHooks
  • Binding Direction
    • Trigger direction is always In
    • Input and Output binding use In and/or Out
    • special bindings Inout
  • Binding Expressions
    • curly braces container/{queueTrigger}
      • Lots of types
  • Local Settings File
    • local.settings.json
      • Local Configurations for local development
      • do not put in remote repository
  • Core Tools
    • Azure Function Core Tools - func
    • func init - new project
    • func logs - logs of running functions
    • func start
  • Custom Handlers
    • lightweight webserver to receive events
    • used to support languages not supported by Azure
    • Application Structure
      • host.json
      • local.settings.json
      • function.json
      • command, script or executable to run the web server
      • Could not get it up and running, really difficult.
  • Unreachable
    • Error - Runtime Unreachable
      • Storage account deleted
        • settings were deleted
        • credentials are invalid
  • Durable Functions
    • Create statuful functions
    • two types
      • Orchestrator function - define stateful workflows
      • Entity Function
    • Currently supported by:
      • C#
      • Javascript
      • Python
      • F#
      • Powershell
    • Need to install library to support language in use. ie npm install durable-functions
  • Patterns of Durable Functions
    • Function Chaining
    • Fan-out/Fan-in
      • Fanning out
      • Fanning in
    • Async HTTP Api
    • Monitor
      • polling till conditions are met
    • Human Interaction
    • Aggregator (Stateful entities)
  • Azure function on Kubernetes
    • KEDA Kubernetes Event driven Autoscaling

📇 Additional Metadata

  • 🗂 Type::note
  • 🏷️ Tags::
  • 📡 Status::🌲