What is MS Azure Functions?
In order to write less code, manage less infrastructure, and save money we can use Azure Functions which is a serverless computing platform. Rather than worrying about establishing and managing servers, the cloud architecture delivers all of the current resources necessary to keep your apps running.
Azure Functions takes care of the rest of everything we just have to concentrate on the code that matters most us the most.
We frequently design systems to respond to a sequence of crucial events. Every application, whether it's creating a web API, responding to database updates, processing IoT data streams, or simply maintaining message queues, need a means to run code as events occur.
The "compute on demand" is provided in Azure Functions in two methods as per the need.
First, Azure Functions enables you to turn your system's logic into easily accessible code chunks. "Functions" are the name for these code blocks. Various functions can be activated at any time when you need to respond to a vital incident.
Second, when demand grows, Azure Functions scales up to provide as many resources and function instances as needed - but only when they're needed. Any surplus resources and application instances are immediately decommissioned as demand decrease.
What is the source of all the computational resources? Azure Functions can supply as many or as few compute resources as you need to meet the demands of your application.
The serverless computing is defined as the provisioning of compute resources on demand in the Azure Functions.
A function may interface with a variety of cloud services to give feature-rich implementations in various scenarios.
The scenarios listed below are a popular, but not exhaustive, set of Azure Functions scenarios.
The following options and resources are accessible to you when you develop your functions:
Azure Functions enables you to turn your system's logic into easily accessible code chunks. "Functions" are the name for these code blocks.
What do we mean by "durable functions"?
Durable Functions is a serverless computing extension of Azure Functions that allows you to construct stateful functions. Using the Azure Functions programming model, you can construct stateful workflows by creating orchestrator functions and stateful entities by writing entity functions.
The following languages are currently supported by Durable Functions:
Durable Functions' main purpose is to simplify complex, stateful coordination requirements in serverless systems. The benefit that we can get from Durable Functions in Typical application patterns are -
Pattern: Function chaining
A succession of functions executes in a certain order in the function chaining pattern. The output of one function is applied to the input of another function in this way.
As seen in the following example, we can utilize Durable Functions to quickly implement the function chaining pattern.
The numbers F1, F2, F3, and F4 in this example are the names of additional functions in the same function app. Control flow can be implemented using standard imperative coding constructs. The execution of code begins at the top and works its way down. We can even use the conditional statements and different loop statements while writing the code as per the need. In try/catch/finally blocks, we can incorporate error handling logic as well.
Pattern: Fan out/fan in
You run numerous functions in parallel in the fan out/fan in pattern, then wait for them all to finish. On the results supplied by the functions, some aggregation work is frequently performed.
You can fan out standard functions by having them send several messages to a queue. Returning to the original position is significantly more difficult. To fan in, you build code to track when queue-triggered functions conclude and then store function outputs in a conventional function.
The F2 function's fan-out task is divided across numerous instances. A dynamic list of tasks is used to track the job. Task. It waits for all of the functions that have been called to finish, when All is called. The results of the F2 function are then combined and supplied to the F3 function from the dynamic task list.
The automated checkpointing that occurs when Task is called with an await call. When All ensures that a potential mid-task crash or reboot does not result in the task being restarted.
Pattern: Async HTTP APIs
This type of pattern solves the a very major problem of coordination of the status of long-running activities which is faced by external clients. An HTTP endpoint is a common technique to implement this pattern by triggering the long-running activity. The client is then sent to a status endpoint, which it polls to determine when the process is complete.
Durable Functions has built-in support for this pattern, making it easier to interact with long-running function executions and even eliminating the need to write code.
The Durable Functions runtime even manages state for us, so we don't need to create our own status-tracking method.
Built-in HTTP APIs for managing long-running orchestrations are exposed through the Durable Functions extension. A queue message, for example, could be used to initiate termination.