- Needs storage account for creating Azure function
- Runtime stack can be .net, java, node.js etc
Azure Functions can be hosted as
- Consumption plan (serverless - auto scale, has time limit of 5 minutes for each method invocation, pay per use)
- Azure app service (no time limit, monthly plan service)
- Premium plan (faster performance, reserved instances, enhanced security)
- Docker container (on premises or any cloud provider)
Azure Function types
- HTTP Function Triggers (web hooks, use for APIs invocation)
- Timer Trigger (scheduled tasks, CRON expression)
- Blob Storage Trigger (data operation, run when a new file is uploaded to Blob storage)
- Queue Trigger (run in response to a message on a queue)
- Cosmos DB Trigger (run when a document is created or updated)
- Event Trigger
- Graph Trigger
- SendGrid Trigger (3rd party - send email)
- Twilio Trigger (3rd party - send text)
Every Azure function has exactly one trigger
HTTP Request Trigger
Security considerations:
Anonymous (no key required)
Security key per function
Admin: key per function app
Input and Output Bindings
Example for Input Bindings:
Blob storage binding - read all contents of a file in Blob storage
Cosmos DB binding - look up a document in a cosmos DB database
Queue storage binding - read a message from queue
Microsoft Graph binding - access OneDrive
To develop locally,
Azure Functions VS Code extension
we can use Azure storage emulator, Azure Cosmos DB Emulator
Command to run the function: func start
Call the endpoint using postman or powershell command "Invoke-WebRequest <endpoint>"
When a message is posted to a queue, we can use a free tool "Azure storage explorer" to view the queue and actual message
Azure Durable Functions (for workflows)
Create stateful, serverless workflows / orchestration
Orchestration Patters:
Function Chaining
Fan-out Fan-in
Asynchronous HTTP APIs
Monitor pattern (Poll and sleep)
Human Interaction (Process approval / escalate)
Install Microsoft.Azure.WebJobs.Extensions.DurableTask nuget package
No comments:
Post a Comment