Azure functions usage
The azure function can be used under the following circumstances,
- Use the Azure function where the application needs to execute small code/logic repeatedly.
- Code that needs to scale quickly or that runs sporadically.
Azure function triggers
The azure function can be triggered from the following,
- Queue
- Timer
- Event Grid
- HTTP
I was working on the azure function with service bus queue triggers and would like to share some observations,
- Once the azure function picks the message from the queue, the function should finish the processing within 5 minutes because the queue message lock duration is 5 min. If a function takes more than 5 min to execute and the Max delivery count is more than 1, then the message will be re-queued and picked up by another function instance.
- The azure function can be hosted in 3 different plans,
- Consumption Plan - Scales automatically can have 200 instances in windows with a 10-minute max time of execution.
- Premium Plan - Scales automatically can have 100 instances in windows with an unlimited max time of execution.
- Dedicate Plan - Manual/autoscale can have 10-20 instances in windows with an unlimited max time of execution.
Tips
- If the queue is used as a function trigger and a premium or dedicated plan are used, function execution should finish within 5 min only. Otherwise, the message will be re-queued and picked again by another function instance.
- If you need more than 200 instances at any given time and are using queues, separate the message into multiple queues, which triggers different function deployments.