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

First steps

In this topic you’ll learn how to install and get started with the Azion CLI.

Note: in order to simplify the text, from this point onwards the Azion CLI will be referred as CLI.

Installing

There are two ways to install the CLI:

  • Using package managers, such as:
    • Homebrew4 Package Manager
    • RPM Package Manager (RPM)
    • Dpkg Package Manager (Dpkg)
    • Alpine Package Keeper (apk)
  • Installing the CLI manually.

To install the CLI using the package managers, follow these steps:

  1. To use the RPM, Dpkg, and apk package managers, go to our releases page and download the desired package. If you choose this option, you can go to step 3.
  2. To use Homebrew, visit the official package installer website and follow the installation instructions located on its homepage.

    Note: there is no need to download packages from our releases page as in step 1.

  3. Execute the command in the Installation Command column of the table below for the chosen installation package. The CLI will be installed automatically.

    Note: in the RPM, Dpkg, and apk package managers install commands, replace the <downloaded_file> placeholder with the installation package file downloaded in step 1. In the case of Homebrew package manager, only run the command exactly as shown in the table.

    Package Manager Website Documentation Install Command
    Homebrew Homebrew package manager Homebrew Support Documentation brew install aziontech/tap/azioncli
    RPM RPM package manager RPM Support Documentation sudo rpm -i <downloaded_file>
    Dpkg Debian® 5 operating system Dpkg Support Documentation sudo dpkg -i <downloaded_file>
    apk Alpine Linux® 6operating system support documentation apk apk add <downloaded_file>
  4. Run the azioncli --version command to test the installation. The CLI displays on the terminal its installed current version number.

Alternatively, visit the package manager websites using the links in the table of the step 3 and follow the installation instructions by clicking on the links in the Documentation column.

To install the CLI manually, follow these steps:

  1. Create a folder on your computer’s file system where you want to run the CLI commands; for example: my-cli.

    Tip: you can create a folder on your file system directly using the terminal. To do this, run the command mkdir my-cli, where my-cli is the name of the folder.

  2. Download the desired architecture binary, whose supported platforms are listed below; the azioncli binary file is downloaded into the Downloads folder of the computer’s file system.

    Operating System Architecture Azion CLI URL
    macOS x86_64 https://downloads.azion.com/darwin/x86_64/azioncli
    macOS ARM64 https://downloads.azion.com/darwin/arm64/azioncli
    FreeBSD® 7 x86_64 https://downloads.azion.com/freebsd/x86_64/azioncli
    FreeBSD ARM64 https://downloads.azion.com/freebsd/arm64/azioncli
    Linux® 8 x86_32 https://downloads.azion.com/linux/x86_32/azioncli
    Linux x86_64 https://downloads.azion.com/linux/x86_64/azioncli
    Linux ARM32 https://downloads.azion.com/linux/arm32/azioncli
    Linux ARM64 https://downloads.azion.com/linux/arm64/azioncli

    Alternatively, you can download it via command line. In the example below, the link refers to the Linux/x86_64 architecture. If you want to use another architecture, just change the URL to the desired operating system or architecture with the command below:

    curl -O https://downloads.azion.com/linux/x86_64/azioncli

  3. Copy the azioncli file, downloaded in the previous step, to the folder created in step 1 with your operating system’s file manager.

  4. Open the terminal and change the working directory to the folder you created in step 1 by running the cd <path> command with the path of the my-cli folder on your computer.

    Tip: you can easily open the terminal directly with the full path of a folder by dragging it from your operating system’s file manager to the terminal application icon. This tip works on most operating systems.

  5. Confirm the existence of the azioncli binary file in the project folder with the ls command.

    Terminal response:

      azioncli
    
  6. Grant permission to run the azioncli binary on your computer with the following command:

    chmod +x azioncli

    If the terminal doesn’t display any messages, it means that the command was executed without errors.

    Note: if your computer uses the macOS operating system, it’ll present a window with an error message preventing the execution of the CLI. See the procedure for release the CLI to run on the macOS operating system, presented later.

  7. Run the command:

    Note: the command below allows you to run azioncli from any folder on your computer’s file system. You can then delete the azioncli files in your project directory and the Downloads folder by running the rm azioncli command in the respective directories.

    sudo cp azioncli /usr/local/bin

    The command is optional. In case you didn’t want to run the command sudo cp azioncli /usr/local/bin, remember to have a copy of the azioncli binary in your project folder and run it with the characters ./ in front, as in ./azioncli <command>. Otherwise, an error message will be displayed stating that the azioncli command was not found.

    The sudo command asks for the password of the user with computer administrator powers. Enter your password and press the ENTER or RETURN key. Characters are not displayed while typing.

  8. Test the CLI installation with the following command; a help screen will appear on the monitor.

    azioncli --help

    CLI response:

     Usage:	
     azioncli <command> <subcommand> [flags]	
     azioncli [flags]	
     		
     azioncli [command]	
        
     Available Commands:	
     configure      Authorizes connections with Azion platform’s services	
     edge_functions Manages your Azion account's Edge Functions	
     edge_services  Manages your Azion account's Edge Services	
     help           Help about any command	
     version        Returns the CLI version	
     edge_applications         Creates edge applications on Azion's platform	
       
     Flags:	
     -h, --help      Displays more information about the Azion CLI	
     -v, --version   version for azioncli	
     Use "azioncli [command] --help" for more information about a command.
    

    If a window with an alert message appears on the screen informing you that the developer can’t be identified, click on the Cancel button. The terminal responds with the following message:

      zsh: killed azioncli --help
    

    Then, follow the steps in the Running the CLI on macOS Operating System topic. After releasing the execution, rerun the command azioncli --help or azioncli --version to verify that the Azion CLI is working normally. In the case of the azioncli --version command, the response should be similar to the one shown below, or a higher version:

      azioncli version 0.46.0
    

    Note: the CLI release process presented above is for the macOS operating system. If you use another operating system, follow the procedures provided in the system documentation.

