Instantiate a function on an application
Bind a function to an application from Azion Console or the Azion API, name the instance, and pass its Args in JSON.
You can create a function instance on an application from Azion Console or the Azion API. The instance binds one function to one application and carries the Args passed into the execution context.
An instance without a Rules Engine rule never runs. The rule selects the instance with the Run Function behavior and sets the criteria that trigger it. To add that rule, refer to Run a function on an application.
To create the same object on a firewall, refer to Instantiate a function on a firewall.
Prerequisites
- An application. To create one, refer to Applications quickstart.
- A function on the account. Take one from Azion Marketplace, or write one, as in the Functions quickstart.
- A personal token, for the API path.
Create the function instance
An application runs a function through an instance, and one function can back several instances. Each path turns on the Functions module for the application, then creates the instance:
To create the instance from Azion Console:
Access Azion Console > Applications > your application.
Enter a name for the instance. For example: hello-world instance.
Select the function the instance runs. For example, the pre-configured Azion - Hello World function.
(Optional) In the Args tab, enter the arguments for the instance in JSON.
The instance appears in the Functions Instances tab. It does not run until a Rules Engine rule selects it.
Instance Args
Args are the arguments an instance passes into the context of the function’s execution, written as a JSON object. The code of the function cannot be changed at instantiation, so Args are how one function behaves differently in each application that instantiates it. An Args object that sets one key:
The code reads the key at run time and the instance decides its value. A function can define default Args of its own, and the Args of an instance override the keys they repeat. The Args object holds a maximum of 100 KB, and an object above that ceiling makes the function fail at instantiation. Sensitive values such as API keys, credentials, and access tokens belong in environment variables instead.
For the default values and the override rules, refer to How Functions works. For every field of the instance object, refer to Function instances.