# Azion CLI update

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

- [Applications](#applications).
    - [Functions](#functions-1).
    - [Rules engine](#rules-engine).
    - [Cache settings](#cache-settings).
    - [Workloads](#workloads).
    - [Connectors](#connectors).
    - [Variables](#variables).
    - [Object Storage object](#object-storage-bucket).
    - [Object Storage object](#object-storage-object).
    - [WAF](#waf).
    - [WAF exceptions](#waf-exceptions).

:::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 update edge-application --application-id <application_id> [flags]
```

#### Required flags

##### application-id

The `--application-id` flag specifies the application's ID to be updated.

#### Optional flags

##### application-acceleration

The `--application-acceleration` flag specifies if the application has the [Application Acceleration](/en/documentation/products/build/applications/application-accelerator/) module active.

##### delivery-protocol

The `--delivery-protocol` flag specifies the application's [delivery protocol](/en/documentation/products/build/applications/main-settings/).

##### device-detection

The `--device-detection` flag specifies whether the application has Device Detection active or not.

##### edge-firewall

The `--edge-firewall` flag specifies whether the application has an associated firewall active or not.

##### edge-functions

The `--edge-functions` flag specifies if the application has the [Functions](/en/documentation/products/build/applications/functions/) module active.

##### http-port

The `--http-port` flag specifies the application's HTTP Port. By default, it's `80`.

##### https-port

The `--https-port` flag specifies the application's HTTPS Port. By default, it's `443`.

##### image-optimization

The `--image-optimization` flag specifies if the application has the [Image Processor](/en/documentation/products/build/applications/image-processor/) module active.

##### file

The `--file` flag specifies the given path and JSON file to automatically update the application attributes. You can use `-` for reading from stdin.

Attributes inside a `JSON` file:

```json
{
   "active": true,
  "application_acceleration": false,
  "delivery_protocol": "http,https",
  "device_detection": false,
  "edge_firewall": false,
  "edge_functions": false,
  "http_port": 80,
  "https_port": 443,
  "id": 1337,
  "image_optimization": false,
  "l2_caching": false,
  "load_balancer": false,
  "minimum_tls_version": "tls_1_1",
  "name": "vaivaivai",
  "raw_logs": false,
  "web_application_firewall": false
}
```

##### l2-caching

The `--l2-caching` flag specifies if the application has the [Tiered Cache](/en/documentation/products/build/applications/cache/tiered-cache/) module active.

##### load-balancer

The `--load-balancer` flag specifies if the application has the [Load Balancer](/en/documentation/products/secure/connectors/load-balancer/) module active.

##### min-tsl-ver

The `--min-tls-ver` flag specifies the application's Minimum TLS Version.

##### name

The `--name` flag specifies the application's name.

##### raw-logs

The `--raw-logs` flag specifies whether the application has raw logs active or not.

##### webapp-firewall

The `--webapp-firewall` flag specifies whether the application has Web Application Firewall active or not.

#### help

The `--help` option displays more information about the update action.

---

## Functions 

#### Usage

```bash
$ azion update edge-function --function-id <function_id>
```

#### Required flags

##### function-id

The `--function-id` flag is the unique identifier of the function.

#### Optional flags

##### active

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

##### args

The `--args` flag sets the path and name of the JSON file containing the function's arguments.

##### code

The `--code` flag sets the path and name to the file containing the function's code.

##### file

The `--file` flag specifies the given path and JSON file to automatically update the function attributes. 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 update edge-function` command.

##### name

The `--name` flag sets the new name for the function.

---

## Rules engine

#### Usage

```bash
azion update rules-engine --rule-id <rule-id> --application-id <application-id> --phase <phase> --file <rule-json>
```

#### Required flags

##### rule-id

The `--rule-id` flag specifies the unique identifier for the rule in Rules Engine.

##### application-id

The `--application-id` flag specifies the unique identifier for the application that implements these rules.

##### phase

The `--phase` flag specifies the Rules Engine Phase. 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 will be updated. You can use `-` to read from stdin.

Attributes inside a `JSON` file:

```json
{
  "id": 1234,
  "name": "UpdatedRule",
  "phase": "request",
  "behaviors": [
    {
      "name": "run_function",
      "target": "9045"
    }
  ],
  "criteria": [
    [
      {
        "variable": "${uri}",
        "operator": "starts_with",
        "conditional": "if",
        "input_value": "/"
      }
    ]
  ]
}
``` 

##### help

The `-h` or `--help` flag displays more information about the `azion update rules-engine` command.

---

## Cache settings

#### Usage

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

#### Required flags

##### application-id

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

##### cache-setting-id

The `--cache-setting-id` flag sets the unique identifier for a Cache Settings configuration.

##### name

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

#### 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 updated. 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 update 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.

---

## Workloads

#### Description

Updates a domain's name and other attributes based on a given ID.

#### Usage

```bash
azion update domain --domain-id 1234 --name 'Hello'
```

#### Required flags

##### domain-id

The `--domain-id` flag specifies the unique identifier of the domain that you want to update.

#### Optional flags

##### active

The `--active` option sets the domain as active.

##### application-id

The `--application-id` option is the unique identifier for an application used by this domain.

##### cname-access-only

The `--cname-access-only` option sets if the domain should be accessed only through CNAMEs.

##### cnames

The `--cnames` option specifies the CNAMEs of your domain.

##### digital-certificate-id

The `--digital-certificate-id` option is the unique identifier of the digital certificate. This value can be either an *integer* or *null*.

##### file

The `--file` option specifies a given path and JSON file to automatically update the domain attributes. You can use `-` to read from stdin.

Attributes inside a `JSON` file:

```json 
{
    "cname_access_only": true,
    "cnames": [
     "www.test123.com",
     "www.aa.com"
    ],
    "id": 1337,
    "name": "name"
   }
```

##### name

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

##### help

The `-h` or `--help` option displays more information about the `azion update domain` command.

---

## Connectors

#### Usage

```bash
$ azion update origin --application-id <application-id> --origin-key <origin-key> 
```

#### Required flags

##### application-id

The `--application-id` flag sets the unique identifier for an application. It's a required field.

##### origin-key

The `--origin-key` flag sets the unique identifier for an origin. It's a required field.

#### Optional flags

##### name

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

##### addresses

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

##### host-header

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

##### origin-type

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

##### origin-protocol-policy

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

##### 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.

##### hmac-authentication

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

##### file

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

Attributes inside a `JSON` file:

```json 
{
  "name": "name",
  "addresses": [{
    "address": "asdfsd.cvdf"
  }],
  "host_header": "asdfsdfsd.cvdf"
}
``` 


##### hmac-access-key

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

##### 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.

#### help

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

---

## Variables

Update an environment variable based on given attributes.

#### Usage

```bash
  azion update variables  --variable-id 7a187044-4a00-4a4a-93ed-d2309004019201909321f3 --key 'Content-Type' --value 'json' --secret false
```

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

##### variable-id

The `--variable-id` flag gives the UUID for the variable being updated.

##### 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`.

#### Optional flags

##### file

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

Attributes inside a `JSON` file:

```json 
{
  "uuid": "32e8ffca-4021-49a4-971f-hkghg330935566af4",
  "key": "Content-Type",
  "value": "json",
  "secret": false,
  "last_editor": "hunter@hunter.com",
  "created_at": "2023-06-13T13:17:13.145625Z",
  "updated_at": "2023-06-13T13:17:13.145666Z"
}
```

##### help

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

---

## Object Storage bucket

#### Usage

```bash
azion update edge-storage bucket --name 'zorosola' --edge-access 'read_only'
azion update edge-storage bucket --help
```

#### Required flags

##### name

The `--name` flag sets the name of the Object Storage bucket that will be updated.

#### Optional flags

##### edge-access

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

##### file

The `--file` option specifies the path to a JSON file containing the attributes of the bucket to be updated. You can use `-` for reading from stdin.

##### help

The `-h` or `--help` option displays more information about the `azion update edge-storage bucket` command.

---

## Object Storage object

#### Usage

```bash
azion update edge-storage object --bucket-name 'mybalde' --object-key 'path/index.html' --source './index.html'
azion update edge-storage object --help
```

#### Required flags

##### bucket-name

The `--bucket-name` flag specifies the name of the Object Storage bucket where the object that you want to update is located.

##### object-key

The `--object-key` flag identifies the Object Storage object in the specified bucket that you want to update.

##### source

The `--source` flag specifies the file path to update the Object Storage bucket object.

#### Optional flags

##### file

The `--file` option refers to the path to a JSON file containing the attributes of the bucket that will be updated. You can use `-` for reading from stdin.

Attributes inside a `JSON` file:


##### help

The `-h` or `--help` option provides more information about the `azion update edge-storage object` command.

---

## WAF

Updates a WAF (Web Application Firewall).

#### Usage

```bash
azion update waf --waf-id <waf-id> [flags]
```

#### Required flags

##### waf-id

The `--waf-id` flag specifies the unique identifier of the WAF to be updated.

#### Optional flags

##### name

The `--name` flag sets the new name for the WAF.

##### mode

The `--mode` flag sets the WAF mode. Possible values: `learning` or `blocking`.

##### 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 update waf` command.

---

## WAF exceptions

Updates a WAF exception.

#### Usage

```bash
azion update waf-exceptions --exception-id <exception-id> --waf-id <waf-id> [flags]
```

#### Required flags

##### exception-id

The `--exception-id` flag specifies the unique identifier of the WAF exception to be updated.

##### waf-id

The `--waf-id` flag specifies the unique identifier of the WAF associated with the exception.

#### 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 update waf-exceptions` command.