How to run scripts on edge nodes
To be able to orchestrate services on your device, you must configure all the resources needed to install, uninstall, and reload your services.
This guide presents how to install Azion CLI on your edge nodes through a resource of the type Shell Script
configured on a specific edge service.
Requirements
- An edge node with Edge Orchestrator Agent installed and authorized.
- The Dpkg package manager installed on this node.
Creating an edge service
- Access Azion Console.
- On the upper-left corner of the page, open the Products menu, represented by three horizontal lines, and then select Edge Services.
- Click on the + Service button.
- Name this service
Azion CLI Installation
. - Enter the variables and values for the resource, if necessary.
- Set the status as Active.
- Click the Save button.
- Access Real-Time Manager (RTM).
- On the upper-left corner of the page, open the Products menu, represented by three horizontal lines, and then select Edge Services.
- Click on the Add Service button.
- Name this service
Azion CLI Installation
. - Go back and, on the list of services, set the new service’s status as active.
- Run the following
POST
request in your terminal, replacing[TOKEN VALUE]
with your personal token and informing the name of the service being created:
- Keep the ID of the edge service you’ve just created. You can access it in the response body, for example:
- Run the following
PATCH
request in your terminal to set the service as active, replacing[TOKEN VALUE]
with your personal token:
Creating a resource
- Inside the service you’ve just created, called
Azion CLI Installation
, go to the Resources tab. - Click on + Resource.
- Enter
/scripts/install-cli
in the Path field. - Choose the type Shell Script.
- Choose the trigger Install.
- Add the following content to the Content block:
#!/bin/bash # Define the URL of the binary to download
BINARY_URL="https://github.com/aziontech/azion/releases/download/1.10.2/azion_1.10.2_linux_arm64.deb" # Download the binary
wget $BINARY_URL -O /tmp/azion.deb # Install the binary
# This assumes that you have dpkg installed on your system
sudo dpkg -i /tmp/azion.deb # Clean up the downloaded binary
rm /tmp/azion.deb echo "Installation completed successfully"
- Click the Save button.
This script will install the Azion binary in the following path: /usr/local/bin
- On the services list, select the edge service you’ve just created, called
Azion CLI Installation
. - Go to the Resources tab and click on Add Resource.
- Enter
/scripts/install-cli
in the Filepath field. - Choose the type Shell Script.
- Choose the trigger Install.
- Add the following content to the content block:
#!/bin/bash # Define the URL of the binary to download
BINARY_URL="https://github.com/aziontech/azion/releases/download/1.10.2/azion_1.10.2_linux_arm64.deb" # Download the binary
wget $BINARY_URL -O /tmp/azion.deb # Install the binary
# This assumes that you have dpkg installed on your system
sudo dpkg -i /tmp/azion.deb # Clean up the downloaded binary
rm /tmp/azion.deb echo "Installation completed successfully"
- Click the Save button.
This script will install the Azion binary in the following path: /usr/local/bin
- Run the following
POST
request in your terminal:
curl --location 'https://api.azionapi.net/edge_services/:id/resources' \
--header 'Accept: application/json; version=3' \
--header 'Authorization: Token [TOKEN VALUE]' \
--header 'Content-Type: application/json' \
--data '{ "content_type": "Shell Script", "name": "/scripts/install-cli/", "content": "#!/bin/bash\n\n# Define the URL of the binary to download\nBINARY_URL=\"https://github.com/aziontech/azion/releases/download/1.10.2/azion_1.10.2_linux_arm64.deb\"\n\n# Download the binary\nwget $BINARY_URL -O /tmp/azion.deb\n\n# Install the binary\n# This assumes that you have dpkg installed on your system\nsudo dpkg -i /tmp/azion.deb\n\n# Clean up the downloaded binary\nrm /tmp/azion.deb\n\necho \"Installation completed successfully\""
}'
Replace [TOKEN VALUE]
with your personal token, :id
with the ID of the edge service and inform the following parameters in the request body:
Property | Description | Required |
---|---|---|
content_type | Content type of the resource being created | Yes |
name | Name of the resource being created | Yes |
content | Content that defines actions performed when the resource state changes in the edge node | Yes |
Binding an edge service to an edge node
- On the upper-left corner of the page, open the Products menu, represented by three horizontal lines, and then select Edge Nodes.
- Select the edge node to which you want to bind a service.
- Go to the Services tab and click the + Service button.
- Choose the service
Azion CLI Installation
you’ve created. - Click the Save button.
- On the upper-left corner of the page, open the Products menu, represented by three horizontal lines, and then select Edge Nodes.
- Select the edge node to which you want to bind a service.
- Go to the Services tab and click the Add Service button.
- Choose the service
Azion CLI Installation
you’ve created. - Click the Save button.
- Run the following
GET
request in your terminal, replacing[TOKEN VALUE]
with your personal token and retrieve the edge node ID you wish to bind to an edge service:
curl --location 'https://api.azionapi.net/edge_nodes/' \
--header 'Accept: application/json; version=3' \
--header 'Authorization: Token [TOKEN VALUE]'
- Run the following
POST
request in your terminal:
curl --location 'https://api.azionapi.net/edge_nodes/:id/services' \
--header 'Accept: application/json; version=3' \
--header 'Authorization: Token [TOKEN VALUE]' \
--header 'Content-Type: application/json' \
--data '{ "service_id": :id, "variables": [ { "name": "string", "value": "string" } ]
}'
Replace [TOKEN VALUE]
with your personal token, :id
with the ID of the edge node and inform the ID of the service in the request body:
Property | Description | Required |
---|---|---|
service_id | ID of the edge service being bound to the edge node | Yes |
variables | Variables to be replaced during the processing on the edge node | No (requires checking) |
Accessing Azion CLI
After this process, in your edge node, access the folder:
Run:
The output will be similar to: