1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20

doc

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.

  1. Prerequisites
  2. Listing you functions
  3. Creating an edge function
  4. Deleting an edge function

1. Prerequisites


2. Listing you functions

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:

    azioncli edge_functions list

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

    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).

3. Creating an edge function

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:

    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:

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

CLI response:

    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:

    azioncli edge_functions list

CLI response:

    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.


4. Deleting an edge function

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

    azioncli edge_functions delete --function-id 6823

CLI response:

    Edge Function 6823 was successfully deleted

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

    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.



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