About Code-only Functions
Find out about code-only functions, a way to create functions in OCI Functions from archives instead of container images.
Overview
OCI Functions supports two deployment models:
- Code-only functions that use a function archive.
- Container image-based functions.
With code-only functions, you provide your code and dependencies in an archive and select a supported managed runtime. OCI Functions checks that the archive uses the required format and directory structure for the selected runtime and application architecture, and manages the execution environment used to run the function.
With code-only functions, OCI Functions manages the execution environment, including the operating system and language runtime where applicable. OCI Functions publishes supported runtime versions over time, and you control how your function adopts those versions by setting the runtime update mode.
Use code-only functions when:
- You want the simplest onboarding path for standard Functions runtimes.
- You want to deploy function code without building a container image.
- The function can run on one of the supported managed runtimes.
- You want OCI Functions to manage the runtime.
- You can package the code and dependencies into the required archive structure.
- You do not need custom OS configuration or packages, a custom runtime, or a custom base image.
Use container image-based functions when:
- You need full control over the operating system, packages, runtime, or image contents.
- The function requires custom system libraries or tools not available in the managed runtime.
- You need a custom base image.
- You need full control over how the final deployment artifact is built, scanned, signed, and published as a container image.
- You need to manage image vulnerability scanning or image signing as part of your deployment process.
You can provide the archive for a code-only function in either of the following ways:
Upload the archive file directly when you create or update the function. Use direct archive upload for archives up to 25 MB.
Store the archive in Object Storage and create or update the function by specifying the bucket, namespace, and object name. Use an Object Storage archive source for archives up to 250 MB.
Code-only functions compared with image-based functions
| Area | Code-only functions | Image-based functions |
|---|---|---|
| Deployment artifact | Archive file, such as a ZIP file. For Java, use JAR for a simple function, or ZIP when including resources or native dependencies. Java JARs must be uber/fat JARs. | Container image |
| You build container image | No | Yes |
| You push image to OCIR | No | Yes |
| Runtime | You select a supported managed runtime | Runtime is included in the image |
| Runtime management | Execution environment managed by OCI Functions | Managed by you as part of the image |
| Best for | Standard runtimes, simpler onboarding, simplified operational management, archive-based workflows | Custom runtimes, custom OS packages, specialized dependencies, custom build/sign/scan pipelines |
| Your responsibility | Package code correctly, include dependencies, choose runtime, test function | Build image, manage base image, patch OS/runtime, push image, test function |
You are responsible for the code and dependencies that you include in function archives. Scan your function code and packaged dependencies according to your organization's security policies. OCI Functions manages the execution environment for the code-only function according to the selected runtime update mode.
Code-only functions support the following runtimes:
- Go (for Go code-only functions, you provide a statically linked, self-contained Linux executable binary and OCI Functions provides the supported Oracle Linux runtime environment)
- Java
- Node.js
- Python
Ruby and C# are not supported for code-only functions.
Code-only functions are available in OC1 regions.
Code-only functions support x86, ARM, and multi-architecture applications. The archive layout must match the architecture of the OCI Functions application. Archive structure can differ by runtime and application architecture.
Limits
| Limit | Value |
|---|---|
| Direct archive upload size | 25 MB |
| Object Storage archive source size | 250 MB |
| Supported archive formats | ZIP. For Java, JAR is also supported for a simple function. Java JARs must be uber/fat JARs. |
Changing between code-only and image-based functions
You cannot change a code-only function into a container image-based function. You also cannot change a container image-based function into a code-only function. To change between code-only and image-based function deployment models, create a new function.
Required IAM policy to enable access to Object Storage archives
If you create or update a code-only function using an archive stored in Object Storage, an IAM policy must exist in the tenancy where the archive resides to enable the OCI Functions application resource principal to read the archive object. For example:
Allow any-user to read objects in compartment <compartment-name> where all {request.principal.type = 'fnapp', request.principal.compartment.id = '<compartment-ocid>', target.object.name = '<object-name-containing-the-archive>', target.bucket.name = '<bucket-name>'}