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)
- A Function
- 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
- function.json
- 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
- Near real time
- Streaming Logs
- 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
- Application runtime is a compute environment configured to run application code
- Hosting
- Windows vs Linux
- Differences
- performance
- functionality
- features
- Differences
- Windows vs Linux
- 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
- For Common Scenarios
- Function Configuration
- function.json
- type
- direction
- name
- function.json
- Hosts Configuration
- hosts.json
- global configuration
- LOT of configuration options
- hosts.json
- Plan Services
- 3 available plans
- Consumption Plan (Serverless) - Cold Starts
- Premium Plan (Functions Premium) - Pre-Warmed
- App Service Plan - VM Sharing
- 3 available plans
- 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
- …
- Trigger - Specific type of event which causes the function to run
- Binding Direction
- Trigger direction is always
In
- Input and Output binding use
In
and/orOut
- special bindings
Inout
- Trigger direction is always
- Binding Expressions
- curly braces
container/{queueTrigger}
- Lots of types
- curly braces
- Local Settings File
- local.settings.json
- Local Configurations for local development
- do not put in remote repository
- local.settings.json
- Core Tools
- Azure Function Core Tools -
func
func init
- new projectfunc logs
- logs of running functionsfunc start
- …
- Azure Function Core Tools -
- 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
- Storage account deleted
- Error - Runtime Unreachable
- 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
- Create
- 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