From the course: Learning Azure Durable Functions
Problems with Azure Functions - Azure Tutorial
From the course: Learning Azure Durable Functions
Problems with Azure Functions
- Azure Functions can solve a lot of different problems but are best for specific problems. As we learned in the last video, Azure Functions are an event-driven, serverless way to write some code that accomplishes a task where the provisioning of resources is obstructed away for you. However, this perk can quickly become a problem depending on the type of task you're trying to do. Let's explore this particular characteristic of Azure Functions. Giving up some complexity on your end by not worrying about infrastructure means limiting how complex you can make your functions. Not knowing what resources your Azure Functions will run on when executed nor having access to those resources presents some constraints on the way you write your code. First, the functions you create need to be stateless since your Azure function doesn't always run on the same server; in fact, a different server is used each time your function is executed. This means they can't depend on some piece of information or key dependency to exist each time it runs. And once your function is complete, it tears down the resources used, deleting any related context and information that may have existed during the function's execution. If any part of your task needs that context, you'll need to access it before your function finishes. Azure Functions also have timeout limits. On the common consumption plan, a function has a default timeout of 5 minutes and maximum timeout of 10 minutes. The premium plan has a longer range with a default timeout of 30 minutes and a maximum timeout of 60 minutes but still presents strict limits. With these timeout limits in place, your functions need to be short-lived or quick-running tasks that can complete within those limits. If they take longer, they run the risk of failing due to the function timing out or introducing weird edge cases if they partially complete before the timeout kicks in. You may also incur unintended additional costs if a function runs longer than expected. As you consider the serverless options available to you, keep these constraints for Azure Functions in mind. In the next video, we'll see how to handle these constraints using durable functions.