Hyde: creating serverless applications

  • Tutorial
Today we lay out a guide for creating serverless applications. It includes 3 main sections: creating serverless logic, setting up triggers, and using bindings. Join now!


Imagine that you are working in an escalator company that has invested heavily in IoT technology to track your product locally. You control the processing of data from temperature sensors on the drive mechanisms of escalators. You are tracking temperature data and adding a flag indicating that the temperature of the drive mechanism is too high. In systems located lower in the process chain, this data helps determine the need for maintenance.

Your company receives data from sensors from several places and from different models of escalators. This data comes in a variety of formats, including sending batch files, scheduled retrievals from the database, queued messages, and incoming data from an event hub. You want to develop a reusable service that allows you to process temperature data from all of these sources.

When developing services such as this using traditional enterprise architecture strategies, you will need to take into account the server infrastructure and its maintenance in advance: select the necessary equipment, plan its installation, coordinate work with the IT department to manage it, etc. The alternative is serverless computing. With serverless computing, the cloud provider manages infrastructure preparation and maintenance, allowing you to fully concentrate on building logic applications. The Azure Functions service is a key component of Azure serverless computing offering, allowing you to run code snippets or functions written in your own programming language in the cloud.

Learning objectives

In this module, you will learn how to perform the following tasks:

  • Determine the suitability of serverless computing to meet business needs.
  • Create an Azure function app in the Azure portal.
  • Function execution using triggers.
  • Tracking and Testing Azure Features in the Azure Portal

Determining the suitability of serverless computing to meet business needs

To help you figure out whether to use serverless computing, we’ll first give you general information about this concept.

What is serverless computing?

Serverless computing is a function as a service (FaaS) or microservice hosted on a cloud platform. Business logic runs in a function format, which means you do not need to manually prepare or scale the infrastructure. All infrastructure management takes over the cloud service provider. The application automatically scales up or down depending on the load. Azure offers several ways to create this kind of architecture. The two most common approaches are using Azure Logic Apps and Azure Features. In this module, we consider them.

What are Azure Features?

Azure Functions is a serverless computing platform. It allows developers to implement business logic that can be executed without infrastructure preparation. The functions are structurally well scaled, and you only pay for the resources actually used. Function code can be created in any convenient language, including C #, F #, and JavaScript. NuGet and NPM are also supported, which allows using many popular libraries in business logic.

Benefits of serverless computing

Serverless computing is a great option for placing business logic code in the cloud. Serverless services, such as Azure Features, allow you to create business logic in any language you want. You get automatic scaling, you don’t need to worry about server management, and you only pay for the resources you actually use, and not for the reserved time. Below are some more features of a serverless solution that need to be considered.

Lack of excess infrastructure allocation

Suppose you have prepared virtual server servers and provided them with sufficient resources for peak loads. During periods of low traffic, you are likely to pay for unused infrastructure. Serverless computing helps to solve the problem of over-allocation of resources, since scaling is performed automatically and you pay only for the time of active work of the function.

Stateless Logic

Stateless functions are great for serverless computing; function instances are created and deleted upon request. If state tracking is required, it can be stored in the appropriate storage service.

Event management

Functions are event driven. This means that they are executed only in response to a certain event (trigger), for example, receiving an HTTP request or adding a message to a queue. Triggers are configured in the function definition. This approach greatly simplifies the code base, allowing you to declare only data sources (trigger / input binding) and destination (output binding). You do not have to write to create your own code to work with queues, BLOB objects, hubs, etc. It only remains to create business logic.

Functions can be used in traditional computing environments.

Functions are a key component of serverless computing, but at the same time they serve as a computing platform for executing any type of code. If the application needs change, you can always deploy the same project in a familiar server environment, getting the flexibility of managing scaling, running in virtual networks, and even complete isolation of functions.

Disadvantages of serverless computing

Serverless computations are not always optimal for hosting business logic. Below are a few characteristics of features that may influence your decision to host services in serverless computing.

lead time

By default, functions use a wait time of 5 minutes. It can be increased, but not more than 10 minutes. If the execution of the function takes more than 10 minutes, it can be placed on a virtual machine. In addition, if your service starts with an HTTP request and you expect to receive an HTTP response, the wait time is limited to 2.5 minutes. And finally, there is an additional opportunity to create robust functions in order to orchestrate the execution of several functions without timeout restrictions.

