Managing your edge functions with Azion CLI

Manage your edge functions using the Azion CLI. It’s common for an edge application to use several functions present in an Edge Library.


Initially, you can list the edge functions available in your library, including the pre-configured Azion - Hello World function.

To list your edge functions, run the command:

Terminal window
azioncli edge_functions list

A list of your functions will be presented on the monitor, as in this example:

Terminal window
ID NAME LANGUAGE ACTIVE
3976 Azion - Hello World javascript true
6598 func01 javascript true

The azioncli edge_functions list command responded with a table consisting of four columns:

  • ID: unique identifier of the edge function on the Azion’s platform.
  • NAME: name of the function.
  • LANGUAGE: programming language or framework of the function.
  • ACTIVE: status of the function, which can be active (true) or inactive (false).

Create a new edge function directly from the CLI, without having to resort to RTM. Initially, we’ll need a JavaScript file containing the function code. If you don’t have a file in the current directory, create one with the command below:

Terminal window
echo "alert('My new JavaScript function');" > my-func.js

After running the command, verify the creation of the my-func.js file with the ls command.

Now that you have a file with the JavaScript function, you can create your edge function with it. To do so, type the following command:

Terminal window
azioncli edge_functions create --name my-new-ef --code ./my-func.js --active true

CLI response:

Terminal window
Created Edge Function with ID 6823

The CLI responds with the ID of the newly created function. To confirm it, use the list command again:

Terminal window
azioncli edge_functions list

CLI response:

Terminal window
ID NAME LANGUAGE ACTIVE
3976 Azion - Hello World javascript true
6598 func01 javascript true
6823 my-new-ef javascript true

Relative to the list in the previous example, this time the list command included the my-new-ef function with ID 6823, created by the create command.


To delete the newly created my-new-ef function, run the delete command with the ID parameter of the function:

Terminal window
azioncli edge_functions delete --function-id 6823

CLI response:

Terminal window
Edge Function 6823 was successfully deleted

Run the list command again. The CLI will present the following table:

Terminal window
ID NAME LANGUAGE ACTIVE
3976 Azion - Hello World javascript true
6598 func01 javascript true

Note that the my-new-ef function, whose ID was 6823, no longer appears in the list. As a suggestion, you can access RTM to analyze the results of the CLI commands presented in this example.


Contributors