⚡ Azure Functions

📌 Overview

Azure Functions is a serverless compute service that lets you run event-triggered code without having to explicitly provision or manage infrastructure.


1. Key Concepts

🔫 Triggers

A Trigger is what causes the function to start running.

🔗 Bindings

Bindings are a declarative way to connect data to your function code. They save you from writing boilerplate connection code.


3. Architecture Flow

      Events (Trigger)           Function App             Action (Output)
      ================           ============             ===============

    +----------------+         +--------------+          +---------------+
    | New Photo      | ------> | Resize Code  | -------> | Save Thumbnail|
    | (Blob Storage) |         | (Serverless) |          | (Blob Storage)|
    +----------------+         +--------------+          +---------------+
            ^                                                   |
            |                                                   v
    +----------------+                                   +---------------+
    | HTTP Request   |                                   | Send Email    |
    | (API Call)     |                                   | (SendGrid)    |
    +----------------+                                   +---------------+

2. Hosting Plans

You pay differently depending on how you host your function.

🥤 Consumption Plan (Serverless)

💎 Premium Plan

🏢 App Service Plan (Dedicated)



3. 🛠️ Hands-on: Create a Function App

Step 1: Create a Resource Group

az group create --name myResourceGroup --location eastus2

Step 2: Create a Storage Account (Required)

Function Apps require a storage account to manage triggers and logging.

Note: Your subscription has a restricted list of allowed regions.
If eastus2 fails, try: westus2, northeurope, southeastasia.

az storage account create \
  --name priyanshuksharma$RANDOM \
  --resource-group myResourceGroup \
  --location eastasia \
  --sku Standard_LRS

Step 3: Create the Function App

Replace <storage_name> with the name generated above.

az functionapp create \
  --resource-group myResourceGroup \
  --consumption-plan-location eastasia \
  --runtime node \
  --functions-version 4 \
  --name myUniqueFunctionApp$RANDOM \
  --storage-account 

💡 Exam Tips for AZ-900