# Azion CLI origin

The Azion CLI `origin` commands create, list, describe, update, and delete the [origins](/en/documentation/platform/connectors/origins/) of an application. An origin is the server from which Azion retrieves the content of the application, such as a cloud server or an Object Storage bucket. Each origin belongs to one application, so every command takes `--application-id`. [Connectors](/en/documentation/platform/connectors/) replace the Origins feature, and the [connector commands](/en/documentation/devtools/cli/resources/connector/) manage them. The options every command accepts, such as `--format`, `--out`, and `-y`, are on [Global options](/en/documentation/devtools/cli/globals/).

---

## Create

`azion create origin` creates an origin in an application:

```bash
azion create origin [flags]
```

| Flag                       | Short | Type    | Default | Description                                                                                                                                                            |
| -------------------------- | ----- | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--addresses`              | —     | strings | —       | Addresses of the origin. Separate several addresses with commas.                                                                                                       |
| `--application-id`         | —     | int     | —       | ID of the application that holds the origin.                                                                                                                           |
| `--bucket`                 | —     | string  | —       | **Required** when `--origin-type` is `object_storage`. Name of the [Object Storage](/en/documentation/platform/object-storage/) bucket the origin serves content from. |
| `--file`                   | —     | string  | —       | Path to a JSON file with the attributes of the origin. Use `-` to read the JSON from standard input.                                                                   |
| `--hmac-access-key`        | —     | string  | —       | Access key for HMAC authentication.                                                                                                                                    |
| `--hmac-authentication`    | —     | string  | —       | Turns HMAC authentication on (`true`) or off (`false`) for the origin.                                                                                                 |
| `--hmac-region-name`       | —     | string  | —       | Region name for HMAC authentication.                                                                                                                                   |
| `--hmac-secret-key`        | —     | string  | —       | Secret key for HMAC authentication.                                                                                                                                    |
| `--host-header`            | —     | string  | —       | Host name of the server being accessed, which the origin receives in the `Host` header.                                                                                |
| `--name`                   | —     | string  | —       | Name of the origin.                                                                                                                                                    |
| `--origin-path`            | —     | string  | —       | Path appended to the URI when the request is forwarded to the origin. Leave it empty to forward the URI alone.                                                         |
| `--origin-protocol-policy` | —     | string  | —       | Protocol policy of the origin. An origin created without this flag reports `preserve`.                                                                                 |
| `--origin-type`            | —     | string  | —       | **Required** unless the `--file` JSON carries `origin_type`. Type of the origin. Without it, the command asks you to choose `single_origin` or `object_storage`.       |
| `--prefix`                 | —     | string  | —       | Path of the folder inside the bucket that holds the content. Applies only when `--origin-type` is `object_storage`.                                                    |

This command creates an origin named `my-origin` that retrieves content from `httpbin.org`:

```bash
azion create origin --application-id 1234567890 --name my-origin --addresses httpbin.org --host-header '${host}' --origin-type single_origin
```

The command prints the key of the origin, which the describe, update, and delete commands take in `--origin-key`:

```text
Created Origin with key 00000000-0000-0000-0000-000000000003
```

---

## List

`azion list origin` lists the origins of an application, 50 to a page:

```bash
azion list origin [flags]
```

| Flag               | Short | Type   | Default | Description                                                                                                                        |
| ------------------ | ----- | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `--application-id` | —     | int    | —       | ID of the application whose origins are listed.                                                                                    |
| `--details`        | —     | —      | —       | Adds the `ID`, `ORIGIN TYPE`, `ORIGIN PATH`, `ADDRESSES`, and `CONNECTION TIMEOUT` columns to the `ORIGIN KEY` and `NAME` columns. |
| `--filter`         | —     | string | —       | Name to filter the list by.                                                                                                        |
| `--order-by`       | —     | string | —       | Field to sort the list by, such as `name`.                                                                                         |
| `--page`           | —     | int    | `1`     | Number of the page to return.                                                                                                      |
| `--page-size`      | —     | int    | `50`    | Number of origins on each page.                                                                                                    |

The command needs `--order-by`. Without it, the command fails with this error, with or without `--details`, `--page`, and `--page-size`:

```text
Error: Failed to list your origins: '' is not a valid option for 'order_by'. Check your settings and try again. If the error persists, contact Azion support.
```

This command lists the origins of the application with ID `1234567890`, sorted by name, with every column:

```bash
azion list origin --application-id 1234567890 --order-by name --details
```

The command prints one row per origin:

```text
ORIGIN KEY                            NAME                ID      ORIGIN TYPE    ORIGIN PATH  ADDRESSES                                  CONNECTION TIMEOUT
00000000-0000-0000-0000-000000000003  my-origin           123485  single_origin               [{httpbin.org {<nil> true} primary true}]  60
```

The `ADDRESSES` column prints each address in this raw form. To read the settings of each address, use `azion describe origin` with `--format json`.

---

## Describe

`azion describe origin` prints the settings of one origin:

```bash
azion describe origin [flags]
```

| Flag               | Short | Type   | Default | Description                                  |
| ------------------ | ----- | ------ | ------- | -------------------------------------------- |
| `--application-id` | —     | int    | —       | ID of the application that holds the origin. |
| `--origin-key`     | —     | string | —       | Key of the origin to describe.               |

This command describes the origin with key `00000000-0000-0000-0000-000000000003`:

```bash
azion describe origin --application-id 1234567890 --origin-key 00000000-0000-0000-0000-000000000003
```

The command prints the ID, the key, the name, and the settings of the origin:

```text
Origin ID:                      123485
Origin Key:                     00000000-0000-0000-0000-000000000003
Name:                           my-origin
Origin Type:                    single_origin
Addresses:                      [{"address":"httpbin.org","is_active":true,"server_role":"primary","weight":null}]
Origin Protocol Policy:         preserve
Is Origin Redirection Enable:   false
Host Header:                    ${host}
Method:
Origin Path:
Connection Timeout:             60
Timeout Between Bytes:          120
Hmac Authentication:            false
Hmac Region Name:
Hmac Secret Key:
Hmac Access Key:
```

With `--format json`, the command prints the full object: `addresses`, `bucket`, `connection_timeout`, `hmac_access_key`, `hmac_authentication`, `hmac_region_name`, `hmac_secret_key`, `host_header`, `is_origin_redirection_enabled`, `method`, `name`, `origin_id`, `origin_key`, `origin_path`, `origin_protocol_policy`, `origin_type`, `prefix`, and `timeout_between_bytes`. Each item of `addresses` holds `address`, `is_active`, `server_role`, and `weight`.

A key that does not exist in the application fails with this error:

```text
Error: Failed to describe the Origin: The given ID or API's endpoint doesn't exist or isn't available. Check that the identifying information is correct. Check your settings and try again. If the error persists, contact Azion support.
```

---

## Update

`azion update origin` changes the name, the addresses, or the settings of an origin:

```bash
azion update origin [flags]
```

| Flag                       | Short | Type    | Default | Description                                                                                                                            |
| -------------------------- | ----- | ------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `--addresses`              | —     | strings | —       | Addresses of the origin. Separate several addresses with commas.                                                                       |
| `--application-id`         | —     | int     | —       | ID of the application that holds the origin.                                                                                           |
| `--bucket`                 | —     | string  | —       | Name of the Object Storage bucket the origin serves content from.                                                                      |
| `--file`                   | —     | string  | —       | Path to a JSON file with the attributes to change. Use `-` to read the JSON from standard input.                                       |
| `--hmac-access-key`        | —     | string  | —       | Access key for HMAC authentication.                                                                                                    |
| `--hmac-authentication`    | —     | string  | —       | Turns HMAC authentication on (`true`) or off (`false`) for the origin.                                                                 |
| `--hmac-region-name`       | —     | string  | —       | Region name for HMAC authentication.                                                                                                   |
| `--hmac-secret-key`        | —     | string  | —       | Secret key for HMAC authentication.                                                                                                    |
| `--host-header`            | —     | string  | —       | Host name of the server being accessed, which the origin receives in the `Host` header.                                                |
| `--name`                   | —     | string  | —       | New name of the origin.                                                                                                                |
| `--origin-key`             | —     | string  | —       | **Required**. Key of the origin to update. Without it, the command asks for the key, even when the `--file` JSON carries `origin_key`. |
| `--origin-path`            | —     | string  | —       | Path appended to the URI when the request is forwarded to the origin. Leave it empty to forward the URI alone.                         |
| `--origin-protocol-policy` | —     | string  | —       | Protocol policy of the origin.                                                                                                         |
| `--origin-type`            | —     | string  | —       | Type of the origin, such as `single_origin` or `object_storage`.                                                                       |
| `--prefix`                 | —     | string  | —       | Path of the folder inside the bucket that holds the content.                                                                           |

This command renames the origin with key `00000000-0000-0000-0000-000000000003` to `my-origin-renamed` and sets its origin path to `/anything`:

```bash
azion update origin --application-id 1234567890 --origin-key 00000000-0000-0000-0000-000000000003 --name my-origin-renamed --origin-path /anything
```

The command prints the key of the updated origin:

```text
Updated Origin with key 00000000-0000-0000-0000-000000000003
```

The settings you do not pass keep their values. In this example, the address `httpbin.org` stays unchanged.

---

## Delete

`azion delete origin` deletes an origin from an application:

```bash
azion delete origin [flags]
```

| Flag               | Short | Type   | Default | Description                                  |
| ------------------ | ----- | ------ | ------- | -------------------------------------------- |
| `--application-id` | —     | int    | —       | ID of the application that holds the origin. |
| `--origin-key`     | —     | string | —       | Key of the origin to delete.                 |

This command deletes the origin with key `00000000-0000-0000-0000-000000000004`:

```bash
azion delete origin --application-id 1234567890 --origin-key 00000000-0000-0000-0000-000000000004 -y
```

The command confirms the deletion:

```text
Origin 00000000-0000-0000-0000-000000000004 was successfully deleted
```

---

## Use a JSON file

`azion create origin` and `azion update origin` read the attributes of the origin from a JSON file with `--file`. Pass `--application-id` on the command line.

This file creates an origin named `my-site-origin` that retrieves content from `example.com`:

```json
{
  "name": "my-site-origin",
  "origin_type": "single_origin",
  "addresses": [
    {
      "address": "example.com"
    }
  ],
  "host_header": "${host}"
}
```

Pass the file to the create command:

```bash
azion create origin --application-id 1234567890 --file origin-create.json
```

The command prints the key of the origin:

```text
Created Origin with key 00000000-0000-0000-0000-000000000004
```

On update, the command does not read `origin_key` from the file, so pass `--origin-key` on the command line too. This file renames the origin with key `00000000-0000-0000-0000-000000000004`:

```json
{
  "origin_key": "00000000-0000-0000-0000-000000000004",
  "name": "my-site-origin-updated"
}
```

Pass the file and the key to the update command:

```bash
azion update origin --application-id 1234567890 --origin-key 00000000-0000-0000-0000-000000000004 --file origin-update.json
```

The command prints the key of the updated origin:

```text
Updated Origin with key 00000000-0000-0000-0000-000000000004
```

The fields the file leaves out keep their values.

---

## Related resources

- [Global options](/en/documentation/devtools/cli/globals.md): The options every command accepts, such as `--format`, `--out`, and `-y`.
- [Origins](/en/documentation/platform/connectors/origins.md): What each origin type does and how the bucket and prefix of an Object Storage origin work.
- [Azion CLI application](/en/documentation/devtools/cli/resources/application.md): The commands that create and list the applications that hold your origins.
- [Azion CLI connector](/en/documentation/devtools/cli/resources/connector.md): The commands that manage connectors, which replace the Origins feature.
