### Display Help for 'update app' Command Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsusingwithfncli.htm This example shows how to get detailed help for a subcommand like 'update app' using the --help or -h flag. ```bash fn update app -h ``` -------------------------------- ### Example OCIR Login with Namespace and User Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsquickstartocicomputeinstance.htm An example of the `docker login` command using a sample tenancy namespace and username. ```bash docker login -u 'ansh81vru1zp/jdoe@acme.com' phx.ocir.io ``` -------------------------------- ### Example func.yaml with Signing Details Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsenforcingsignedimagesfromocir.htm This is a complete example of a func.yaml file including the `signing_details` section with placeholder OCIDs and a specific signing algorithm. ```yaml schema_version: 20180708 name: hello-java version: 0.0.1 runtime: java build_image: fnproject/fn-java-fdk-build:jdk11-1.0.141 run_image: fnproject/fn-java-fdk:jre11-1.0.141 cmd: com.example.fn.HelloFunction::handleRequest signing_details: image_compartment_id: ocid1.tenancy.oc1..aaaaaaaa___ta kms_key_id: ocid1.key.oc1.phx.bbqehaq3aadfa.abyh______qlj kms_key_version_id: ocid1.keyversion.oc1.phx.0.bbqehaq3aadfa.acy6______mbb signing_algorithm: SHA_224_RSA_PKCS_PSS ``` -------------------------------- ### Example: Build and Push Multi-Architecture Image Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsspecifyingcomputearchitectures.htm This example demonstrates building a multi-architecture image supporting both Arm64 and AMD64 architectures, tagging it as 'my-manifest-name:1.0.0-SNAPSHOT-X86-ARM', and pushing it to the registry. ```bash docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag my-manifest-name:1.0.0-SNAPSHOT-X86-ARM . ``` -------------------------------- ### Python Example: Making an Authenticated OCI Request Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsaccessingociresources.htm Demonstrates how to use the `rp_auther` function to obtain claims and an authentication object, then makes a GET request to the OCI Identity API to retrieve tenancy information. ```python # Use RP credentials to make a request region = os.environ['OCI_RESOURCE_PRINCIPAL_REGION'] claims, rp_auth = rp_auther() response = requests.get("https://identity.{}.oraclecloud.com/20160918/tenancies/{}".format(region, claims['res_tenant']), auth=rp_auth) print(response.json()) ``` -------------------------------- ### Example OCI Registry Login Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionslogintoocir.htm An example of the `docker login` command using 'phx' as the region key for the Phoenix region. ```bash docker login phx.ocir.io ``` -------------------------------- ### Example Commit Message Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionscreatingfromtemplateusingcodeeditor.htm An example commit message for adding hello-world files to the repository. ```text Adds hello-world files. ``` -------------------------------- ### Docker Running Confirmation Message Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsstartdocker.htm This is an example of the expected output when Docker is running correctly. If you see this message, you can proceed with OCI Functions setup. ```text Hello from Docker. This message shows that your installation appears to be working correctly. ``` -------------------------------- ### Example Dockerfile for OCI Functions Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsrunningasunprivileged.htm This example Dockerfile demonstrates setting up a Node.js environment, including creating the 'fn' user and group, for a function deployed to OCI Functions. ```dockerfile FROM oraclelinux:7-slim RUN yum -y install oracle-release-el7 oracle-nodejs-release-el7 && \ yum-config-manager --disable ol7_developer_EPEL && \ yum -y install oracle-instantclient19.3-basiclite nodejs && \ rm -rf /var/cache/yum && \ groupadd --gid 1000 fn && \ adduser --uid 1000 --gid fn fn WORKDIR /function ADD . /function/ RUN npm install CMD exec node func.js ``` -------------------------------- ### Debug Log Example Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsusingwithfnserverlocally.htm An example of the debug log output when the Fn Server is started with the DEBUG log level. This includes logs from the function code itself. ```text time="2026-02-12T09:05:14Z" level=debug msg="01KH______01 - root - INFO - Inside Python Hello World function\n" action="server.(*Server).handleFnInvokeCall-fm" app_id=01KH______001 call_id=01KH______001 fn_id=01KH______04 image="simple-default-python:0.0.140" user_log=true ``` -------------------------------- ### Start Fn Server Locally Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsdeveloplocallywithhotreloadandfnserver.htm Starts the local Fn Server, which is required to run and manage functions on your local machine. ```bash fn start ``` -------------------------------- ### OCI Configuration File Example Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsusingwithfnserverlocally.htm This is an example of the OCI configuration file (`~/.oci/config`) required for user API key authentication. Ensure all fields are correctly populated with your OCI user, tenancy, and region details, and that the `key_file` points to your private key. ```ini [DEFAULT] user= fingerprint= tenancy= region= key_file=/myfunc/.oci/oci_api_key_private_key.pem ``` -------------------------------- ### Create a Custom Span in Example Function Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionstracing.htm Demonstrates creating a custom span named 'Get ADB Password from OCI Vault' within an example function. It shows how to update spans with error messages or response details. ```python def example(ctx): with zipkin_span( service_name=ctx.TracingContext().service_name(), span_name="Get ADB Password from OCI Vault", binary_annotations=ctx.TracingContext().annotations() ) as example_span_context: try: logging.getLogger().debug("Get ADB Password from OCI Vault") time.sleep(0.005) # throwing an exception to show how to add error messages to spans raise Exception('Request failed') except (Exception, ValueError) as error: example_span_context.update_binary_annotations( {"Error": True, "errorMessage": str(error)} ) else: FakeResponse = namedtuple("FakeResponse", "status, message") fakeResponse = FakeResponse(200, "OK") # how to update the span dimensions/annotations example_span_context.update_binary_annotations( { "responseCode": fakeResponse.status, "responseMessage": fakeResponse.message } ) ``` -------------------------------- ### Example: Create Fn App with Syslog URL Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsexportingfunctionlogfiles.htm This is a concrete example of creating a new Fn application named 'acmeapp' and directing its logs to 'tcp://my.papertrail.com:4242'. It also specifies the subnet OCID for the application. ```bash fn create app acmeapp --syslog-url tcp://my.papertrail.com:4242 --annotation oracle.com/oci/subnetIds='["ocid1.subnet.oc1.phx.aaaaaaaacnh..."]' ``` -------------------------------- ### Get Application Details with Fn Project CLI Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/get-application.htm Use this command to retrieve detailed information about a specific application managed by the Fn Project CLI. Ensure you have the Fn Project CLI installed and configured. ```bash fn inspect app ``` ```json { "annotations": { "oracle.com/oci/appCode": "fht7ns4mn2q", "oracle.com/oci/compartmentId": "ocid1.compartment.oc1..aaaaaaaaw______nyq", "oracle.com/oci/subnetIds": [ "ocid1.subnet.oc1.phx.aaaaaaaao..." ], "oracle.com/oci/tenantId": "ocid1.tenancy.oc1..aaaaaaaap...keq" }, "created_at": "2018-07-13T17:54:34.000Z", "id": "ocid1.fnapp.oc1.phx.aaaaaaaaaf______r3ca", "name": "acme-app", "updated_at": "2018-07-13T17:54:34.000Z" } ``` -------------------------------- ### Example Fn Context File Content Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionscreatefncontext.htm This is an example of the content found within an Fn Project CLI context file, showing the API URL, provider, registry, and compartment ID. ```yaml api-url: https://functions.us-phoenix-1.oci.oraclecloud.com provider: oracle registry: phx.ocir.io/ansh81vru1zp/acme-repo oracle.image-compartment-id: ``` -------------------------------- ### Example Application Name Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionscreatingfromcoderepousingcodeeditor.htm An example name for a new OCI Functions application. ```text helloworld-python-app ``` -------------------------------- ### Example Fn Project CLI Context Configuration for Image Compartment Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsquickstartocicomputeinstance.htm An example of setting the `oracle.image-compartment-id` context for the Fn Project CLI. ```bash fn update context oracle.image-compartment-id ocid1.compartment.oc1..aaaaaaaaquqe______z2q ``` -------------------------------- ### Example: Alarm for Total Provisioned Concurrency Memory Allocation (40GB Total) Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsmonitoringcapacityusage_topic-Monitoring-provisioned-concurrency.htm An example query to set an alarm when total provisioned concurrency memory allocation exceeds 70% of 40 GB (28672 MiB). ```oci AllocatedProvisionedConcurrency[5m].grouping().sum() > 28672 ``` -------------------------------- ### Install Fn CLI using Homebrew (macOS) Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsinstallfncli.htm Use this command to install the Fn Project CLI on a macOS environment with Homebrew. ```bash brew update && brew install fn ``` -------------------------------- ### Example func.yaml Configuration Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsusingcustomdockerfiles.htm This is an example of a func.yaml file used by OCI Functions to define function metadata and build/run images. It specifies the runtime, build image, run image, and command for a Java function. ```yaml schema_version: 20180708 name: hello-java version: 0.0.1 runtime: java build_image: fnproject/fn-java-fdk-build:jdk11-1.0.116 run_image: fnproject/fn-java-fdk:jre11-1.0.116 cmd: com.example.fn.HelloFunction::handleRequest ``` -------------------------------- ### Install Fn CLI using Curl Script (Linux/macOS) Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsinstallfncli.htm Install the Fn Project CLI on Linux or macOS by downloading and executing a script from the official repository. You may be prompted for a superuser password. ```bash curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh ``` -------------------------------- ### Custom Dockerfile for Oracle Instant Client and Node.js Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsusingcustomdockerfiles.htm This custom Dockerfile installs Oracle Instant Client and Node.js on an oraclelinux:7-slim base image. It sets up the working directory, adds application files, installs npm dependencies, and defines the command to execute. ```dockerfile FROM oraclelinux:7-slim RUN yum -y install oracle-release-el7 oracle-nodejs-release-el7 && \ yum-config-manager --disable ol7_developer_EPEL && \ yum -y install oracle-instantclient19.3-basiclite nodejs && \ rm -rf /var/cache/yum WORKDIR /function ADD . /function/ RUN npm install CMD exec node func.js ``` -------------------------------- ### Example: Alarm for Specific Function's Memory Allocation (10% of 40GB) Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsmonitoringcapacityusage_topic-Monitoring-provisioned-concurrency.htm An example query to set an alarm when a specific function's provisioned concurrency memory allocation exceeds 10% of 40 GB (4096 MiB). ```oci AllocatedProvisionedConcurrency[5m]{resourceId = "ocid1.fnfunc.oc1.phx.aaaa____uxoa"}.max() > 4096 ``` -------------------------------- ### Example of Deleting an Application using Fn Project CLI Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsdeletingapplications.htm This is an example command demonstrating how to delete an application named 'acmeapp' using the Fn Project CLI. ```bash fn delete app acmeapp ``` -------------------------------- ### Example Log Entry for Database Secret Rotation with Wallet Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functions_pbf_database_secret_rotation_with_wallet.htm This is an example log entry for the Database Secret Rotation with Wallet pre-built function, showing the format and logging level. ```text PBF | Database Secret Rotation with Wallet | INFO | 2024-01-31T18:06:50.809Z | Fetching details from Events JSON ``` -------------------------------- ### Example: Update Fn App to Use Syslog URL Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsexportingfunctionlogfiles.htm This example demonstrates updating an existing Fn application named 'acmeapp' to direct its logs to the syslog URL 'tcp://my.papertrail.com:4242'. ```bash fn update app acmeapp --syslog-url tcp://my.papertrail.com:4242 ``` -------------------------------- ### Media Workflow Job Spawner Log Entry Example Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functions_pbf_catalog_media_workflow_job.htm This is an example log entry for the Media Workflow Job Spawner pre-built function, showing the standard prefix and log format. ```text "PBF | Media Workflow Job Spawner | INFO | 2023-02-07T18:06:50.809Z | Fetching details from Events JSON" ``` -------------------------------- ### Start fn watch from Function Project Directory Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsdeveloplocallywithhotreloadandfnserver.htm Start the `fn watch` command from the root directory of your function project to enable automatic redeployment. Ensure `func.yaml` is present in the directory. ```bash fn watch --app ``` -------------------------------- ### Application Inspection Output Example Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsupdatingapplications.htm This is an example of the JSON output you can expect when inspecting an application's details using the Fn Project CLI. It shows various properties including annotations, creation and update timestamps, ID, name, and syslog URL. ```json { "annotations": { "oracle.com/oci/compartmentId": "ocid1.compartment.oc1..aaaaaaaaw______nyq", "oracle.com/oci/subnetIds": [ "ocid1.subnet.oc1.iad.aaaaaaaa7______5qa" ] }, "created_at": "2020-02-18T11:53:07.375Z", "id": "ocid1.fnapp.oc1.iad.aaaaaaaaaf______r3ca", "name": "acme-app", "syslog_url": "tcp://my.papertrail.com:4242", "updated_at": "2020-03-25T10:13:32.163Z" } ``` -------------------------------- ### Borders Configuration Example Source: https://docs.oracle.com/en-us/iaas/Content/Functions/non-dita/DocGenPBF-xls/markdown/DocGen-Excel-Template-Tags.htm Configures the borders for all four sides of a cell with different styles and colors. ```json { "top": { "borderStyle": "MEDIUM", "color": { "colorType": "OPAQUE_HEX_RGB", "value": "FFFF00" } }, "bottom": { "borderStyle": "DASHED", "color": { "colorType": "OPAQUE_HEX_RGB", "value": "FF00FF" } }, "left": { "borderStyle": "DOTTED" }, "right": { "borderStyle": "MEDIUM_DASHED" } } ``` -------------------------------- ### Font Styling Example Source: https://docs.oracle.com/en-us/iaas/Content/Functions/non-dita/DocGenPBF-xls/markdown/DocGen-Excel-Template-Tags.htm Applies various font properties like family, size, color, and style. ```json { "font": { "familyName": "Cookie", "sizeInPoints": 20, "color": { "colorType": "OPAQUE_HEX_RGB", "value": "FF0000" }, "isBold": true, "isItalic": true, "isStrikethrough": true, "underline": "DOUBLE", "textPosition": "SUPERSCRIPT" } } ``` -------------------------------- ### Conditional Expression Examples Source: https://docs.oracle.com/en-us/iaas/Content/Functions/non-dita/DocGenPBF-doc/markdown/DocGen-Template-Tags.htm Demonstrates various conditional expressions using operators and functions. ```template age >= 18 ``` ```template a == b || c == d && e > 0 ``` ```template (title=="manager" || title == "director") && employeeCount > 2 ``` ```template StartsWith(movieName, "The") && year == 1999 ``` ```template Contains(movieName, "Matrix") || movies.0.actor != "Pitt" ``` ```template (numberOfTomatoes > maxTomatoes) == false ``` ```template -1 >= -1.01 || UnknownName == "Smith" ``` ```template Contains(drink, "Cafe\u0301") ``` -------------------------------- ### Custom Dockerfile for Go Function Debugging Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsdebugfunctionslocally.htm This Dockerfile example builds a Go function with debugging enabled using Delve and starts the debugger on port 5678. ```dockerfile FROM fnproject/go:1.24-dev as build-stage WORKDIR /function WORKDIR /go/src/func/ ENV GO111MODULE=on COPY . . RUN go mod tidy RUN go build -gcflags="all=-N -l" -o func -v RUN go install github.com/go-delve/delve/cmd/dlv@latest FROM fnproject/go:1.24 WORKDIR /function COPY --from=build-stage /go/src/func/func /function/ COPY --from=build-stage /go/bin/dlv /function CMD ["/function/dlv", "--listen=:5678", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "./func"] ``` -------------------------------- ### Create an Application Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsusingwithfncli.htm This command demonstrates how to create a new application, specifying its name and associated subnet IDs through annotations. ```bash fn create app acmeapp --annotation oracle.com/oci/subnetIds='["ocid1.subnet.oc1.phx.aaaaaaaacnh..."]' ``` -------------------------------- ### Set Custom Debounce Time for Redeploys Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsdeveloplocallywithhotreloadandfnserver.htm Starts watch mode with a custom debounce time, controlling the delay between file changes and redeployment. This example sets the debounce time to 2 seconds. ```bash fn watch --app myapp --debounce 2s ``` -------------------------------- ### Python Custom Resource Principal Provider Example Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsaccessingociresources.htm This Python code demonstrates a custom resource principal provider. It loads credentials from environment variables and RPST token, then makes an authenticated GET request to the IAM API to retrieve the tenancy OCID. ```python #!/usr/bin/env python3 import base64 import email.utils import hashlib import httpsig_cffi.sign import json import logging import os.path import re import requests.auth import urllib.parse LOG = logging.getLogger(__name__) ``` -------------------------------- ### Example func.yaml build and run images Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionssupportedlanguageversions.htm Shows the default or current build_image and run_image parameters in a func.yaml file for a Java function. ```yaml build_image: fnproject/fn-java-fdk-build:jdk11-1.0.105 run_image: fnproject/fn-java-fdk:jre11-1.0.105 ``` -------------------------------- ### Build, Push, and Deploy Helloworld Function Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionscreatingfirst.htm Builds the Docker image for the helloworld function, pushes it to the configured Docker registry, and deploys it to an OCI Functions application. The -v flag provides verbose output. ```bash fn -v deploy --app helloworld-app ``` -------------------------------- ### Verify Fn CLI Installation Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsinstallfncli.htm Confirm that the Fn Project CLI has been successfully installed by checking its version. This command should display the installed CLI version. ```bash fn version ``` -------------------------------- ### Check Docker Installation Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsinstalldocker.htm Use this command to verify if Docker is installed on your development environment. ```bash docker version ``` -------------------------------- ### Check Supported Runtimes with fn init --help Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionssupportedlanguageversions.htm Use this command to list all available language runtimes and their specific versions supported by the Fn Project CLI. This helps in selecting the correct runtime for your function. ```bash fn init --help | grep runtime ``` ```text --runtime value Choose an existing runtime - dotnet, dotnet3.1, dotnet6.0, dotnet8.0, go, go1.18, go1.19, java, java11, java17, java8, kotlin, node, node14, node16, node18, python, python3.11, python3.8, python3.9, ruby, ruby2.7, ruby3.1 ``` -------------------------------- ### Example Application OCID Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsmonitoringcapacityusage_topic-Monitoring-concurrent-function-execution.htm This is an example of an Oracle Cloud Infrastructure Function Application OCID. ```text ocid1.fnapp.oc1.phx.aaaaaaaaaf______r3ca ``` -------------------------------- ### List Applications using Fn Project CLI Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionscreatingapps-task.htm Verify the creation of a new application by listing all applications in the current context using the Fn Project CLI. ```bash fn list apps ``` ```text $ fn list apps acmeapp ``` -------------------------------- ### Example of Inspect Function Output Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsupdatingfunctions.htm This is an example of the JSON output you can expect when inspecting a function, showing its configuration details. ```json { "annotations": { "fnproject.io/fn/invokeEndpoint": "https://fht7ns4mn2q.us-phoenix-1.functions.oci.oraclecloud.com/20181201/functions/ocid1.fnfunc.oc1.phx.aaaa____uxoa/actions/invoke", "oracle.com/oci/compartmentId": "ocid1.compartment.oc1..aaaaaaaaw______nyq" }, "app_id": "ocid1.fnapp.oc1.phx.aaaaaaaaaf______r3ca", "created_at": "2018-07-26T12:50:53.000Z", "format": "default", "id": "ocid1.fnfunc.oc1.phx.aaaa____uxoa", "image": "phx.ocir.io/ansh81vru1zp/acme-repo/acme-func:0.0.4", "memory": 256, "name": "acme-func", "timeout": 60, "updated_at": "2018-07-26T13:59:18.000Z" } ``` -------------------------------- ### Display Help for 'create' Command Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsusingwithfncli.htm To get detailed information about a specific Fn Project CLI command, such as 'create', use the --help or -h flag with the command itself. ```bash fn create --help ``` -------------------------------- ### Example Dynamic Group Rule Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsscheduling.htm An example of a dynamic group rule using a specific resource schedule OCID. ```HCL ALL {resource.type='resourceschedule', resource.id='ocid1.resourceschedule.oc1.phx.amaaaaaa3______owq'} ``` -------------------------------- ### Initialize a Function with Fn Project CLI Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsuploading.htm Use this command to initialize a new function project with a specified runtime language and function name. The command creates necessary files like func.yaml, source files, and build configuration. ```bash fn init --runtime ``` ```bash fn init --runtime java acme-func ``` -------------------------------- ### Create a New Fn Project CLI Context Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionscreatefncontext.htm Use this command to create a new context for connecting to Oracle Cloud Infrastructure. Replace with your desired context name. ```bash fn create context --provider oracle ``` ```bash fn create context johns-oci-context --provider oracle ``` -------------------------------- ### JSON Data Structure Example Source: https://docs.oracle.com/en-us/iaas/Content/Functions/non-dita/DocGenPBF-doc/markdown/examples/Word-HLoop.json This JSON structure defines weekdays and a distribution flag. It is used as an example input for function processing. ```json { "weekdays1": [ { "name": "Monday" }, { "name": "Tuesday" }, { "name": "Wednesday" }, { "name": "Thursday" }, { "name": "Friday" } ], "weekdays2_distribute": true, "weekdays2": [ { "name": "Monday" }, { "name": "Tuesday" }, { "name": "Wednesday" }, { "name": "Thursday" }, { "name": "Friday" } ] } ``` -------------------------------- ### Initialize a Helloworld Java Function Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionscreatingfirst.htm Creates a new directory with the basic structure for a Java helloworld function using the Fn Project CLI. ```bash fn init --runtime java helloworld-func ``` -------------------------------- ### OCI Functions: Example Specific Function OCID Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsmonitoringcapacityusage_topic-Monitoring-provisioned-concurrency.htm An example of how to specify a function OCID when querying allocated provisioned concurrency memory. ```oci-monitoring-query AllocatedProvisionedConcurrency[5m]{resourceId = "ocid1.fnfunc.oc1.phx.aaaa____uxoa"}.max() ``` -------------------------------- ### Build Multi-Architecture Image with Docker Buildx Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionstroubleshooting_topic-Issues-deploying-applications-and-functions.htm Build a multi-architecture Docker image for deployment. This command pushes the image directly to the registry. Replace /: with your registry, image name, and tag. ```bash docker buildx build --platform linux/amd64,linux/arm64 -t /: --push . ``` -------------------------------- ### Run Hello-World Docker Image Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsstartdocker.htm Execute this command in a terminal to verify if Docker is running. The output will indicate whether Docker is operational or if further action is required. ```bash docker run hello-world ``` -------------------------------- ### Initialize a New Function with a Specific Runtime Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionssupportedlanguageversions.htm Use this command to create a new function project for a specified language. The `func.yaml` file generated will contain the default FDK build and run image versions for that language. ```bash fn init --runtime hello-func ``` ```bash fn init --runtime java hello-func ``` -------------------------------- ### Document Generator Log Entry Example Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functions_pbf_catalog_document_generator.htm An example of a log entry for the Document Generator pre-built function, showing how to identify PBF logs and their details. ```text "PBF | Document Generator | INFO | 2023-08-31T20:19:51.181593Z | 2. LOG001 - Setting Log Level to : DEBUG" ``` -------------------------------- ### Start Watch Mode with Custom Ignore Patterns Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsdeveloplocallywithhotreloadandfnserver.htm Starts watch mode and specifies custom ignore patterns directly via command-line arguments. ```bash fn watch --app myapp --ignore .idea --ignore '*.log' ``` -------------------------------- ### Number Formatting Examples Source: https://docs.oracle.com/en-us/iaas/Content/Functions/non-dita/DocGenPBF-doc/markdown/DocGen-Template-Tags.htm Illustrates various number formatting options using the pipe syntax with different Oracle Number Formats, separators, and currency symbols. ```template {unit_price|format:"FML999G999G999G999G990D00":"<>":"$"} ``` ```template {unit_price|format:"999G999G999G999G990D00":",."} ``` ```template {unit_price|format:"999G999G999G999G990D00":", "} ``` ```template {unit_price|format:"999G999G999G999G999G999G990"} ``` ```template {unit_price|format:"999G999G999G999G990D00MI"} ``` ```template {unit_price|format:"S999G999G999G999G990D00"} ``` ```template {unit_price|format:"999G999G999G999G990D00PR"} ``` ```template {unit_price|format:"FML999G999G999G999G990PR"} ``` -------------------------------- ### Example ZPR Policy for Resource Access Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsusingzpr.htm An example of a ZPR policy that allows a specific functions application to connect to a database server resource within a VCN. ```plaintext in VCN-Network:myVCN VCN allow functions-app:myFuncAppA endpoints to connect to DB-Server:App1 endpoints ``` -------------------------------- ### Create an Application for Functions Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsdebugfunctionslocally.htm Creates a new application to contain your functions if one does not already exist. ```bash fn create app ``` -------------------------------- ### Example Function Response (List Compartments) Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionscreatingfromsampleusingcodeeditor.htm This is an example response from a function based on the 'oci-list-compartments-python' sample, after being added to a dynamic group. It returns a list of compartments in the tenancy. ```json {"compartments": [["", ""], ["", ""]… } ``` -------------------------------- ### Initialize a New Function Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsdebugfunctionslocally.htm Initializes a new function project for a specified runtime and function name. Navigate into the function's directory afterward. ```bash fn init --runtime ``` ```bash cd ``` -------------------------------- ### Example Log Entry for Database Secret Rotation Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functions_pbf_database_secret_rotation_without_wallet.htm This is an example log entry format for the Database Secret Rotation without Wallet pre-built function, useful for debugging. ```text "PBF | Database Secret Rotation without Wallet | INFO | 2024-01-31T18:06:50.809Z | Fetching details from Events JSON" ``` -------------------------------- ### Example IAM Policy for Cross-Tenancy Image Pulling Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionspullingimagescrosstenancy.htm An example of the IAM policy statement used to allow functions from the 'application-tenancy' to pull images from the destination tenancy's repositories. ```text Define tenancy application-tenancy as 'ocid1.tenancy.oc1..aaaa______abc' Admit any-user of tenancy application-tenancy to { REPOSITORY_READ } in tenancy where all { request.principal.type = 'fnapp', request.principal.repo_name = target.repo.name} ``` -------------------------------- ### Initialize a Java Function Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsquickstartcloudshell.htm Use this command to create a new Java function project. It sets up the necessary directory structure and configuration files. ```bash fn init --runtime java hello-java ``` -------------------------------- ### Example APM Log Sender Log Entry Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functions_pbf_apm_log_sender.htm Example log entry format for the APM Log Sender pre-built function, showing how to identify its logs and potential errors. ```text "PBF | APM Log Sender | ERROR | 2024-08-13T12:44:49.579050219Z | Unable to retrieve data upload endpoint" ``` -------------------------------- ### List Functions using Fn Project CLI Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionscreatingfunctions.htm Verify the creation of a new function by listing all functions within a specified application. This command helps confirm the function was successfully added. ```bash fn list functions ``` ```bash fn list functions acme-app ``` -------------------------------- ### View Fn Context File Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionscreatefncontext.htm Verify the created Fn Project CLI context by viewing its configuration file. This command displays the contents of the context file. ```bash more ~/.fn/contexts/johns-oci-context.yaml ``` -------------------------------- ### Cost Reports FOCUS Converter Log Entry Example Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functions_pbf_catalog_cost_reports_focus_converter.htm This is an example log entry for the Cost Reports FOCUS Converter pre-built function, showing the log format and identifying prefix. ```text "PBF | FOCUS Converter | INFO | 2023-02-07T18:06:50.809Z | Target Bucket Details from input payload: Bucket Name: target-storage File path: /" ``` -------------------------------- ### Deploy a Function to OCI Functions Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsquickstartocicomputeinstance.htm Navigate to your function's directory and use this command to build, push, and deploy the function to your OCI Functions application. Ensure you are in the 'hello-java' directory. ```bash cd hello-java ``` ```bash fn -v deploy --app helloworld-app ``` -------------------------------- ### Create Fn App with Syslog URL Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsexportingfunctionlogfiles.htm Use this command to create a new Fn application and immediately configure it to send all its function logs to a specified external syslog URL. Ensure you provide a valid application name, syslog URL, and subnet OCID(s). ```bash fn create app --syslog-url --annotation oracle.com/oci/subnetIds='[""]' ``` -------------------------------- ### List Functions using Fn Project CLI Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionscreatingfunction-task.htm Verify the creation of a new function by listing all functions within a specified application. This command helps confirm the function's name and associated image. ```bash fn list functions ``` ```bash $ fn list functions acme-app NAME IMAGE acme-func phx.ocir.io/ansh81vru1zp/acme-repo/acme-func:0.0.3 ``` -------------------------------- ### Get Function Details with OCI CLI Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/get-function.htm Use the `oci fn function get` command with the function's OCID to retrieve its details. This method requires the specific OCID of the function. ```bash oci fn function get --function-id [OPTIONS] ``` -------------------------------- ### Complete Java Tracing Function Example Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionstracing.htm This is a complete Java function demonstrating initialization of Zipkin tracing and handling requests with custom spans for 'MainHandle', 'Method1', 'Method2', and 'Method3'. It includes error handling and span finalization. ```java package com.example.fn; import brave.Span; import brave.Tracer; import brave.Tracing; import brave.propagation.*; import brave.sampler.Sampler; import com.fnproject.fn.api.tracing.TracingContext; import com.github.kristofa.brave.IdConversion; import zipkin2.reporter.Sender; import zipkin2.reporter.brave.AsyncZipkinSpanHandler; import zipkin2.reporter.urlconnection.URLConnectionSender; public class HelloFunction { Sender sender; AsyncZipkinSpanHandler zipkinSpanHandler; Tracing tracing; Tracer tracer; String apmUrl; TraceContext traceContext; public void intializeZipkin(TracingContext tracingContext) throws Exception { System.out.println("Initializing the variables"); apmUrl = tracingContext.getTraceCollectorURL(); sender = URLConnectionSender.create(apmUrl); zipkinSpanHandler = AsyncZipkinSpanHandler.create(sender); tracing = Tracing.newBuilder() .localServiceName(tracingContext.getServiceName()) .sampler(Sampler.NEVER_SAMPLE) .addSpanHandler(zipkinSpanHandler) .build(); tracer = tracing.tracer(); tracing.setNoop(!tracingContext.isTracingEnabled()); traceContext = TraceContext.newBuilder() .traceId(IdConversion.convertToLong(tracingContext.getTraceId())) .spanId(IdConversion.convertToLong(tracingContext.getSpanId())) .sampled(tracingContext.isSampled()).build(); } public String handleRequest(String input, TracingContext tracingContext) { try { intializeZipkin(tracingContext); // Start a new trace or a span within an existing trace representing an operation Span span = tracer.newChild(traceContext).name("MainHandle").start(); System.out.println("Inside Java Hello World function"); try (Tracer.SpanInScope ws = tracer.withSpanInScope(span)) { method1(); method2(); method3(); } catch (RuntimeException | Error e) { span.error(e); // Unless you handle exceptions, you might not know the operation failed! throw e; } finally { span.finish(); // note the scope is independent of the span. Always finish a span. tracing.close(); zipkinSpanHandler.flush(); } } catch (Exception e) { return e.getMessage(); } return "Hello, AppName " + tracingContext.getAppName() + " :: fnName " + tracingContext.getFunctionName(); } public void method1() { System.out.println("Inside Method1 function"); TraceContext traceContext = tracing.currentTraceContext().get(); Span span = tracer.newChild(traceContext).name("Method1").start(); try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } finally { span.finish(); } } public void method2() { System.out.println("Inside Method2 function"); TraceContext traceContext = tracing.currentTraceContext().get(); Span span = tracer.newChild(traceContext).name("Method2").start(); try { Thread.sleep(400); } catch (InterruptedException e) { e.printStackTrace(); } finally { span.finish(); } } public void method3() { System.out.println("Inside Method3 function"); TraceContext traceContext = tracing.currentTraceContext().get(); Span span = tracer.newChild(traceContext).name("Method3").start(); try { Thread.sleep(300); } catch (InterruptedException e) { e.printStackTrace(); } finally { span.finish(); } } } ``` -------------------------------- ### Configure .fnignore File Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsdeveloplocallywithhotreloadandfnserver.htm Specifies files and directories to be ignored by `fn watch` during automatic redeployment. Add one pattern per line. ```properties # IDE files .idea # Python cache __pycache__ # Logs *.log ``` -------------------------------- ### Display General Help for Fn Project CLI Source: https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsusingwithfncli.htm To see a complete list of available Fn Project CLI commands, you can use the --help or -h flag with the main 'fn' command. ```bash fn --help ``` ```bash fn -h ```