Different Options for Function Development Environments

Find out about development environment options for creating and deploying functions in OCI Functions using the Fn Project CLI.

When setting up a development environment to create and deploy functions in OCI Functions, you have different options. For most users, setting up a local machine is the recommended way to work with OCI Functions.

Use code-only functions when your function can run on a supported managed runtime and you want to deploy function code without building and publishing a container image. Use image-based functions when you need full control over the operating system, packages, runtime, or image contents.

  • Option 1: Setting up a local machine. (Recommended) For most users, setting up a local machine is the preferred way to create, deploy, and invoke functions. You can use a local machine to create code-only functions from archives, or to create image-based functions from container images.

    • For code-only functions, you provide a function archive and select a supported managed runtime. OCI Functions checks that the archive uses the required format and directory structure, and manages the execution environment used to run the function.
    • For image-based functions, you build a container image, push the image to Oracle Cloud Infrastructure Registry, and deploy the function from the image.

    If you set up a local machine, you have to specify --provider oracle when you create a new Fn Project CLI context. This option enables OCI Functions to perform authentication and authorization using OCI request signing, private keys, user groups, and policies that grant permissions to those user groups.

    Use Functions QuickStart on Local Host Using Archives (Code-only Functions) if you want to set up a local machine as your development environment and create a code-only function.

    Use Functions QuickStart on Local Host Using Container Images if you want to set up a local machine as your development environment and create an image-based function.

  • Option 2: Setting up Cloud Shell. Use Cloud Shell when you want to try out image-based functions quickly without installing local development tools. By copying and pasting a few commands from the Console into the Cloud Shell window, you can set up an OCI Functions development environment in just a few minutes.

    If you set up Cloud Shell, two ready-made Fn Project CLI contexts are provided. If you want to create your own Fn Project CLI context, specify --provider oracle-cs when you create the context.

    This option enables you to experiment with creating, deploying, and invoking image-based functions. You can also explore OCI Functions using the samples on GitHub. Note that Cloud Shell allocates 5 GB for each user's home directory, which cannot be expanded or mounted to external storage. You are responsible for performing regular housekeeping to keep space usage below 5 GB.

    Use Functions QuickStart on Cloud Shell Using Container Images if you want to set up Cloud Shell as your development environment for image-based functions.

  • Option 3: Setting up an Oracle Cloud Infrastructure compute instance. For some users, setting up an OCI compute instance is more convenient than setting up a local machine. If you set up an OCI compute instance, you have to specify --provider oracle-ip when you create a new Fn Project CLI context.

    This option enables OCI Functions to perform authentication and authorization using instance OCIDs, dynamic groups, and policies that grant permissions to those dynamic groups. This approach removes the requirement for users to manage private keys.

    To set up an OCI Functions development environment on an OCI compute instance, you must have permission to create dynamic groups, create a dynamic group that includes the compute instance's OCID, create a policy to give the dynamic group access to function resources and network resources, and specify --provider oracle-ip when you create a new Fn Project CLI context.

    Use Functions QuickStart on an OCI Compute Instance Using Container Images if you want to set up an OCI compute instance as your development environment.

Setting Fn Project CLI context for different development environments

The Fn Project CLI uses a context to connect to your OCI tenancy. The context specifies OCI Functions endpoints and the OCID of the compartment to which deployed functions will belong. For code-only functions using the implicit developer flow, the context can also specify Object Storage details for archive upload. For image-based functions, the context also specifies the address of the container registry to and from which to push and pull images.

When setting up a local machine development environment, or an OCI compute instance development environment, you have to create your own Fn Project CLI context. The Cloud Shell development environment provides two ready-made contexts, although you can create your own.

When you create a Fn Project CLI context, you use the fn create context command, and you specify an authentication provider. The provider to specify depends on the development environment you are using, as shown in the following table:

Development Environment Command to create Fn Project CLI context
Local Machine fn create context <my-context> --provider oracle
Cloud Shell fn create context <my-context> --provider oracle-cs
OCI Compute Instance fn create context <my-context> --provider oracle-ip