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

Guides

How to create a web application using Azion CLI

This guide will present the steps for creating a web application using the Azion CLI commands.

Note: to create a web application with the Azion CLI using a detailed step-by-step, follow the tutorials Web application and Building a web application using Azion CLI from scratch. The tutorials are recommended if you have doubts or difficulties to follow the steps in this guide.

Requirements: Before starting to build your web application, you need to:

  • Download and install the Node.js JavaScript runtime compatible with your operating system from the official website; this installation includes the npm package manager.
  • Download and install the Azion CLI, version 0.46.0 or higher, as shown in the topic Installing.
  • Create a personal token in RTM and configure it in CLI. See the topic Authorization on the Azion Platform.

To create a web application using the CLI with the JavaScript template, follow these steps:

  1. Start a Node.js project in the application folder with the command npm init -y.

  2. Create a file called index.js with the application code.

  3. Run the command:

    azioncli edge_applications init --name "my-app" --type javascript

  4. Run the command:

    azioncli edge_applications build

  5. Run the command:

    azioncli edge_applications publish

    The CLI response will be similar to the example below:

     Building your Web Application
    
     Your Web Application was built successfully
     Created Edge Function my-app with ID 1909
     Created Edge Application my-app with ID 123456789
     Created Domain my-app with ID 123456789
     Your Web Application was published successfully
    
     To visualize your application access the domain: xxxxxxx.map.azionedge.net
    
     Content is being propagated to all Azion POPs and it might take a few minutes for all edges to be up to date
    
  6. Use the URL that appears at the end of the message in step 5 to open your web application in your Internet browser.

Note: publishing a web application via RTM or CLI is not an instantaneous process. There is a time to propagate and configure the application in Azion’s edge locations. It may be necessary to wait a few minutes for the URL to be activated and the application page to be effectively displayed in the browser. Browse RTM to view the new elements that the CLI commands created in this guide.

Tip: if you want to retrieve your application’s URL, on RTM select Products Menu > Domains. You will see a list of your domains, including the one created by the CLI commands in this guide.

Configuring the output of edge_applications commands from the CLI

The outputs of CLI edge_applications commands in the terminal are presented, by default, only as minimal and essential information for the developer. If necessary, you can configure your application to observe all outgoing messages, regardless of whether errors occur or not.

This setting can be useful for analyzing the command responses in more detail and correcting possible flaws in the project. However, detailed outputs can quickly clutter up your terminal screen with too much information. If necessary, follow the procedure below to change the display of command responses.

To configure the output messages of the Azion CLI edge_applications commands, follow the steps below:

  1. After initializing a web application with the edge_applications init command, access the automatically created azion directory.
  2. Open the config.json file.
  3. In the init and build sections, change the "output-ctrl": "<value>" lines to the following values:
    • on-error: output messages will be detailed only when an error occurs. This is the default value for the key.
    • disable: the output messages will always be complete, regardless of the occurrence or not of errors in the execution of the commands.
          {	
            "start": {	
                "cmd": "...",	
                "env": "./azion/webdev.env",	
                "output-ctrl": "on-error"	
             },	
            "build": {	
                "cmd": "...",	
                "env": "./azion/webdev.env",	
                "output-ctrl": "on-error"	
             }	
           }	
      

      Note: don’t forget the comma after the "env" line: "./azion/webdev.env".

  4. Save the file and restart the terminal.

Ready! The next CLI commands will display messages with the level of detail specified in the above configuration.


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