# Azion CLI create

With the `azion create [resource]` command you can create:

- [Application](#applications).
- [Functions](#functions).
- [Rules engine](#rules-engine).
- [Cache settings](#cache-settings).
- [Firewall](#firewall).
- [Firewall instance](#firewall-instance).
- [Firewall rule](#firewall-rule).
- [WAF](#waf).
- [WAF exceptions](#waf-exceptions).
- [Network list](#network-list).
- [Workloads](#workloads).
- [Workload deployment](#workload-deployment).
- [Connectors](#connectors).
- [Variables](#variables).
- [Personal tokens](#personal-tokens).
- [Profile](#profile).
- [Object Storage bucket](#edge-storage-bucket).
- [Object Storage object](#edge-storage-object).


:::note 
In case one or more required fields aren't informed through the specific flags, an interactive message prompts and asks for the missing information.
:::

---

## Applications

#### Usage

```bash
azion create edge-application --name "naruno"
```

#### Required flags

##### name

The `--name` flag sets the name of the application being created. It's required if the `--file` flag isn't used.

#### Optional flags

##### address

The `--address` option specifies the address of the origin server.

##### browser-cache-settings

The `--browser-cache-settings` option configures the amount of time that content is cached in the user's browser. Possible values are `honor` or `override`.

##### browser-cache-settings-maximum-ttl

The `--browser-cache-settings-maximum-ttl` option defines the maximum time to live (TTL) of cached resources in the browser. It sets a time limit for how long resources can be cached in the browser, in seconds.

##### cdn-cache-settings

The `--cdn-cache-settings` option configures how Azion caches content at the edge. Possible values are `honor` or `override`.

##### cdn-cache-settings-maximum-ttl

The `--cdn-cache-settings-maximum-ttl` option defines the maximum time to live (TTL) of cached resources in the edge. It sets a time limit for how long resources can be cached on the edge nodes, in seconds.

##### delivery-protocol

The `--delivery-protocol` option specifies whether the data should be delivered via HTTP or HTTPS.

##### host-header

The `--host-header` option allows customization of the `Host` header.

##### http-port

The `--http-port` flag specifies the application's HTTP delivery port. The default is `80`.

##### https-port

The `--https-port` flag specifies the application's HTTPS delivery port. The default is `443`.

##### http3

The `--http3` option enables delivery in HTTP/3.

##### file

The `--file` option specifies a path to a JSON file containing the attributes of the application being created. It can also read from stdin using `-`.

Attributes inside a `JSON` file:

```json
{
    "name": "borus",
    "delivery_protocol": "http",
    "origin_type": "single_origin",
    "address": "www.new.api",
    "origin_protocol_policy": "preserve",
    "host_header": "www.new.api",
    "browser_cache_settings": "override",
    "browser_cache_settings_maximum_ttl": 20,
    "cdn_cache_settings": "honor",
    "cdn_cache_settings_maximum_ttl": 60
}
```

##### origin-protocol-policy

The `--origin-protocol-policy` option specifies the type of connection between the edge nodes and the origin. Possible values are `preserve`, `http`, or `https`.

##### origin-type

The `--origin-type` option specifies the type of the origin. Possible values are `single_origin` (default value), `load_balancer`, or `live_ingest`.

##### supported-ciphers

The `--supported-ciphers` option determines which cipher suite will be used in the TLS connections of your application.

##### websocket

The `--websocket` option allows you to establish the WebSocket communication protocol between your application and your users under the reverse proxy architecture.

##### debug-rules

The `--debug-rules` option allows you to check whether rules or rule sets created using the Rules Engine module for Applications or Firewall have been successfully executed in your application.

---

## Functions

#### Usage

```bash
$ azion create edge-function --name "<function_name>" --code "<path_to_code>" --active <true_or_false> [--args "<path_to_args_file>"] [--file "<file_path>"]
```

#### Required flags

##### name

The `--name` flag sets the name of the function being created.

##### code

The `--code` flag sets the path to the function's code.

##### active

The `--active` flag specifies whether the function is active or not. Accepts `true` or `false`.

#### Optional flags

##### args

The `--args` flag sets the path to the function's arguments JSON file.

##### file

The `--file` flag specifies the file path to create an function. You can use `-` for reading from stdin.

Attributes inside a `JSON` file:

```json
{
  "active": true,
  "code": "async function handleRequest(request) {\n return new Response(\"Hello!\",\n   {\n       status:204\n   })\n}\naddEventListener(\"fetch\", event =\u003e {\n event.respondWith(handleRequest(event.request))\n})",
  "name": "func"
}
```

##### help

The `--help` option displays more information about the `azion create edge-function` command.

---


## Rules engine

#### Usage

```bash
azion create rules-engine --application-id 1679423488 --phase "response" --file `./file.json`
```

#### Required flags

##### application-id

The `--application-id` flag sets the unique identifier for an application.

##### phase

The `--phase` flag specifies the phase for the rule. It's either `request` or `response`.

#### Optional flags

##### file

The `--file` flag specifies the path to a JSON file containing the attributes of the rule that'll be created. You can use `-` to read from stdin.

Attributes inside a `JSON` file:

```json
{
    "name": "New Rule 534322",
    "description": "This is a very basic rule engine description",
    "criteria": [
        [
            {
                "conditional": "if",
                "variable": "${uri}",
                "operator": "starts_with",
                "input_value": "/"
            }
        ]
    ],
    "behaviors": [
        {
            "name": "deliver",
            "target": "io"
        }
    ]
}
```

##### help

The `--help` flag displays more information about the `azion create rules-engine` action.

---

## Cache settings

#### Usage

```bash
$ azion create cache-setting --application-id 1673635839 --name "phototypesetting"
```

#### Required flags

##### application-id

The `--application-id` flag sets the unique identifier for the application.

##### name

The `--name` flag sets the name of the Cache Settings configuration being created.

#### Optional flags

##### adaptive-delivery-action

The `--adaptive-delivery-action` option informs the Cache Settings configuration adaptive delivery action. The default value is `ignore`.

##### browser-cache-settings

The `--browser-cache-settings` option configures the amount of time that the content is cached in the web browser. The default value is `honor`.

##### browser-cache-settings-maximum-ttl

The `--browser-cache-settings-maximum-ttl` option informs Browser Cache Settings configuration maximum TTL.

##### cache-by-cookies

The `--cache-by-cookies` option defines if cache by cookies is active. The default value is `ignore`.

##### cache-by-query-string

The `--cache-by-query-string` option defines how the content should be cached according to variations of the Query String in URLs. The default value is `ignore`.

##### cdn-cache-settings

The `--cdn-cache-settings` option configures the amount of time Azion's applications take to cache the content. It can either Honor Origin Cache Headers or Override Cache Settings. The default value is `honor`.

##### cnd-cache-settings-maximum-ttl

The `--cnd-cache-settings-maximum-ttl` option informs CDN Cache Settings configuration maximum TTL. The default value is `60`.

##### cookie-names

The `--cookie-names` option distinguishes objects in the Azion cache by the name/value of cookies.

##### enable-caching-for-options

The `--enable-caching-for-options` option defines if caching for options is active. The default value is `false`.

##### enable-caching-for-post

The `--enable-caching-for-post` option defines if caching for post is active.

##### enable-caching-string-sort

The `--enable-caching-string-sort` option defines if caching string sort is active.

##### file

The `--file` option specifies the path to a JSON file containing the attributes of the Cache Settings configuration that'll be created. You can use `-` for reading from stdin.

Attributes inside a `JSON` file:

```json
{
  "name": "thename",
  "browser_cache_settings": "honor",
  "browser_cache_settings_maximum_ttl": 0,
  "cdn_cache_settings": "honor",
  "cdn_cache_settings_maximum_ttl": 60,
  "cache_by_query_string": "ignore",
  "query_string_fields": ["aa"],
  "enable_query_string_sort": true,
  "cache_by_cookies": "ignore",
  "cookie_names": ["aa"],
  "adaptive_delivery_action": "ignore",
  "device_group": [],
  "enable_caching_for_post": true,
  "l2_caching_enabled": false,
  "is_slice_configuration_enabled": false,
  "is_slice_edge_caching_enabled": false,
  "is_slice_l2_caching_enabled": false,
  "slice_configuration_range": null,
  "enable_caching_for_options": true,
  "enable_stale_cache": true,
  "l2_region": null
}
```

##### help

The `--help` option displays more information about the `azion create cache-setting` command.

#### l2-caching-enabled

The `--l2-caching-enabled` option defines if Tiered Cache is active.

#### query-string-fields

The `--query-string-fields` option gives a list of query string parameters to be considered in the Cache Settings configuration, segregating the cache to the same URL.

#### slice-configuration-enabled

The `--slice-configuration-enabled` option defines if Large File Optimization is active.

#### slice-configuration-range

The `--slice-configuration-range` option informs the fragment range.

#### slice-l2-caching-enabled

The `--slice-l2-caching-enabled` option defines if Large File Optimization for Tiered Cache is active.

---

## Firewall

Creates a Firewall.

#### Usage

```bash
azion create firewall --name "<firewall-name>"
```

#### Required flags

##### name

The `--name` flag sets the name of the firewall being created.

#### Optional flags

##### file

The `--file` flag specifies the path to a JSON file containing the attributes of the firewall that will be created. You can use `-` for reading from stdin.

##### help

The `--help` flag displays more information about the `azion create firewall` command.

---

## Firewall instance

Creates a new Firewall Function Instance.

#### Usage

```bash
azion create firewall-instance --firewall-id <firewall-id> --name "<instance-name>"
```

#### Required flags

##### firewall-id

The `--firewall-id` flag sets the unique identifier for the firewall.

##### name

The `--name` flag sets the name of the firewall instance being created.

#### Optional flags

##### file

The `--file` flag specifies the path to a JSON file containing the attributes of the firewall instance. You can use `-` for reading from stdin.

##### help

The `--help` flag displays more information about the `azion create firewall-instance` command.

---

## Firewall rule

Creates a new Firewall Rule.

#### Usage

```bash
azion create firewall-rule --firewall-id <firewall-id> --file "./rule.json"
```

#### Required flags

##### firewall-id

The `--firewall-id` flag sets the unique identifier for the firewall.

#### Optional flags

##### file

The `--file` flag specifies the path to a JSON file containing the attributes of the firewall rule. You can use `-` for reading from stdin.

##### help

The `--help` flag displays more information about the `azion create firewall-rule` command.

---

## WAF

Creates a WAF (Web Application Firewall).

#### Usage

```bash
azion create waf --name "<waf-name>"
```

#### Required flags

##### name

The `--name` flag sets the name of the WAF being created.

#### Optional flags

##### file

The `--file` flag specifies the path to a JSON file containing the attributes of the WAF. You can use `-` for reading from stdin.

##### help

The `--help` flag displays more information about the `azion create waf` command.

---

## WAF exceptions

Creates a new WAF Exception.

#### Usage

```bash
azion create waf-exceptions --waf-id <waf-id> --file "./exception.json"
```

#### Required flags

##### waf-id

The `--waf-id` flag sets the unique identifier for the WAF.

#### Optional flags

##### file

The `--file` flag specifies the path to a JSON file containing the attributes of the WAF exception. You can use `-` for reading from stdin.

##### help

The `--help` flag displays more information about the `azion create waf-exceptions` command.

---

## Network list

Creates a Network List.

#### Usage

```bash
azion create network-list --name "<list-name>"
```

#### Required flags

##### name

The `--name` flag sets the name of the network list being created.

#### Optional flags

##### file

The `--file` flag specifies the path to a JSON file containing the attributes of the network list. You can use `-` for reading from stdin.

##### help

The `--help` flag displays more information about the `azion create network-list` command.

---

## Workloads

Creates a domain.

#### Usage

```bash
azion create domain --application-id 1231 --name "domainName"
```

#### Required flags

##### application-id

The `--application-id` flag sets the application's unique identifier.

##### name

The `--name` flag sets the domain's name.

#### Optional flags

##### active

The `--active` option specifies if the domain is active. The default value is `true`.

##### cname-access-only

The `--cname-access-only` option specifies if the domain is accessed only through the CNAMEs. The default value is `false`.

##### cnames

The `--cnames` option is a list of domains' CNAMEs to associate with the domain.

##### digital-certificate-id

The `--digital-certificate-id` option sets the digital certificate's unique identifier. It can be an *integer*, *null*, or the string `lets_encrypt`. If `lets_encrypt` is informed, then a Let's Encrypt certificate will be created for you.

##### help

The `--help` option displays more information about the `azion create domain` action.

##### file

The `--file` option specifies a path to a JSON file containing the attributes that will be updated. You can use `-` to read from stdin.

Attributes inside a `JSON` file:

```json
{
    "cnames": [],
    "name": "one",
    "edge_application_id": 1234635841,
    "cname_access_only": false,
    "is_active": false
}
```

---

## Workload deployment

Creates a new Workload Deployment.

#### Usage

```bash
azion create workload-deployment --workload-id <workload-id>
```

#### Required flags

##### workload-id

The `--workload-id` flag sets the unique identifier for the workload.

#### Optional flags

##### file

The `--file` flag specifies the path to a JSON file containing the attributes of the workload deployment. You can use `-` for reading from stdin.

##### help

The `--help` flag displays more information about the `azion create workload-deployment` command.

---


## Connectors

#### Usage

```bash
$ azion create origin --application-id <application-id> --name "<origin-name>" --addresses "<comma-separated-addresses>"
```

#### Required flags

#### application-id

The `--application-id` flag sets the unique identifier for the application in which the origin will be created.

#### name

The `--name` flag sets the name of the origin being created.

#### addresses

The `--addresses` flag passes a list of addresses linked to the origin. Multiple addresses should be separated by commas.

#### Optional flags

#### file

The `--file` flag specifies the path to a JSON file containing the attributes of the origin that will be created. You can use `-` for reading from stdin.

Attributes inside a `JSON` file:

```json
{
 "name": "Create Or22i21231222n2",
 "addresses": [
  {
   "address": "httpbin.org"
  }
 ],
 "host_header": "asdf.asdfom"
}
```

#### hmac-access-key

The `--hmac-access-key` flag informs the Hmac Access Key.

#### hmac-authentication

The `--hmac-authentication` flag specifies whether Hmac Authentication is used or not.

#### hmac-region-name

The `--hmac-region-name` flag informs the Hmac region name.

#### hmac-secret-key

The `--hmac-secret-key` flag informs the Hmac Secret Key.

#### host-header

The `--host-header` flag specifies the hostname of the server being accessed.

#### origin-path

The `--origin-path` flag defines the path to be appended to the URI when forwarding the request to the origin. Leave it blank to use only the URI.

#### origin-protocol-policy

The `--origin-protocol-policy` flag tells the protocol policy used in the origin.

#### origin-type

The `--origin-type` flag identifies the source of a record. Accepted values:
- `single_origin` (default)
- `load_balancer`
- `live_ingest`
- `object_storage`

#### bucket

The `--bucket` flag informs the name of the Object Storage bucket. **Required when origin-type is equal to `object_storage`**.

#### prefix 

The `--bucket` flag informs the path or location within the bucket from which the content must be retrieved. **Optional and only used when origin-type is equal to `object_storage`**

#### help

The `-h` or `--help` option displays more information about the `azion create origin` action.

---


## Variables

Create a new environment variable or secret to be used inside your functions.

#### Usage

```bash
  azion create variables  --key "Content-Type" --value "string" --secret false
```

#### Required flags if the --in flag isn't informed

#### key

The `--key` flag provides the variable's key.

#### value

The `--value` flag provides the variable's value.

#### secret

The `--secret` flag indicates whether the value is meant to be confidential. The default value is `true`.

:::note
Variables with names containing the following substrings will be sent as **secrets** to the Azion environment by default:

  - password
  - pwd
  - secret
  - key
  - hash
  - encrypted
  - passcode
  - auth
  - token
  - secret
:::

#### Optional flags

#### file

The `--file` flag informs the file path to the file containing all attributes of the variable being created. You can use `-` for reading from stdin.

Attributes inside a `JSON` file:

```json
{
    "key": "Content-Type",
    "value": "json",
    "secret": false
}
```

#### help

The `--help` option displays more information about the `azion create variables` command.

---

## Personal tokens

#### Usage

```sh
azion create personal-token --name "newToken" --expiration "9m" 
```

#### Optional flags

##### file 

The `--file` option informs the file path to a JSON file containing all attributes of the personal token being created.

Attributes inside a `JSON` file:

```sh
{
    "name": "my token",
    "expires_at": "9m"
}
```

##### help

The `--help` option displays more information about the `create` subcommand.

#### Required flags when --file isn't informed

##### description 

The `--description` option informs the personal token's description.

##### expiration 

The `--expiration` option informs the personal token's expiration.

##### name

The `--name` option informs the personal token's name.

---

## Profile

Create a new profile for the Azion CLI.

#### Usage

```bash
azion create profile --name "<profile-name>"
```

#### Required flags

##### name

The `--name` flag sets the name of the profile being created.

#### Optional flags

##### file

The `--file` flag specifies the path to a JSON file containing the attributes of the profile. You can use `-` for reading from stdin.

##### help

The `--help` flag displays more information about the `azion create profile` command.

---

<a id="edge-storage-bucket"></a>
## Object Storage bucket

#### Usage

```bash
azion create edge-storage bucket --name "zorosola" --edge-access 'read_only'
```

#### Required flags

##### edge-access

The `--edge-access` flag indicates the type of permission for actions within the bucket. Possible values include `read_only`, `read_write`, or `restricted`.

##### name 

The `--name` flag defines the name of the Object Storage bucket. 

#### Optional flags

##### file

The `--file` option specifies the path to a JSON file containing the attributes of the bucket that will be created. Alternatively, you can use '-' for reading from stdin.

Attributes inside a `JSON` file:

```json
{
	"name": "arthur-morgan",
	"edge_access": "read_only"
}
```

##### help

The `--help` option displays more information about the 'create edge-storage bucket' command.

---

<a id="edge-storage-object"></a>
## Object Storage object 

#### Usage

```bash
$ azion create edge-storage object --bucket-name 'mynewbucket' --object-key 'path/to/my/remote/file.txt' --source './local/file.txt'
```

#### Required flags

##### bucket-name

The `--bucket-name` flag sets the name of the Object Storage bucket where the object will be stored.

##### object-key

The `--object-key` flag sets the name of the object to be stored in the bucket. It can also be used to indicate a full file path (such as 'path/to/file/bucket/file.txt').

##### source

The `--source` flag defines the path to the local file to be uploaded to the bucket. The path should be absolute.

#### Optional flags    

##### file

The `--file` option allows you to specify a path to a JSON file containing the attributes of the objects to be created. You can use `-` for reading from stdin.

Attributes inside a `JSON` file:

```json
{
  "bucket-name": "name",
  "object-key": "key",
  "source": "fixtures/index.html"
}
```

##### help

The `-h` or `--help` option displays more detailed information about the `azion create edge-storage object` command.