2.3.4. š” First Principle: Azure Functions
First Principle: Azure Functions is a serverless compute service that enables you to run small pieces of code in response to events. Its core purpose is to provide highly scalable, event-driven, and cost-effective compute, allowing developers to focus purely on application logic without managing any infrastructure.
What It Is: A serverless, event-driven compute platform where you run small blocks of code ("functions") that are triggered by events.
Key Concepts:
- Serverless: You don't provision or manage any servers. Azure handles all infrastructure management.
- Event-Driven: Functions are triggered by events, such as an HTTP request, a new message in a queue, or a new file being uploaded to storage.
- Pay-Per-Execution: With the Consumption plan, you only pay for the time your code is actually running.
Scenario: An e-commerce website needs to automatically resize an image every time a new product photo is uploaded to Azure Blob Storage. This task is small, happens intermittently, and should be cost-effective.
Reflection Question: Why is Azure Functions an ideal choice for this image resizing task compared to running a dedicated VM or App Service that is always on?
š” Tip: Azure Functions is perfect for small, event-driven tasks. If you hear "when X happens, do Y," think of Azure Functions.