Function instances
The azion/applications functions that create, list, read, update, and delete the function instances of an application.
A function instance runs an existing function for an application, with the arguments the instance sets. These azion/applications functions create, list, read, update, and delete the function instances of an application.
createFunctionInstance
Creates a function instance in an application. An instance runs an existing function for that application, with the arguments the instance sets.
Two things must exist first. The application must have functions turned on, which patchApplication does with data: { edge_functions: true }. The function must exist too: the instance names it by its ID in edge_function_id, and the azion package has no module that creates functions.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
data | ApiCreateFunctionInstancePayload | Yes | name, the edge_function_id of the function, and the args the function receives. |
options | AzionClientOptions | No | Request options. |
Returns data as the created AzionFunctionInstance, with its id.
Output:
getFunctionInstances
Lists the function instances of an application, one page at a time.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
params | ApiListFunctionInstancesParams | No | Pagination: page and page_size. |
options | AzionClientOptions | No | Request options. |
Returns an AzionApplicationCollectionResponse whose data.results holds AzionFunctionInstance objects.
Output:
getFunctionInstance
Returns one function instance of an application by its ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
functionInstanceId | number | Yes | The ID of the function instance. |
options | AzionClientOptions | No | Request options. |
Returns data as an AzionFunctionInstance.
Output:
updateFunctionInstance
Sends the function instance fields you pass in a PATCH request.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
functionInstanceId | number | Yes | The ID of the function instance to update. |
data | ApiUpdateFunctionInstancePayload | Yes | The fields to change. The sample changes name. |
options | AzionClientOptions | No | Request options. |
Returns data as the updated AzionFunctionInstance.
Output:
deleteFunctionInstance
Deletes a function instance of an application by its ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
functionInstanceId | number | Yes | The ID of the function instance to delete. |
options | AzionClientOptions | No | Request options. |
A successful delete returns error with the message Expected JSON response, but got: , so the sample reads the instance back with getFunctionInstance. A 404 error confirms the delete.
Output: