Azion CLI storage
Azion CLI commands that create, list, describe, update, and delete Object Storage buckets and objects, with every flag, its type, and its default.
The Azion CLI storage commands create, list, describe, update, and delete the buckets and objects of Object Storage. Every verb takes a subcommand: bucket acts on a bucket, named with --name, and object acts on a file inside a bucket, named with --bucket-name and --object-key. The options every command accepts, such as --format, --out, and -y, are on Global options.
Create
azion create storage takes the bucket or the object subcommand.
Bucket
azion create storage bucket creates a bucket with the name and the access level you pass:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--file | — | string | — | Path to a JSON file with the attributes of the bucket. Use - to read the JSON from standard input. |
--name | — | string | — | Name of the bucket, in lowercase letters, numbers, and hyphens. |
--workloads-access | — | string | — | Required unless --file is set. Permission type for actions within the bucket: read_only, read_write, or restricted. Without it, the command asks you to choose one. |
A name with capital letters is refused with this error:
Any other --workloads-access value is refused the same way, such as public with ["\"public\" is not a valid choice."].
This command creates a bucket named my-bucket with the read_only access level:
The command confirms the creation:
Object
azion create storage object uploads a local file to a bucket as an object:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--bucket-name | — | string | — | Name of the bucket that receives the object. |
--file | — | string | — | Path to a JSON file with the attributes of the object. Use - to read the JSON from standard input. The command reads the local path from the file and still needs --bucket-name and --object-key. |
--object-key | — | string | — | Required, also with --file. Key of the object in the bucket. A key can be a full path, such as path/to/file/bucket/file.txt. |
--source | — | string | — | Path to the local file to upload. A relative path is read from the current directory. |
A bucket that does not exist, or a --file call without --object-key, fails with this error:
This command uploads ./upload/index.html to my-bucket under the key site/index.html:
The command confirms the upload:
List
azion list storage takes the bucket or the object subcommand.
Bucket
azion list storage bucket lists the buckets of your account with the access level of each, 50 to a page:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--page | — | int | 1 | Number of the page to return. |
--page-size | — | int | 50 | Number of buckets on each page. |
The command has no --details flag and fails with Error: unknown flag: --details when you pass one.
This command returns the first page of a list split into pages of two buckets:
The command prints one row per bucket:
Object
azion list storage object lists the objects of one bucket with the key and the last change of each, 50 to a page:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--bucket-name | — | string | — | Required. Name of the bucket whose objects to list. Without it, the command asks for the name. |
--details | — | — | — | Adds the SIZE column, in bytes, to the KEY and LAST MODIFIED columns. |
--next-page | — | — | — | Returns the next page of the list, after the first --page-size objects. |
--page-size | — | int | 50 | Number of objects on each page. |
This command lists the objects of my-bucket with their sizes:
The command prints one row per object:
Describe
azion describe storage takes the object subcommand. Its help lists no subcommand.
Bucket
azion describe storage bucket takes no --name flag and fails with Error: unknown flag: --name, so the CLI does not describe a bucket. To read the access level of a bucket, run azion list storage bucket.
Object
azion describe storage object prints the content of one object:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--bucket-name | — | — | — | Name of the bucket that holds the object. |
--object-key | — | — | — | Key of the object to print. |
This command prints the object site/index.html of my-bucket:
The command prints the content of the object as stored:
With --format json, the command prints the same content, not a JSON object. With --out, such as --out object-download.html, it writes the object to that file instead of printing it.
Update
azion update storage takes the bucket or the object subcommand.
Bucket
azion update storage bucket changes the access level of a bucket:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--file | — | string | — | Path to a JSON file with the name of the bucket and the attributes to change. Use - to read the JSON from standard input. |
--name | — | string | — | Name of the bucket to update. |
--workloads-access | — | string | — | Permission type to set for actions within the bucket: read_only, read_write, or restricted. |
This command changes the access level of my-bucket to restricted:
The command confirms the update:
After the update, azion list storage bucket shows restricted for my-bucket.
Object
azion update storage object replaces the content of an object with a local file:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--bucket-name | — | string | — | Name of the bucket that holds the object. |
--file | — | string | — | Path to a JSON file with the local path of the replacement content. Use - to read the JSON from standard input. Pass --bucket-name and --object-key with it. |
--object-key | — | string | — | Key of the object to update. |
--source | — | string | — | Required unless --file is set. Path to the local file with the replacement content. Without it, the command asks for the path. |
This command replaces the content of site/index.html in my-bucket with ./upload/index-v2.html:
The command confirms the update:
After the update, azion describe storage object prints the replacement content, <h1>hello world updated</h1>.
Delete
azion delete storage takes the bucket or the object subcommand.
Bucket
azion delete storage bucket deletes a bucket and the objects in it:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--force | — | — | — | Empties the bucket, then deletes it. |
--name | — | string | — | Name of the bucket to delete. |
This command deletes the empty bucket my-other-bucket:
The command confirms the deletion, and the bucket leaves the list at once:
A bucket that holds objects is emptied, and its deletion is scheduled instead of done at once. The command prints this output:
The bucket then stays in azion list storage bucket for a while, with no objects in it. For more information, refer to Object Storage limits.
Object
azion delete storage object deletes one object from a bucket:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--bucket-name | — | string | — | Name of the bucket that holds the object. |
--object-key | — | string | — | Key of the object to delete. |
This command deletes the object site/two.txt from my-bucket:
The command confirms the deletion:
Use a JSON file
azion create storage and azion update storage read the attributes of a bucket or an object from a JSON file with --file.
Bucket file
A bucket file carries name and workloads_access. This file creates a bucket named my-other-bucket with the read_write access level:
Pass the file to the create command:
The command confirms the creation:
On update, the command reads the bucket to change from name, so --name is not needed. This file changes the access level of my-other-bucket to read_only:
Pass the file to the update command:
The command confirms the update:
Object file
An object file carries source, the path to the local file. The command does not read the key from the file, so pass --bucket-name and --object-key on the command line, on create and on update. This file points to the replacement content of site/two.txt:
Pass the file to the update command with the bucket and the key:
The command confirms the update: