Azion CLI function-instance
Azion CLI commands that create, list, describe, update, and delete function instances, with the flags, types, and defaults of each command.
The Azion CLI function-instance commands create, list, describe, update, and delete function instances. A function instance binds one function to one application and carries the arguments that the function code receives. Options shared by every command, such as --format, --out, and -y, are listed on Global options.
Create
azion create function-instance adds a function to an application as a function instance:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--active | — | string | "true" | Sets whether the function instance is active (true) or not (false). |
--application-id | — | int | — | ID of the application that receives the function instance. |
--args | — | string | — | Path to a JSON file with the arguments of the function instance. |
--file | — | string | — | Path to a JSON file with the attributes of the function instance. Use - to read the JSON from standard input. |
--function-id | — | int | — | Required unless --file is set. ID of the function to instantiate. Without it, the command asks for the ID. |
--name | — | string | — | Name of the function instance. |
--args takes the path of a JSON file, not the JSON itself. Inline JSON fails with this error:
This file holds the arguments for the function instance:
This command creates a function instance named my-instance from the function with ID 12359 in the application with ID 1234567890, and passes it the arguments in fi-args.json:
The command prints the ID of the function instance:
List
azion list function-instance lists the function instances of an application, 50 to a page:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--application-id | — | int | — | ID of the application whose function instances you list. |
--details | — | — | — | Adds the LAST EDITOR and LAST MODIFIED columns to the ID, NAME, ACTIVE, and FUNCTION 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 function instances on each page. |
This command lists the function instances of the application with ID 1234567890:
The command prints one row per function instance, with the ID of the function it runs:
Describe
azion describe function-instance prints the settings of one function instance:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--application-id | — | int | — | ID of the application that holds the function instance. |
--instance-id | — | int | — | ID of the function instance to describe. |
This command describes the function instance with ID 12361:
The command prints the ID, the name, the function, and the last change of the function instance:
The plain output leaves out the arguments. With --format json, the command prints the full object: active, args, azion_form, created_at, function, id, last_editor, last_modified, and name. For the function instance above, args holds the object read from fi-args.json:
Update
azion update function-instance changes the attributes of a function instance:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--active | — | string | "true" | Sets whether the function instance is active (true) or not (false). |
--application-id | — | int | — | ID of the application that holds the function instance. |
--args | — | string | — | Path to a JSON file with the new arguments of the function instance. |
--file | — | string | — | Path to a JSON file with the attributes to change. Use - to read the JSON from standard input. |
--function-id | — | int | — | ID of the function the instance runs. |
--instance-id | — | int | — | ID of the function instance to update. |
--name | — | string | — | New name of the function instance. |
A function instance stays active. With --active false, the API refuses the update and the command fails with this error:
This command renames the function instance with ID 12361 to my-instance-renamed:
The command prints the ID of the updated function instance. The arguments and the active state keep their values:
Delete
azion delete function-instance removes a function instance from an application:
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--application-id | — | int | — | ID of the application that holds the function instance. |
--instance-id | — | int | — | ID of the function instance to delete. |
This command deletes the function instance with ID 12362:
The command confirms the deletion and prints the ID as %!s(int64=12362):
Use a JSON file
azion create function-instance and azion update function-instance read the attributes of the function instance from a JSON file with --file. Inside the file, args is a JSON object, not a path.
This file creates an active function instance named my-other-instance from the function with ID 12359. The command reads name, function, active, and args from it:
Pass the file to the create command with the ID of the application:
The command prints the ID of the function instance:
On update, pass the ID of the application and the ID of the function instance on the command line. This file changes the name and the arguments of the function instance with ID 12362:
Pass the file to the update command:
The command prints the ID of the updated function instance:
Fields that the file leaves out keep their values: the function instance above stays active.