A. Set up your tenancy
- 1. Create groups and users
- 2. Create compartment
- 3. Create VCN and subnets
- 4. Create policy for group
B. Set up your local dev environment
C. Set up Fn Project CLI in local dev environment
- 1. Set up signing key
- 2. Set up OCI profile
- 3. Set up Fn CLI context --provider oracle
- 4. Complete Fn CLI context configuration
D. Create, deploy, and invoke your function

A. Set up your tenancy
1Create groups and users

If suitable users and groups don't exist already, log in to the Console as a tenancy administrator and under Governance and Administration, go to Identity and then:

Create a new group by clicking Groups and then Create Group.



Create a new user by clicking Users and then Create User.

Add a user to a group by clicking Groups, then the name of the group, and then Add User to Group.
See documentation for more details.
2Create compartment

If a suitable compartment in which to create network resources and Oracle Functions resources doesn't exist already, log in to the Console as a tenancy administrator and under Governance and Administration, go to Identity and then:

Click Compartments and then Create Compartment.
See documentation for more details.
3Create VCN and subnets

If a suitable VCN in which to create network resources doesn't exist already, log in to the Console as a tenancy administrator and under Core Infrastructure, go to Networking and then:

Click Virtual Cloud Networks and choose a compartment.

Click Start VCN Wizard, then VCN with Internet Connectivity, then Start VCN Wizard.

Enter a name for the new VCN, click Next, and then click Create to create the VCN along with the related network resources.
See documentation for more details.
4Create policy for group

Log in to the Console as a tenancy administrator and under Governance and Administration, go to Identity and click Policies and then:

If one or more Oracle Functions users is not a tenancy administrator, use the Policy Builder to create a new policy. Select the tenancy's root compartment and base the policy on the policy template Let users create, deploy, and manage functions and applications using Cloud Shell.
The policy template includes the following policy statements:
Allow group <group-name> to use cloud-shell in tenancy
Allow group <group-name> to manage repos in tenancy
Allow group <group-name> to read objectstorage-namespaces in tenancy
Allow group <group-name> to read metrics in tenancy
Allow group <group-name> to manage functions-family in tenancy
Allow group <group-name> to use virtual-network-family in tenancy
If necessary, you can restrict these policy statements by compartment (as described in the documentation).
B. Set up your dev environment
1Install and start Docker
Log in to your development environment as a functions developer and:

Confirm that Docker is installed by entering:
$ docker version

If you see an error message indicating that Docker is not installed, you have to install Docker before proceeding. See the Docker documentation for your platform (for Oracle Linux, see here).

Assuming Docker is installed, go to the Prerequisites section of the Fn Project home page on GitHub and confirm that the installed version of Docker is at least the minimum version specified there. If not, re-install Docker before proceeding.

Launch the standard hello-world Docker image as a container to confirm that Docker is running by entering:
$ docker run hello-world

If you see an error message indicating that Docker is not running, you have to start the Docker daemon before proceeding. See the Docker documentation.
See documentation for more details.
2Generate auth token

Log in to the Console as a functions developer and:

Open the User menu () and go to User Settings. On the Auth Tokens page, click Generate Token.

Enter a meaningful description for the auth token in the Generate Token dialog, and click Generate Token. The new auth token is displayed.

Copy the auth token immediately to a secure location from where you can retrieve it later, because you won't see the auth token again in the Console.

Close the Generate Token dialog.
See documentation for more details.
3Log in to Registry
Log in to your development environment as a functions developer and:

Log in to Oracle Cloud Infrastructure Registry by entering:
$ docker login <region-key>.ocir.io
where <region-key> is a three character key indicating the registry location (see here).
For example:
$ docker login phx.ocir.io

When prompted, enter the name of the user you will be using with Oracle Functions to create and deploy functions, in the format <tenancy-namespace>/<username>, where <tenancy-namespace> is the tenancy's auto-generated Object Storage namespace string shown on the Tenancy Information page. For example, ansh81vru1zp/jdoe@acme.com. If your tenancy is federated with Oracle Identity Cloud Service, use the format <tenancy-namespace>/oracleidentitycloudservice/<username>.

When prompted for a password, enter the user's Oracle Cloud Infrastructure auth token.
See documentation for more details.
4Install Fn Project CLI
Log in to your development environment as a functions developer and:

Open the Fn Project CLI README.md file on GitHub and follow the appropriate instructions for installing the Fn Project CLI. As a convenient overview, the instructions are summarized below:
• Linux or MacOS: Enter:
$ curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh
• MacOS using Homebrew: Enter:
$ brew install fn
• Linux, MacOS, or Windows: Download and run the binary from the Fn Project Releases page on GitHub.

Confirm that the CLI has been installed by entering:
$ fn version
See documentation for more details.
C. Set up Fn Project CLI in local dev environment
1Set up signing key
Log in to your local machine development environment as a functions developer and:

Generate a private key encrypted with a passphrase that you provide by entering:
$ openssl genrsa -out ~/.oci/<private-key-file-name>.pem -aes128 2048

Change permissions on the file to ensure that only you can read it.
$ chmod go-rwx ~/.oci/<private-key-file-name>.pem

Generate a public key (encrypted with the same passphrase that you provided when creating the private key, and in the same location as the private key file) by entering:
$ openssl rsa -pubout -in ~/.oci/<private-key-file-name>.pem -out ~/.oci/<public-key-file-name>.pem

