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 an OCI compute instance
C. Set up dev environment on the compute instance
D. Set up Fn Project CLI on the compute instance
E. 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, select the tenancy's root compartment and create a new policy with the following policy statements:
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 compartment <compartment-name>
See documentation for more details.
B. Set up an OCI compute instance
For some users, setting up a development environment on an Oracle Cloud Infrastructure compute instance will be more convenient than setting up a local machine.
When you set up an Oracle Cloud Infrastructure compute instance, you'll have to specify --provider oracle-ip
when you create a new Fn CLI context later on. This enables Oracle Functions to perform authentication and authorization using instance OCIDs, dynamic groups, and policies granting permissions to those dynamic groups. This approach removes the requirement for users to manage private keys. Note that to set up an Oracle Functions development environment on a compute instance, you must have permission to create dynamic groups.
1Create instance and obtain OCID
Log in to the Console as a tenancy administrator and:

Under Core Infrastructure, go to Compute and click Instances.
Select the compartment in which to create network resources and Oracle Functions resources.

If a suitable compute instance doesn't exist in the compartment already, click Create Instance and:
• select the compartment, VCN, and subnets for use with Oracle Functions
• specify that a public IP address is to be assigned to the new compute instance
• select the file that contains the SSH key to access the new compute instance

On the Instance Details page, copy the OCID and public IP address of the compute instance to use as the development environment.
See documentation for more details.
2Create a dynamic group
Create a new dynamic group to include the compute instance. Log in to the Console as a tenancy administrator and:


Under Governance and Administration, go to Identity and click Dynamic Groups.

Create a new dynamic group.

Enter a rule that includes the compute instance's OCID:
ANY {instance.id = '<instance-ocid>'}
See documentation for more details.
3Create policy for dynamic group
Create a policy to give the new dynamic group access to function resources, network resources, and Oracle Cloud Infrastructure Registry. Log in to the Console as a tenancy administrator and:

Under Governance and Administration, go to Identity and click Policies.

Select the tenancy's root compartment and create a new policy with three policy statements:
Allow dynamic-group <dynamic-group-name> to manage functions-family in compartment <compartment-name>
Allow dynamic-group <dynamic-group-name> to use virtual-network-family in compartment <compartment-name>
Allow dynamic-group <dynamic-group-name> to read repos in tenancy
See documentation for more details.
C. Set up dev environment on the compute instance
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.
D. Set up Fn Project CLI on the compute instance
1Set up Fn Project CLI context --provider oracle-ip
Log in to your OCI compute instance development environment as a functions developer and:

Create a new Fn CLI context by entering:
$ fn create context <my-context> --provider oracle-ip
Note that you specify --provider oracle-ip
to enable authentication and authorization using instance OCIDs, dynamic groups, and policies granting permissions to those dynamic groups.

Specify that the Fn Project CLI is to use the new context by entering:
$ fn use context <my-context>
2Complete 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.
E. 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