Edge Functions for Edge Application
Azion Edge Functions allows you to create event-driven, serverless applications, at the edge of the network, closer to users.
With Edge Functions for Edge Application, you can:
- Implement the required logic.
- Reuse an edge function in different edge applications.
- Keep and retrieve your pre-configured environment variables.
- Access databases.
- Write your code in JavaScript.
- Deploy functions easily.
- Make use of pair programming with the Chat GPT integration.
- Preview the outcome of the function live on the preview deployment.
Implementation
Scope | Guide |
---|---|
API Builder | How to build an API with Edge Functions and ChatGPT |
Examples | Examples |
Code samples | GitHub repository |
Azion Runtime
By using JavaScript in Edge Functions, you can execute code closer to the end user, enhancing performance and enabling custom logic for handling requests and responses.
By using the Azion Runtime to develop your edge functions, you have a set of tools that help you implement your logic.
Go to azion runtimeGo to supported Web Frameworks
Go to supported Web APIs
Go to node.js support reference
JavaScript frameworks
Next.js
Next.js is a JavaScript framework built on top of React that enables server-side rendering (SSR) and static site generation for building Jamstack applications.
Jamstack
Jamstack stands for JavaScript, APIs, and Markup, and it promotes decoupling the front end from the back end by pre-rendering content and serving it as static files.
SSR
SSR allows rendering React components on the server before sending them to the client, enhancing initial load times and improving SEO.
Static Site
Static site generation generates static HTML files at build time, which can be cached and delivered quickly to users, reducing the need for server-side processing.
WebAssembly
WebAssembly (Wasm) is a binary instruction format that allows high-performance execution of code on the web. It enables running applications at near-native speed, bridging the gap between different programming languages and platforms.
Azion Edge Functions leverages the power of WebAssembly to provide serverless computing at the edge of the network, enabling developers to deploy custom logic and optimize web applications with reduced latency and improved performance.
This combination of WebAssembly and Azion Edge Functions opens up new possibilities for creating faster, more efficient, and scalable web experiences.
Learn more on How to create an edge function using WebAssembly on the Azion Edge platform.
Function instantiation
The Edge Functions instances module allows you to instantiate serverless functions in your edge applications, as well as set up conditions for their execution.
Once your edge application runs an edge function, it responds to events closer to the end user, ensuring greater scalability and availability.
Learn more about Edge Functions Instances.
Rules Engine
Rules Engine handles the conditional execution of behaviors through logical operators. By using Rules Engine, you can build an architecture that provides better performance to your users while consuming fewer resources by processing at the origin.
Learn more about Rules Engine.
Code Editor
The code editor for Edge Functions is the best way to get started developing your edge functions on the Azion’s platform. It’s a web-based code editor that makes it easier and more intuitive to develop at the edge of the network. It’s empowered by the Monaco Code Editor, used in VS Code. If you’re used to VS Code, you’ll get familiar with it right away.
Some of its key features are:
- Syntax Highlighting
- Intellisense
- Debugging
Learn more about the Edge Functions Code Editor.
AI Assistant
Generative AI can be used in almost all tasks that involve understanding or generating natural language or code. In the development environment, it’s a tool used for boosting developers’ productivity.
In the edge functions scenario, it helps developers to:
- Debug code.
- Refactor code.
- Generate code based on prompts.
Learn more about the AI Assistant.
Preview
You can check if the output is the expected with the Preview Deployment, making use of the PreviewProvider
function, that emulates a request.
Learn more about Preview Deployment.
Debug
You can debug your edge functions in real time using the inspect
tool inside the Preview Deployment section.
You can also debug using:
Environment variables
Environment variables are a crucial aspect of software development and deployment. They are used to store sensitive information or configuration settings that shouldn’t be hardcoded into the codebase.
Learn more about Environment Variables.
JSON Args
When you add JSON args, you can have different behaviors in your edge function without having to alter the code. Once you’ve set your JSON args, you can retrieve them by calling event.args("desiredArg")
.
Edge Functions management
There are different ways to manage your edge functions on the Azion Edge Platform. You can do this through Azion Console, Azion CLI, Azion API, and Terraform.
Azion Console
You can create and manage edge functions through Azion Console, found on the Products menu below Edge Libraries.
CLI
The Azion CLI allows you to manage your edge functions for edge applications through the terminal.
Learn more about Azion CLI edge functions command and its subcommands
API
The Azion API, accessed through Postman, offers the methods and calls necessary to manage your edge functions.
Access the Azion API collection and test the requests.
Terraform
The Azion Terraform Provider allows the management of edge functions on the Azion platform. It makes possible to treat your infrastructure as code.
Learn more about the management of edge functions trough the Azion Terraform Provider.
Limits
These are the default limits:
Scope | Limit |
---|---|
Arguments | 100 KB |
Memory per Isolate | 512 MB |
Code Limit (UI) | 6 MB |
Code Limit (API) | 20 MB |
Environment variable size | 32 KB |