# Azion CLI dns-zone

The Azion CLI `dns-zone` commands create, list, describe, update, and delete zones, the [Edge DNS](/en/documentation/platform/edge-dns/) object that holds one domain and its records. The fields of a zone, their bounds, and the errors the API returns are on [Zones and records](/en/documentation/platform/edge-dns/zones-and-records/). The options every command accepts, such as `--format`, `--out`, and `-y`, are on [Global options](/en/documentation/devtools/cli/globals/).

---

## Create

`azion create dns-zone` creates a zone for the domain you pass:

```bash
azion create dns-zone [flags]
```

| Flag       | Short | Type   | Default | Description                                                                                               |
| ---------- | ----- | ------ | ------- | --------------------------------------------------------------------------------------------------------- |
| `--active` | —     | —      | `true`  | Turns the zone on (`--active=true`) or off (`--active=false`).                                            |
| `--domain` | —     | string | —       | **Required** unless `--file` is set. Domain the zone serves. Without it, the command asks for the domain. |
| `--file`   | —     | string | —       | Path to a JSON file with the attributes of the zone. Use `-` to read the JSON from standard input.        |
| `--name`   | —     | string | —       | Name of the zone.                                                                                         |

This command creates a zone named `my-zone` for the domain `my-domain.com`:

```bash
azion create dns-zone --name my-zone --domain my-domain.com
```

The command prints the ID of the zone:

```text
Created DNS zone with ID 1234
```

A domain that another account hosts is refused with `["Domain Belongs to Another Account."]`, and a domain that already has a zone in your account is refused with `["This field must be unique."]`. Both errors are explained on [Zones and records](/en/documentation/platform/edge-dns/zones-and-records/#errors).

---

## List

`azion list dns-zone` lists the zones of your account, 50 to a page:

```bash
azion list dns-zone [flags]
```

| Flag          | Short | Type   | Default | Description                                                                                   |
| ------------- | ----- | ------ | ------- | --------------------------------------------------------------------------------------------- |
| `--details`   | —     | —      | —       | Accepted, and prints the same `ID`, `NAME`, `DOMAIN`, and `ACTIVE` columns as the plain list. |
| `--filter`    | —     | string | —       | Name to filter the list by.                                                                   |
| `--order-by`  | —     | string | —       | Field to sort the list by.                                                                    |
| `--page`      | —     | int    | `1`     | Number of the page to return.                                                                 |
| `--page-size` | —     | int    | `50`    | Number of zones on each page.                                                                 |

This command lists every zone of the account:

```bash
azion list dns-zone
```

The command prints one row per zone, with its domain and its state:

```text
ID    NAME          DOMAIN              ACTIVE
1234  my-zone       my-domain.com       true
1235  my-file-zone  my-file-domain.com  false
```

---

## Describe

`azion describe dns-zone` prints the settings of one zone:

```bash
azion describe dns-zone [flags]
```

| Flag        | Short | Type | Default | Description                               |
| ----------- | ----- | ---- | ------- | ----------------------------------------- |
| `--zone-id` | —     | int  | —       | **Required**. ID of the zone to describe. |

This command describes the zone with ID `1235`:

```bash
azion describe dns-zone --zone-id 1235
```

The command prints the zone and the Azion nameservers that answer for its domain:

```text
ID:                1235
Name:              my-file-zone
Domain:            my-file-domain.com
Active:            false
Nameservers:       ["ns1.aziondns.net","ns2.aziondns.com","ns3.aziondns.org"]
Product Version:   2.0
```

With `--format json`, the command prints the same object with the keys `active`, `domain`, `id`, `name`, `nameservers`, and `product_version`.

---

## Update

`azion update dns-zone` changes the name or the active state of a zone. The command has no flag for the domain:

```bash
azion update dns-zone [flags]
```

| Flag        | Short | Type   | Default | Description                                                                                      |
| ----------- | ----- | ------ | ------- | ------------------------------------------------------------------------------------------------ |
| `--active`  | —     | —      | `true`  | Turns the zone on (`--active=true`) or off (`--active=false`).                                   |
| `--file`    | —     | string | —       | Path to a JSON file with the attributes to change. Use `-` to read the JSON from standard input. |
| `--name`    | —     | string | —       | New name of the zone.                                                                            |
| `--zone-id` | —     | int    | —       | **Required**. ID of the zone to update.                                                          |

Write `--active` with an equals sign. With a space, `--active false` prints `DNS zone 1234 was updated` and leaves the zone active.

This command turns off the zone with ID `1234`:

```bash
azion update dns-zone --zone-id 1234 --active=false
```

The command confirms the update:

```text
DNS zone 1234 was updated
```

---

## Delete

`azion delete dns-zone` deletes a zone:

```bash
azion delete dns-zone [flags]
```

| Flag        | Short | Type | Default | Description                             |
| ----------- | ----- | ---- | ------- | --------------------------------------- |
| `--zone-id` | —     | int  | —       | **Required**. ID of the zone to delete. |

This command deletes the zone with ID `1235`:

```bash
azion delete dns-zone --zone-id 1235 -y
```

The command confirms the deletion:

```text
DNS zone 1235 was successfully deleted
```

---

## Use a JSON file

`azion create dns-zone` and `azion update dns-zone` read the attributes of the zone from a JSON file with `--file`.

This file creates a zone named `my-file-zone` for `my-file-domain.com` and keeps it turned off. The command reads `name`, `domain`, and `active` from it:

```json
{
  "name": "my-file-zone",
  "domain": "my-file-domain.com",
  "active": false
}
```

Pass the file to the create command:

```bash
azion create dns-zone --file zone-create.json
```

The command prints the ID of the zone:

```text
Created DNS zone with ID 1235
```

On update, pass the ID of the zone with `--zone-id`. This file renames the zone and turns it on:

```json
{
  "name": "my-file-zone-updated",
  "active": true
}
```

Pass the file to the update command:

```bash
azion update dns-zone --zone-id 1235 --file zone-update.json
```

The command confirms the update:

```text
DNS zone 1235 was updated
```

---

## Related resources

- [Global options](/en/documentation/devtools/cli/globals.md): The options every command accepts, such as `--format`, `--out`, and `-y`.
- [Zones and records](/en/documentation/platform/edge-dns/zones-and-records.md): Every zone and record field, the nameservers, and the errors the API returns.
- [Azion CLI dns-record](/en/documentation/devtools/cli/resources/dns-record.md): The commands that create and manage the records inside a zone.
- [Azion CLI dnssec](/en/documentation/devtools/cli/resources/dnssec.md): The commands that read DNSSEC for a zone and turn it on or off.