Copy the contents of the public key file you just created, by entering:
$ cat ~/.oci/<public-key-file-name>.pem | pbcopy


Log in to the Console as a functions developer, open the User menu () and go to User Settings. On the API Keys page, click Add Public Key. Paste the public key's value into the window and click Add. The key is uploaded and its fingerprint is displayed.
See documentation for more details.
2Set up OCI profile
Log in to your local machine development environment as a functions developer and:

Open the file ~/.oci/config in a text editor. (If the directory and/or the file don't already exist, create them).

Add a new profile to the ~.oci/config file as follows:
[<profile-name>]
user=<user-ocid>
fingerprint=<public-key-fingerprint>
key_file=<full-path-to-private-key-pem-file>
tenancy=<tenancy-ocid>
region=<region-name>
pass_phrase=<passphrase>

Save and close the file.
See documentation for more details.
3Set up Fn Project CLI context --provider oracle
Log in to your local machine development environment as a functions developer and:

Create a new Fn CLI context by entering:
$ fn create context <my-context> --provider oracle
Note that you specify --provider oracle
to enable authentication and authorization using Oracle Cloud Infrastructure request signing, private keys, user groups, and policies that grant permissions to those user groups.

Specify that the Fn Project CLI is to use the new context by entering:
$ fn use context <my-context>

Configure the new context with the name of the OCI profile you've created for use with Oracle Functions by entering:
4Complete Fn Project CLI context configuration
Log in to your development environment as a functions developer and:

Configure the new context with the OCID of the compartment you want to own deployed functions:
$ fn update context oracle.compartment-id <compartment-ocid>

Configure the new context with the api-url endpoint to use when calling the OCI API by entering:
$ fn update context api-url <api-endpoint>
For example:
$ fn update context api-url https://functions.us-phoenix-1.oci.oraclecloud.com

Configure the new context with the address of the registry and repository that you want to use with Oracle Functions by entering:
$ fn update context registry <region-key>.ocir.io/<tenancy-namespace>/<repo-name>
where <region-key> is the same three character key you specified when logging in to the Oracle Cloud Infrastructure Registry, and <tenancy-namespace> is the tenancy's auto-generated Object Storage namespace string shown on the Tenancy Information page.
For example:
$ fn update context registry phx.ocir.io/ansh81vru1zp/acme-repo
You're now ready to start creating, deploying, and invoking functions.
See documentation for more details.
D. Create, deploy, and invoke your function
1Create your first application

Log in to the Console as a functions developer and under Solutions and Platform, go to Developer Services and click Functions, and:

Select the region you intend to use for Oracle Functions (recommended to be the same region as the Docker registry specified in the Fn Project CLI context).

Select the compartment specified in the Fn Project CLI context.

Click Create Application and specify:
• helloworld-app
as the name for the new application. You'll deploy your first function in this application, and specify this application when invoking the function.
• The VCN and subnet in which to run the function.

Click Create.
See documentation for more details.
2Create your first function

Log in to your development environment as a functions developer and:

Create a helloworld java function by entering:
$ fn init --runtime java helloworld-func
A directory called helloworld-func is created, containing:
• a function definition file called func.yaml
• a /src directory containing source files and directories for the helloworld function
• a Maven configuration file called pom.xml that specifies the dependencies required to compile the function
Java is just one of several supported languages.
See documentation for more details.
3Deploy your first function

Log in to your development environment as a functions developer and:

Change directory to the helloworld-func directory created in the previous step:
$ cd helloworld-func

Enter the following single Fn Project command to build the function and its dependencies as a Docker image called helloworld-func, push the image to the specified Docker registry, and deploy the function to Oracle Functions in the helloworld-app application that you created earlier:
$ fn -v deploy --app helloworld-app


(Optional) Confirm that the helloworld-func image has been pushed to Oracle Cloud Infrastructure Registry by logging in to the Console as a functions developer. Under Solutions and Platform, go to Developer Services and click Registry. Choose the registry's region, then click the name of the repository you specified in the Fn Project CLI context to see the helloworld-func function within it.


(Optional) Confirm that the function has been deployed to Oracle Functions by logging in to the Console as a functions developer. Under Solutions and Platform, go to Developer Services and click Functions. Select the compartment you specified in the Fn Project CLI context, then click the helloworld-app on the Applications page to see that the helloworld-func function has been deployed to Oracle Functions.
See documentation for more details.
4Invoke your first function

Log in to your development environment as a functions developer and:

Invoke the helloworld-func function in the helloworld-app that you created earlier by entering:
$ fn invoke helloworld-app helloworld-func
The 'Hello, world !' message is displayed.

Invoke the helloworld-func function with the parameter 'John' by entering:

$ echo -n 'John' | fn invoke helloworld-app helloworld-func
The 'Hello, John!' message is displayed.
Congratulations! You've just created, deployed, and invoked your first function using Oracle Functions!
See documentation for more details.
5Next steps
Now that you've created, deployed, and invoked a function, read the documentation to find out how to:
• export function logs by configuring a syslog URL or sending logs to a storage bucket (see Storing and Viewing Function Logs)
• explore Oracle Functions using samples on GitHub (see Oracle Functions Samples)
• invoke a function using SDKs (see Using SDKs to Invoke Functions)
You're done!
Find out more about Oracle Cloud Infrastructure and Oracle Functions
See: User Guide (HTML and PDF), docs.cloud.oracle.com, Fn Project
Attend Oracle Cloud Events