Invoke Oracle Cloud Infrastructure Functions Directly from an Integration with an OCI Function Action

Oracle Integration provides native support for invoking Oracle Cloud Infrastructure functions. This support enables you to invoke Oracle Cloud Infrastructure functions with an OCI Function action in an integration.

Oracle Cloud Infrastructure functions are part of a fully managed, multi-tenant, highly scalable, on-demand, Functions-as-a-Service platform. Use Oracle Cloud Infrastructure functions to focus on writing code to meet business needs. See Overview of Functions and Functions QuickStart Guides.

Note:

Ensure that your cloud tenancy uses identity domains. The OCI Function action in the integration canvas does not work in cloud tenancies that are not enabled for identity domains.

Want to see a video demo of the OCI Function action?

Capabilities

Oracle Cloud Infrastructure functions provide serverless execution of functions within Oracle Integration to process complex logic not easily performed in Oracle Integration, such as the following:
  • Creating a digital signature based on a key against a specific payload.
  • Supporting a custom ZIP format such as GZIP or TAR.
  • Taking and parsing a PDF file for data fields that can then participate in an integration.

Oracle Integration supports whatever functions you create using Oracle Cloud Infrastructure functions. Oracle Cloud Infrastructure also provides a catalog of prebuilt functions. See Creating Functions Using Pre-Built Functions.

Prerequisites

Note:

When making cross-region calls (the function is in a different region than that of the Oracle Integration service instance), ensure you do the following:
You must perform the following prerequisites from the Oracle Cloud Infrastructure Console before you can invoke functions from an integration. Not performing these prerequisites results in the following error:
An authentication issue was encountered when invoking Function. Please 
check if the prerequisites for calling OCI services have been properly setup for 
this service instance. OCI service integration requires dynamic groups and policies 
granting access to be created in OCI Console. Please consult the documentation for 
more information.
  1. Ensure that your cloud tenancy uses identity domains. Invoking Oracle Cloud Infrastructure functions from an integration does not work in cloud tenancies that are not enabled for identity domains. If you are unsure, ask your administrator for details.
  2. Set up your environment to invoke Oracle Cloud Infrastructure functions from an integration. See Functions QuickStart on Cloud Shell. This section describes how to set up the following:
    • Set up your tenancy:
      • Create groups and users (if not already done so).
      • Create a compartment in which to create functions. You specify this compartment when configuring the OCI Function action in the integration canvas.
      • Create a virtual cloud network (VCN) and subnets. For example:


        The Virtual Cloud Networks page is shown. At the top is the compartment name. Below are the Create VCN and Actions buttons. Below is a table with columns for Name, Status, IPv4 CIDR Block, IPv6 Prefix, Default Route Table, DNS Domain Name, and Created.

      • Create a policy for groups and services. This policy enables you to create functions. For example:


        The Policies tab is selected in the left navigation pane. At the top is the label Policies. The compartment name appears below. Below are the Create Policy and Delete buttons. Below is a table with columns for Name, Description, Statements, and Created.

    • Create an application in which to create the functions to invoke. You specify this application when configuring the OCI Function action in the integration canvas. For example:


      The Applications tab is selected in the left navigation pane. At the top is the label Applications. The compartment name appears below. Below is a table with columns for Name, Status, Created, and Last updated.

    • Set up your Cloud Shell development environment.
    • Create, deploy, and invoke your function. For example:

      Note:

      You must create your own functions in your tenancy. Oracle Cloud Infrastructure doesn't deploy or create any functions for you by default. Oracle Cloud Infrastructure does provide prebuilt functions that you can deploy to your own instance.


      The Functions page is shown. At the top of the page are the Details, Functions, Configuration, Monitoring, and Tags tabs. Below this are the search field, the Create from existing image link, and Create in code editor link. Below is a table with columns for Name, Image, Image digest, Invoke endpoint, Provisioned concurrency units, and Last updated columns.

  3. Create a dynamic group.
    1. Obtain the client ID of the OAuth application for the Oracle Integration instance.
    2. In the navigation pane, select Identity & Security.
    3. Under Identity, select Domains.
    4. In the upper right corner, select Profile, then click the identity domain.
    5. In the menu bar, click Oracle cloud services.


      The Domains tab in the Identity & Security navigation pane is selected. The menu bar shows links for Details, User management, Administrators, Dynamic groups, Directory integrations, Integrated applications, and Oracle cloud services.

      The Oracle Cloud Services page for your domain appears.

    6. In the Name column, click your service instance.
    7. Click OAuth configuration.
    8. Scroll down to the General Information section and copy the client ID value to use to create your dynamic group.
  4. Scroll to the breadcrumbs at the top and click Oracle cloud services to return to the main page for the identity domain.


    A back arrow and the label Oracle cloud services are shown.

  5. In the menu bar, click Dynamic groups.


    The Domains tab is selected in the left navigation pane. The menu bar shows links for Details, User management, Administrators, and Dynamic groups.

  6. Click Create dynamic group.
  7. Enter the following details:
    1. In the Name and Description fields, enter values. These fields are required.
    2. In the Matching Rules section, enter the required rule. The resource ID you specify must match the client ID of the OAuth application of your Oracle Integration instance. Ensure that you enclose the value in single quotes. For example:
      resource.id = 'client_ID'


      The Create dynamic group page is shown. Below this is the Matching rules section, with example text and radio buttons for Match any rules defined below and Match all rules defined below. Below this is the Rule builder link. The Rule 1 section shows the resource.id parameter and value.

  8. In the left navigation pane, click Policies to assign a policy to the dynamic group to enable you to invoke Oracle Cloud Infrastructure functions from an integration.
  9. Click Create Policy.
  10. Enter the following details:
    1. In the Name and Description fields, enter values. These fields are required.
    2. In the Policy Builder section, click Show manual editor to build the required policy for the dynamic group. The following example allows the dynamic group to use the entire functions family, but you can set more granular policies, as needed. See Controlling Access to Invoke and Manage Functions and Policy Statements to Give OCI Functions Users Access to Function-Related Resources.
      Allow dynamic-group group_name to use functions-family in compartment compartment_name
      Where:
      • group_name: Is the dynamic group name you created.
      • compartment_name: Is the compartment where the functions to invoke are hosted.

      Note:

      If you are not creating the policy in the default domain, then specify your domain name in front of the group name. For example:
      Allow dynamic-group identity_domain/group_name to use functions-family in compartment compartment_name

      This enables the Oracle Integration instance associated with the dynamic group to invoke Oracle Cloud Infrastructure functions with the OCI Function action in an integration.

