How to work with variables
During the deployment process on Orchestrator, you can work with variables. A variable can be set on an edge service and an edge node.
You can create edge node and edge services variables using:
Edge Services variables
- Go to Azion Console.
- On the top-left corner, select the Products menu, represented by three horizontal lines, and then Edge Services.
- Select the edge service to which you want to add a variable.
- In the Variables section, add the following variable:
name=azion- Click the Save button.
Now, you’ve created a variable related to a specific service. You need to access this variable through a resource.
- Navigate to the Resources tab.
- Click on + Resource or select the resource to which you wish to use the variable.
- Enter the Path of the resource.
- Choose the type Text.
- Add the following content to the content block:
I am using {{name}} Orchestrator- Click the Save button.
- Run the following
GETrequest in your terminal, replacing[TOKEN VALUE]with your personal token and retrieve the edge service ID to which you wish to add a variable:
curl --location 'https://api.azionapi.net/edge_services/' --header 'Accept: application/json; version=3' --header 'Authorization: Token [TOKEN VALUE]'- Create a variable related to the service. Run the following
PATCHrequest in your terminal, replacing[TOKEN VALUE]with your personal token and informing the variable’s name and value:
curl --location --request PATCH 'https://api.azionapi.net/edge_services/:id' \--header 'Accept: application/json; version=3' \--header 'Authorization: Token [TOKEN VALUE]' \--header 'Content-Type: application/json' \--data '{ "active": true, "name": "service", "variables": [ { "name": "name", "value": "azion" } ]}'Now, you’ve created a variable related to a specific service. You need to access this variable through a resource.
- Run the following
POSTrequest 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": "Text", "name": "/resource", "content": "I am using {{name}} Orchestrator"}'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 |
Edge Node variables
- Go to Azion Console.
- On the top-left corner, select the Products menu, represented by three horizontal lines, and then Edge Nodes.
- Select the edge node to which you want to add a variable.
- Go to the Services tab.
- Choose the service to which you want to apply the variable.
- Add the following content to the variables block:
name=azion2
- Click the Save button.
Now, you’ve created a variable related to a specific node. You need to access this variable through a resource.
- Go to Azion Console > Edge Services.
- Select the service related to the resource.
- Click on + Resource or select the resource where you wish to use the variable.
- Enter the Path of the resource.
- Choose the type Text.
- Add the following content to the content block:
I am using {{name}} Orchestrator
- Click the Save button.
- Run the following
GETrequest in your terminal, replacing[TOKEN VALUE]with your personal token and retrieve the edge node ID to which you wish to add a variable:
curl --location 'https://api.azionapi.net/edge_nodes/' \--header 'Accept: application/json; version=3' \--header 'Authorization: Token [TOKEN VALUE]'- Run the following
GETrequest in your terminal, replacing[TOKEN VALUE]with your personal token and:idwith the ID of the edge node, and retrieve the ID of the relation between the edge node and the chosen service:
curl --location 'https://api.azionapi.net/edge_nodes/:id/services' \--header 'Accept: application/json; version=3' \--header 'Authorization: Token [TOKEN VALUE]'- Run the following
PATCHrequest in your terminal:
curl --location --request PATCH 'https://api.azionapi.net/edge_nodes/:node_id/services/:bind_id' \--header 'Accept: application/json; version=3' \--header 'Authorization: Token [TOKEN VALUE]' \--data '{ "variables": [ { "name": "name", "value": "Azion" } ]}'Replace [TOKEN VALUE] with your personal token, :id with the ID of the edge node and :bind_id with the ID of the relation retrieved in step 2, informing the following properties in the request body:
| Property | Description | Required |
|---|---|---|
variables | Variables to be replaced during the processing on the edge node. | No |
Now, your variables are created and ready to be accessed during the execution on your nodes related to the specific service. It’s relevant to stress that when you have a variable with the same name configured on a service and on a node, the value stored on the node will prevail, for example:
Variable configured on the edge service:
name=azionVariable configured on the edge node
name=azion2When the resource is accessed, the value of the variable will be azion2 instead of azion.
To access the resource on the edge node, you need to access the file. You can access it through the filepath you informed during the creation of the resource.
Resource name:
/txt/testTo access it:
nano /txt/test