Done! From now on you can run CLI commands. To help you, it has an interactive and integrated help system in order to facilitate its use.

In the next topic, you’ll learn how to enable the use of the Azion CLI on the macOS operating system, if you have not already configured this setting.


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

Running the CLI on macOS Operating System

To enable the CLI to run on your computer, follow these steps:

Note: the Apple menu is the small logo of the Apple Inc. company, located in the upper left corner of your Mac computer screen.

  1. Go to Apple menu > System Preferences.
  2. In the System Preferences window, select the Security & Privacy section.
  3. Select the General tab if it’s not already selected; you’ll see a message indicating that the CLI cannot be executed.
  4. Click the Allow Anyway button.

    Note: the next time you run a CLI command, the macOS operating system will open a confirmation window informing you that it can’t verify the azioncli developer.

  5. Run the command below to force the confirmation window to appear:

    azioncli --help

  6. Click the Open button in the confirmation window.

The azioncli --help command will be executed, and you won’t need to repeat these procedures again. Once configured, access to the CLI will become permanent on your computer’s macOS operating system.

If your computer uses another operating system, check the necessary procedures in the corresponding documentation.

In addition to operating system authorization, you’ll also need to manage your Personal Tokens to execute certain CLI commands. Like them, you authorize commands on the Azion platform. See the following topic.


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

Authorization on the Azion Platform

To manage your settings, you must generate a token that identifies you on the Azion platform. Otherwise, the CLI will display an error message in the terminal stating that the token is invalid or is expired.

See the following example, in which we use the configure command to set up a non-existent token:

azioncli configure --token mytokeninAzion123

As the “mytokeninAzion123token doesn’t exist, the CLI shows the following error message:

Usage:
azioncli configure [flags]