Invoke Oracle Cloud Infrastructure Functions

This section provides an overview of how to configure an OCI Function action in the integration canvas to invoke the Oracle Cloud Infrastructure functions available in your application.

  1. Add an OCI Function action to an integration in either of the following ways:
    • On the side of the canvas, click Actions Integration actions icon and drag the OCI Function action to the appropriate location.
    • Click Add icon at the location where you want to add the parallel action, then select OCI Function.

    Note:

    If your cloud tenancy is not using identity domains, an error message appears and the page is blank.

    The OCI Functions wizard appears.

  2. On the Basic Info page, enter the following information to identify the function to invoke, then click >. When you enter details in a field, the page refreshes to show more fields.
    Element Description
    Region Select the region where the functions are deployed.
    Compartment Select the compartment where the functions to invoke are hosted.
    Application Select the application. Oracle Cloud Infrastructure functions are organized in sets called applications. An application can contain multiple functions.
    Function Select the Oracle Cloud Infrastructure function to invoke. The functions you are entitled to invoke by your application are displayed for selection.


    The Basic Info page shows the wizard train at the top: Basic Info, Request, Response, and Summary. To the left and right of the train are < and > links, respectively. Below are the Region, Compartment, Application, and Function lists.

  3. On the Request page, select the payload type and specify the content, then click >.
    • JSON Sample: Drag and drop or select a file, or manually enter the payload.
    • XML Schema: Drag and drop or select a file.
    • XML Sample (Single or No NameSpace): Drag and drop or select a file.
    • Binary:
      • For files, simply select Binary and map the content.
      • For plain/text request/response payloads, select Binary and perform the following encoding:
        • To provide text as input, you must first encode the text as Base64, then decode that Base64 to a stream reference.
          decodeBase64ToReference(encodeBase64(Name))
        • To receive the text output, you need to encode the output stream reference to Base64, then decode that Base64 to text.
          decodeBase64(encodeReferenceToBase64(Stream Reference))
  4. On the Response page, select the response payload type and specify the content, then click >. The available response payload types are the same as the request payload types.
  5. Review your selections on the Summary page. For this example, the hello-python-json function is invoked. The request and response media is in JSON format.


    The Basic Info page shows the wizard train at the top: Basic Info, Request, Response, and Summary. To the left and right of the train are < and > links, respectively. Below are the values for the Compartment Name, Application Name, Function Name, Request Media Type, Response Media Type, and Invoke Endpoint URL.

  6. Click Done.