Serverless functions running on the Edge

Edit on GitHub

With Edge Computing and its Serverless functions (Edge Functions), it is now possible to dispense with the configuration of servers and the use of computing clouds (or Cloud Computing). From a simple “Hello World” to complex scenarios, there are many case possibilities that can be built and processed directly in Edge Nodes.

From serverless functions running on the edge, it is possible to configure automatic responses to requests, create static sites with dynamic navigation and many other options, in a decentralized manner, with high availability, low latency, high transfer capacities and a better user experience as well as devices that trigger them (IoT’s for example).

Hello World! This is an Edge Function

The Edge Function Hello World is a serverless function on Azion’s Edge Computing platform. Create automated responses for API gateways, FAQs, landing pages, error pages, test pages and many other features that will execute the business rules directly on Edge Nodes, load client-side scripts and run functions locally, thereby freeing up precious computing resources for essential services for your business.

The page you are currently viewing is the result of running a Hello World edge function. Entirely built on Edge, this is an example of how static pages can be configured to respond to API requests, for example, thus reducing queries to the origin. Here we show an example of a query to the website, showing some information about the origin of the request, such as the origin IP and the user-agent.

Your origin IP:

  "origin": ","

Your User-agent:

  "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 
(KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36"

How it works

Before you start, make sure that the Edge Functions service is active in your Azion account and that you already have the Hello World function in your Edge Functions Libraries. If not, contact our sales team to enable the service. The operation is very simple, just instantiate a Hello World function inside your Edge Application and configure the desired response through the parameters that the function receives (Json Args).

To configure your Function Hello World, edit the Edge Application to which you want to assign this service, making sure that the Edge Function option is enabled in the Main Settings tab. Next, go to the Functions tab and add a new Hello World function, providing a meaningful name for your custom function (for example MyHelloWorld), because it is through this name that your Function will be identified later in the configuration of the Rules Engine behavior. Note that the function code will appear in the Code section, for reading and understanding only.

In the Json Args tab, enter the function parameters in JSON format: Return message status (http_status) and message body (body), as in the example below.

        "http_status": 200,
        "body": "Hello World! It works!"

In the Rules Engine tab, use the Default Rule or create a new rule with a validation criterion (criteria) to activate your function, and in the Behavior section, select Run Function and choose the “MyHelloWorld” Function that you created.

Didn’t find what you were looking for? Open a support ticket.