Execution frequency

The second characteristic is the frequency of execution. If it is expected that several clients will continuously perform the function, it would be wise to evaluate the use and calculate the cost of using the functions accordingly. Perhaps hosting the service in a virtual machine will be cheaper.

When scaling every 10 seconds, only one instance of the function application can be created, but no more than 200 instances as a whole. Remember that each instance can serve several simultaneous executions, that is, there are no restrictions on the amount of traffic that each instance can handle. Different types of triggers have different scaling requirements. Examine the selected trigger and its associated limitations.

Creating a function app in the Azure portal

A sandbox is required to complete this lesson. The sandbox

provides free access to the Azure resources needed for this lesson. Your Azure subscription fee will not be charged.

Enter the sandbox

Now you are ready to start implementing the temperature control service. In the previous module, you determined that a serverless solution is best suited for solving your problems. Now let's create an application function to store the Azure function.

What is an application function?

Functions are placed in a context called an application function. Feature applications allow you to logically group and structure functions and computational resources in Azure. In our example, you will create a function application to host the temperature control service for the elevator drive. To create an application function, several decisions need to be made, including choosing a maintenance plan and a suitable storage account.

Service plan selection

Function applications can use one of two types of maintenance plans. The first of these types is a consumption-based service plan. This plan will come in handy when using the serverless Azure application platform. The service plan based on consumption provides automatic scaling, and payment is charged only during the execution of functions. The consumption-based service plan allows you to customize the waiting period for a function. By default, this period is 5 minutes, but it can be increased to 10 minutes.

The second type is an Azure app service plan. This plan avoids waiting periods by continuously running the application on the selected virtual machine. If you are using an application service plan, you need to manage resources for the application in which the function is running. Strictly speaking, it does not allow to consider the plan as serverless. But in some circumstances it is better suited, for example, if functions are used constantly or require more processing power or a longer runtime than a consumption-based plan can provide.

Storage Account Requirements

The created function application needs to be linked to the storage account. You can choose an existing storage account or create a new one. The function application uses this storage account for internal operations, such as function execution logging and management of execution triggers. If a consumption based service plan is used, function code and configuration files are also stored here.

Creating application functions

Let's create a function app in the Azure portal.

Sign in to the Azure portal using the same account with which you activated the sandbox.

Click the Create Resource button in the upper left corner of the Azure Portal, and select Get started> Serverless Function App (Starting> Serverless Function Application) to open the New column for the function application. The same column can be opened via the menu item Calculations> Application-function.

Choose a globally unique application name. It will be used as the base URL of your service. You can call it, for example, escalator-functions-xxxxxxx, replacing the crosses with initials and the year of birth. If this name is not globally unique, try other combinations. Valid characters are a – z, 0–9, and -.

Select the Azure subscription in which you want to place the application function.

Select an existing resource group named [sandbox resource group name].

Select the Windows operating system.

Under Plan, select Consumption Plan, which is used for serverless placement.

In the list, select the geographic location closest to you. In the production system, you need to select the location closest to your customers or consumers function.

Free sandbox allows you to create resources in a subset of the global regions of Azure. When creating any resources, select a region from the following list:

  • Western US 2
  • Central West United States
  • Central South US
  • Central United States
  • Eastern United States
  • Western Europe
  • Southeast Asia
  • East Japan
  • Southern brazil
  • Southeast Australia
  • Central india

For the Runtime Stack parameter, select JavaScript from the drop-down list, since it is in this language that we implement the examples of functions in this exercise.

Create a storage account. Azure will automatically give it a name using the application name. You can replace this name with any other, but necessarily unique.

Ensure Azure Application Insights is enabled and select the region closest to you (or your customers).

Select Create. Deployment will take a few minutes. After it is completed, you will receive a notification.

Test Azure Application Function

From the menu on the left side of the Azure portal, select Resource Groups. Then you will see the resource group [sandbox resource group name] in the list of available groups.


Select the resource group [sandbox resource group name]. A list of resources will appear, like in the following image.

The lightning element, here indicated as an application service, is a new function application. Click it to open new feature details. She is assigned a public URL that can be opened in the browser and make sure that the application function is working correctly.

You can continue learning about the guide on our Microsoft Learn portal .

Also popular now: