Azure Cheatsheet

Functions

Use this Azure reference while you build software engineering projects, review code for technical interview prep, or polish examples for a software engineer resume.

Hosting Plans

PlanBillingScaleCold StartBest For
ConsumptionPer invocation + GB-sAuto (0→N)Yes (~1–5s)Event-driven, sporadic
Flex ConsumptionPer invocation + GB-sFast auto, min instancesReducedLatency-sensitive bursts
Premium (EP)Per vCPU-s (pre-warmed)Auto, always-warmNoLow latency, VNet
Dedicated (App Service)Plan rateManual/autoNoPredictable load
Container AppsPer vCPU-sK8s-poweredOptionalMicroservices

Create a Function App

# Create a storage account (required by Functions)
az storage account create \
  --name myfuncstorage -g myRG \
  --location eastus --sku Standard_LRS

# Create function app — Consumption plan, Node.js 20
az functionapp create \
  --name myfuncapp \
  --resource-group myRG \
  --storage-account myfuncstorage \
  --consumption-plan-location eastus \
  --runtime node \
  --runtime-version 20 \
  --functions-version 4 \
  --os-type Linux

# Create on Premium plan (pre-existing plan)
az functionapp create \
  --name myfuncapp -g myRG \
  --storage-account myfuncstorage \
  --plan myPremiumPlan \
  --runtime python \
  --runtime-version 3.11 \
  --functions-version 4

# List supported runtimes
az functionapp list-runtimes --os linux -o table

Deploy Functions

# Install Azure Functions Core Tools
npm install -g azure-functions-core-tools@4 --unsafe-perm true

# Init a new project
func init myproject --worker-runtime node  # or python, dotnet, java, powershell

# Create a new function
cd myproject
func new --name HttpTrigger --template "HTTP trigger" --authlevel anonymous

# Run locally
func start

# Deploy to Azure (zip deploy via Core Tools)
func azure functionapp publish myfuncapp

# Deploy via ZIP
az functionapp deployment source config-zip \
  --name myfuncapp -g myRG \
  --src ./func.zip

Trigger Types

TriggerBinding typeExample use
HTTPhttpTriggerREST APIs, webhooks
TimertimerTriggerCron jobs (0 */5 * * * *)
BlobblobTriggerProcess uploaded files
QueuequeueTriggerAzure Queue Storage messages
Service BusserviceBusTriggerService Bus queues/topics
Event HubeventHubTriggerStream processing
Cosmos DBcosmosDBTriggerChange feed
Event GrideventGridTriggerEvent subscriptions
SignalRsignalRTriggerReal-time connections

function.json (v1 model) vs. code annotations (v2)

// function.json — HTTP trigger (Node v1 model)
{
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": ["get", "post"]
    },
    { "type": "http", "direction": "out", "name": "res" }
  ]
}
// index.js — Node.js v4 programming model (no function.json needed)
const { app } = require('@azure/functions');

app.http('myHttpFunc', {
  methods: ['GET', 'POST'],
  authLevel: 'anonymous',
  handler: async (request, context) => {
    return { body: `Hello ${request.query.get('name') || 'world'}` };
  }
});
# Python v2 model
import azure.functions as func
app = func.FunctionApp()

@app.route(route="hello", auth_level=func.AuthLevel.ANONYMOUS)
def hello(req: func.HttpRequest) -> func.HttpResponse:
    return func.HttpResponse("Hello!")

@app.timer_trigger(schedule="0 */5 * * * *", arg_name="timer")
def my_cron(timer: func.TimerRequest) -> None:
    ...

App Settings & Config

# Set environment variables
az functionapp config appsettings set \
  --name myfuncapp -g myRG \
  --settings DATABASE_URL="..." API_KEY="..."

# List settings
az functionapp config appsettings list --name myfuncapp -g myRG -o table

# Use Key Vault references
# Value format: @Microsoft.KeyVault(SecretUri=https://mykv.vault.azure.net/secrets/mySecret/)
az functionapp config appsettings set \
  --name myfuncapp -g myRG \
  --settings "DB_PASS=@Microsoft.KeyVault(SecretUri=https://mykv.vault.azure.net/secrets/dbPass/)"

Managed Identity

# Enable system-assigned identity
az functionapp identity assign --name myfuncapp -g myRG

# Get the principal ID
az functionapp identity show --name myfuncapp -g myRG --query principalId -o tsv

# Grant access to a storage account
az role assignment create \
  --assignee <principal-id> \
  --role "Storage Blob Data Contributor" \
  --scope /subscriptions/<sub>/resourceGroups/myRG/providers/Microsoft.Storage/storageAccounts/myacct

Durable Functions

# Install Durable extension
func extensions install --package Microsoft.Azure.WebJobs.Extensions.DurableTask
// Orchestrator (Node v4)
const { app } = require('@azure/functions');
const df = require('durable-functions');

df.app.orchestration('myOrchestration', function* (context) {
  const result1 = yield context.df.callActivity('Activity1', 'input');
  const result2 = yield context.df.callActivity('Activity2', result1);
  return result2;
});

df.app.activity('Activity1', { handler: (input) => `processed: ${input}` });

Logs & Monitoring

# Stream live logs
az functionapp log tail --name myfuncapp -g myRG

# Enable Application Insights
az monitor app-insights component create \
  --app myfuncapp-ai -g myRG \
  --location eastus --kind web

INSTRUMENTATION_KEY=$(az monitor app-insights component show \
  --app myfuncapp-ai -g myRG \
  --query instrumentationKey -o tsv)

az functionapp config appsettings set \
  --name myfuncapp -g myRG \
  --settings APPINSIGHTS_INSTRUMENTATIONKEY=$INSTRUMENTATION_KEY

# List function invocations (via az CLI extension)
az monitor app-insights query \
  --app myfuncapp-ai -g myRG \
  --analytics-query "requests | take 20" -o table

Pricing Snapshot (Consumption Plan)

MeterFree grant (monthly)Price after
Executions1,000,000$0.20 per million
Execution time400,000 GB-s$0.000016 per GB-s