Azion CLI dns-record
Azion CLI commands that create, list, describe, update, and delete the records of an Edge DNS zone, with every flag and its type.
The Azion CLI dns-record commands create, list, describe, update, and delete the records of an Edge DNS zone. A record is one name, one type, and the values Edge DNS answers with for that name. A record belongs to one zone, so every command takes the --zone-id of that zone. The fields of a record are on Zones and records. The options every command accepts, such as --format, --out, and -y, are on Global options.
Create
azion create dns-record creates a record in a zone, with the name, type, and values you pass:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--description | — | string | — | Description of the record. Used only when --policy is weighted. |
--file | — | string | — | Path to a JSON file with the attributes of the record. Use - to read the JSON from standard input. |
--name | — | string | — | Name of the record inside the zone, such as www. |
--policy | — | string | — | Routing policy of the record: simple or weighted. |
--rdata | — | strings | — | Values of the record. Repeat the flag or pass a comma-separated list for several values. |
--ttl | — | int | — | Time to live (TTL) of the record, in seconds. |
--type | — | string | — | Type of the record, such as A, AAAA, CNAME, MX, TXT, or NS. The types and their value formats are on Record types. |
--weight | — | int | — | Weight of the record. Used only when --policy is weighted. |
--zone-id | — | int | — | Required. ID of the zone that holds the record. Without it, the command asks for the ID of the zone. |
This command creates an A record named www with two values and a TTL of 3600 seconds:
The command prints the ID of the record:
--rdata splits its value at every comma, so a value that contains a comma becomes several values. With --rdata 'v=spf1 include:a.example.com,b.example.com ~all', the record stores v=spf1 include:a.example.com and b.example.com ~all as two values. To keep the comma inside one value, wrap the value in double quotes inside the single quotes, or pass the value in a JSON file with --file.
This command creates a TXT record named spf2 whose one value contains a comma:
The command prints the ID of the record, which stores the value whole:
A --type value that is not a record type, such as ZZZ, is refused with this error:
List
azion list dns-record lists the records of a zone, 50 to a page:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--details | — | — | — | Accepted, but adds no columns: the list keeps the ID, NAME, TYPE, TTL, and RDATA columns. |
--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 records on each page. |
--zone-id | — | int | — | Required. ID of the zone whose records the command lists. |
This command lists the records of the zone with ID 1234:
The command prints one row per record:
The RDATA column joins the values of a record with a comma and a space. The spf record holds two values and the spf2 record holds one, and the two rows look almost the same. To read each value apart, describe the record with --format json.
Describe
azion describe dns-record prints the settings of one record:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--record-id | — | int | — | Required. ID of the record to describe. |
--zone-id | — | int | — | Required. ID of the zone that holds the record. |
This command describes the record with ID 100001:
The command prints the name, the type, the values, and the routing settings of the record:
With --format json, the command prints description, id, name, policy, rdata, ttl, type, and weight, with rdata as an array of one item per value. A record created without --policy holds the policy simple and the weight 255.
A record ID that does not exist in the zone fails with this error:
Update
azion update dns-record changes the name, type, values, TTL, or routing settings of a record:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--description | — | string | — | Description of the record. Used only when --policy is weighted. |
--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 record inside the zone. |
--policy | — | string | — | Routing policy of the record: simple or weighted. |
--rdata | — | strings | — | Values of the record. Repeat the flag or pass a comma-separated list for several values. |
--record-id | — | int | — | Required. ID of the record to update. |
--ttl | — | int | — | Time to live (TTL) of the record, in seconds. |
--type | — | string | — | Type of the record, such as A, AAAA, CNAME, MX, TXT, or NS. |
--weight | — | int | — | Weight of the record. Used only when --policy is weighted. |
--zone-id | — | int | — | Required. ID of the zone that holds the record. |
--rdata replaces every value of the record and splits its value at every comma, as on create.
This command sets one value and a TTL of 7200 seconds on the record with ID 100001:
The command confirms the update:
The record then holds the single value 192.0.2.3, and its name and type stay www and A.
Delete
azion delete dns-record deletes a record from a zone:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--record-id | — | int | — | Required. ID of the record to delete. |
--zone-id | — | int | — | Required. ID of the zone that holds the record. |
This command deletes the record with ID 100001:
The command confirms the deletion:
Use a JSON file
azion create dns-record and azion update dns-record read the attributes of the record from a JSON file with --file. The zone stays on the command line as --zone-id, and on update the record stays on the command line as --record-id.
In the file, rdata is an array with one item per value, so a comma inside a value stays part of it. This file creates a TXT record named txt with one value and a TTL of 300 seconds:
Pass the file to the create command:
The command prints the ID of the record:
On update, the command changes only the fields in the file, and the fields you leave out keep their values. This file replaces the value of the record and sets a TTL of 600 seconds:
Pass the file to the update command:
The command confirms the update:
The record keeps the name txt and the type TXT, and holds the value v=spf1 -all with a TTL of 600 seconds.