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.
Create a function instance
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.
Returns data as the created AzionFunctionInstance, with its id.
Output:
The signature of createFunctionInstance:
Parameters
| 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. |
Get function instances
getFunctionInstances lists the function instances of an application, one page at a time.
Returns an AzionApplicationCollectionResponse whose data.results holds AzionFunctionInstance objects.
Output:
The signature of getFunctionInstances:
Parameters
| 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. |
Get a function instance
getFunctionInstance returns one function instance of an application by its ID.
Returns data as an AzionFunctionInstance.
Output:
The signature of getFunctionInstance:
Parameters
| 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. |
Update a function instance
updateFunctionInstance sends the function instance fields you pass in a PATCH request.
Returns data as the updated AzionFunctionInstance.
Output:
The signature of updateFunctionInstance:
Parameters
| 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. |
Delete a function instance
deleteFunctionInstance deletes a function instance of an application by its ID.
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:
The signature of deleteFunctionInstance:
Parameters
| 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. |