Examples:
$ azioncli configure --help
$ azion configure --token azionxxxxxxxxxxxxxxxx

Flags:
-h, --help           Displays more information about the configure command
-t, --token string   Saves a given personal token locally to authorize CLI commands

Error: The provided token is invalid. You must create a new token and configure it to use with the CLI. Manage your personal tokens on RTM using the Account Menu > Personal Tokens and confi

Note that the CLI doesn’t simply display the error message. To help you, it divides the text into three distinct parts:

  1. Usage - the command syntax.
  2. Flags - the command modifiers.
  3. Error - the error message itself.

The Invalid token error occurs whenever an invalid token is used in certain CLI commands.

For more information on how to create and manage your personal tokens, please use Azion API or the Personal Tokens page from our documentation.

You can locally store an existing and valid token using the following command:

azioncli configure --token <your_token>

All subsequent commands will use that same token and will consider all permissions granted to the account that token belongs to.

You can replace your Personal Token at any time by repeating the command above.


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

Hands on with Azion CLI

In order to observe in practice how the CLI works, let’s use Edge Functions as an example. It’s common for an Edge Application to use several functions present in an Edge Library.

Note: the following example is only intended to provide a brief introduction to the CLI. The commands will be detailed later in this documentation. In this example, you can easily:

  • List the Edge Functions contained in your Edge Library.
  • Create a new function.
  • Delete an existing function.

Tip: to view your current Edge Functions, go to Real-Time Manager (RTM) > Products Menu and select Edge Functions in the EDGE LIBRARIES section. The Azion - Hello World function is now available by default so you can practice even if you haven’t created any Edge Function yet.

Note: if you have and older RTM account, the Azion - Hello World function may not be available.

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

Prerequisites: for the following examples, you are required to:

  • Install the Azion CLI.
  • Create or use a Personal Token that identifies you on the Azion platform.

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

Note that the azioncli edge_functions list command responded with a table consisting of four columns:

  • ID: unique identifier of the Edge Function on the Azion 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).

In this example, the table is composed of two functions:

  • Azion - Hello World, ID 3976.
  • func01, ID 6598.

As previously mentioned, the Azion - Hello World function was already available in the library. Also note that both functions were developed in the JavaScript9 programming language and that both are currently active.

Let’s now 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 in a practical and direct way 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 check it, let’s 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

Note that, 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.

Let’s now delete the newly created my-new-ef function. To do so, 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 simple example.


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

Using the Autocomplete feature

Azion CLI’s Autocomplete functionality increases productivity when typing commands, especially those that require longer texts.

For example, instead of typing the command azioncli you could simply type az, and then press the tab key. The command’s text will be automatically supplemented.

To install the CLI Autocomplete functionality, visit the Setup Autocomplete topic.

Tip: after installing the Autocomplete feature, remember to restart the terminal to activate the functionality.

Run some tests to familiarize yourself with Autocomplete. Here’s how to quickly type the azioncli edge_applications init command with little effort:

Note: the → symbol means the tab key on the keyboard.

      azwi

The result will be the text azioncli edge_applications init with the keystroke of only seven keys instead of 20, considering that the functionality automatically includes a blank space after each command.

If the text complement has more than one command or subcommand option, Autocomplete automatically shows a list of options when pressing the → key. Try the example below:

      aze → →

user@computer ~ % azioncli edge_
edge_functions -- Manages your Azion account's Edge Functions
edge_services -- Manages your Azion account's Edge Services

Note that, when you type the last →, Autocomplete presents a list with two subcommands and their respective short descriptions. To select one of them, repeatedly press the → until you choose the desired subcommand. Then, press the space key on the keyboard to finish entering the command.

Now all you have to do is enjoy the usefulness and functionality of Autocomplete to speed up the development of your projects with Azion CLI!

Now that you’ve reached the end of this introductory Azion CLI tutorial, follow the specific guides for each command with more detailed explanations on how to explore the full potential of the CLI.


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