Prepare the Local Development Environment
Before you can start using Oracle Functions to create and deploy functions, you have to set up your local environment for function development.
Although it is possible to use Cloud Shell or an Oracle Cloud Infrastructure compute instance as the development environment, this document assumes you will use a local Linux environment for function development.
Before You Begin
In addition to the tasks presented in this section for setting up a local Linux instance for function development, you must also perform the following tasks:
-
To develop functions locally, install the Fn Project development platform from GitHub.
-
Make sure that you have Docker version 17.10.0 or later installed on your local instance.
For information about installing or upgrading Docker on Linux, see Oracle Container Runtime for Docker User's Guide.
Create a Signing Key
Before using Oracle Functions, you have to set up an Oracle Cloud Infrastructure API signing key.
Create a Command Line Interface (CLI) Profile
Before using Oracle Functions, you must have an Oracle Cloud Infrastructure CLI configuration file that contains the credentials profile of the user account that you will be using to create and deploy functions.
The Oracle Cloud Infrastructure CLI configuration file can contain several profiles. If you already have a configuration file containing one or more profiles, you have to add a new profile to the existing file for the user who will be using Oracle Functions to create and deploy functions
Copy and Configure the oci-curl Script
You can use a script to invoke a function. The oci-curl
script creates a signed request based on credentials you provide in the body of the script.
To use oci-curl
to invoke a function, you must provide the credentials of an Oracle Cloud
Infrastructure user that has been granted access to resources in the same tenancy and belonging to the same compartment as the function.
Typically you'll want to invoke a function as the functions developer that's configured for your development environment. The instructions below assume that is the case.
Install the Fn Project Command Line Interface (CLI)
Before using Oracle Functions, the Fn Project command line interface (CLI) must be installed in your development environment.
This procedure uses curl to install the CLI on a Linux instance. Instructions for other operating systems are provided in the readme file for the Fn Project on GitHub.
Create an Fn Command Line Interface Context
When the Fn Project command line interface (CLI) is initially installed, it's configured for local development. To configure Fn Project CLI to connect to your Oracle Cloud Infrastructure tenancy, you have to create a new context.
The context specifies Oracle Functions endpoints, the OCID of the compartment to which deployed functions will belong, and the address of the Docker registry to and from which to push and pull images. You can define multiple contexts, each stored in a different context file in .yaml format.
Create an Auth Token
To deploy functions in Oracle Cloud Infrastructure, you must create an auth token to use as the password when signing Docker in to Oracle Cloud Infrastructure Registry.
- Sign in to the Oracle Cloud Infrastructure console, click the User icon, and select User Settings.
- To create a new auth token, click Auth Tokens in the Resources section and then click Generate Token.
- Provide a description for the Auth Token and click Generate Token. Copy the token when it is displayed.
- Click the Copy link and store the token information in a secure location because when you close the dialog, you will not be able see the token in the console again.
- Click Close.
Sign In to Oracle Cloud Infrastructure Registry
Before you can use Oracle Functions, you must sign Docker in to the Docker registry in which you are going to store your functions as Docker images. This is the Docker registry you specified earlier in the Fn Project command line interface (CLI) context.
- Installed and started Docker on the development environment
- Created an Oracle Cloud Infrastructure context for the Fn command line interface (CLI)
- Created an Oracle Cloud Infrastructure auth token for the user
You can store functions in public and private repositories in Oracle Cloud Infrastructure Registry, an Oracle-managed registry built on top of Oracle Cloud Infrastructure.
To complete the steps below, you must provide the tenancy namespace for Oracle Cloud Infrastructure Object Storage, the user name, and the user's auth token.
To sign Docker into Oracle Cloud Infrastructure Registry: