Going Serverless with Azure Functions

Charana Sonnadara
3 min readFeb 2, 2021

--

Azure Function offers event-driven serverless computing, alleviating the need to provision, manage and pay for fixed computer compute resources in the cloud, allowing you to focus more on the logic than managing the infrastructure.
Azure Function belongs to Function-as-a-Service (FaaS) offer in Azure. Other FaaS offered, such as Lamda functions provided by AWS and Google Cloud Functions provided by Google Cloud.

In general, FaaS insist a developer program their applications with the following characteristics. Functions should be event-driven, stateless: inside the processes, there is no method to store data and short-lived; not more than a couple of minutes; preferably, the process should execute within few seconds.

Before going into details, let’s have a look at the advantages of using the Azure Functions.
1. Reduce the development time
2. Ease infrastructure management
3. Allow delivering your product on time
4. It offers a wide range of triggers to use
5. Wide range of programming languages to start with programming
Built-in scalability
6. No need to pay for an idle compute plan if you go with consumption plans
Built-in fault-tolerant mechanisms

Azure Function does support the following languages.
1. C#
2. JavaScript
3. Java
4. Python
5. PowerShell

Hosting Your Azure Function

Azure Functions can be hosted with consumption or app service plans, depending on the requirement. There are limitations, props, and cons in each of these plans. According to documentation, the Linux consumption plan does not offer Azure Active Directory Authentication support; hence, a developer might have to go with the app service plan if there is a requirement for Authentication and Authorization.

Further, when you are on a consumption plan, there will be a cold start time while invoking a function. It happens when your function is idle for some time and the Azure de-allocates the compute resources allocated for your function. Cold-Start time may not be deterministic. When this happens, a user might have to wait around 20–30 seconds wait for a response. It isn’t very pleasant when from a user’s perspective. Find this article, which has extensive analysis on cold starting.

Since the App Service plans offer a compute resource similar to a VM, you will not experience cold-start time. Further, when a function running on an App Service plan, there is an option to keep it turn on.

Azure Web Functions can only invoke with events. It supports multiple triggers to bind to several events, but function’s support for an event may depend on the programming language. Azure Web Functions offers the following triggers, which you can bind to your functions.

Writing Stateful applications with Azure Functions.

Since most applications are stateful, the developer needs to handle the state in external sources like Azure Storage or Database like cosmos DB.

Handling stateful inside Azure Functions could be quite a bit of overhead for your logic. Therefore Azure Functions offers an extension to manage stateful functions with Durable Functions. With Durable Functions, a programmer can define stateful workflows by writing orchestrator functions and writing stateful entities with Azure Functions. Durable functions handle the state, checkpoints, and restart the functions without your involvement. This extension further increases the productivity of a developer.

A practical use case of the durable web functions would be a long-running operation triggered by an external client. The Durable function will redirect the client to a status endpoint that the client can poll to obtain the results after a successful request. The durable function handles the status tracking mechanism. It reduces the amount of work and resources that a developer has to deal with.

Follow the link for more details on Azure Durable Function documentation.

Start Developing Azure Functions.

You can quickly start your first web functions and debug them on the local machine without even creating Azure resources. You will require the following to start developing Azure Functions.

  1. An Azure account with an active subscription
  2. Azure Functions Core Tools
  3. Visual Studio Code
  4. Azure Functions extension for VS Code

Follow the link for Azure Functions documentation and choose a quick start method of your choice.

Conclusion

Azure Function offers a friendly FaaS where you can start quickly create your business logic. Though it provides limited flexibility, it offers excellent features that help you to keep your focus on the program than the infrastructure.

--

--

Responses (1)