You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Serverless SaaS Extensions using Oracle Functions, API Gateway and VBCS | [repo](https://github.com/oracle/cloud-asset-fusion-serverless-vbcs-sample) | [blog](https://www.ateam-oracle.com/the-cloud-native-approach-to-extending-your-saas-applications)
75
75
| Function that demonstrates connectivity between Oracle SaaS applications with OIC |[sample](./samples/oci-oic-hcm-object-upload)|
76
+
| TypeScript function migrated from AWS Lambda to OCI Functions |[sample](./samples/order-processing-typescript)|
# Function receives an order JSON and creates an object in a bucket
2
+
The JSON document type the function processes is defined in [func.ts](func.ts#L7-L11) and an example can be found in the guide below. The object is written to a target bucket configured through environment variables.
3
+
4
+
As an alternative to the OCI Object Storage API this function also shows how to use the OCI Object Storage Amazon S3 Compatibility APIs. In production-usage you'd not use both at the same time, but we make it easy for testing purposes to change the used API through environment variables so you can experience both options.
5
+
6
+
7
+
## Prerequisites
8
+
Before you deploy this sample function, make sure you have run step A, B and C of the [Oracle Functions Quick Start Guide for Cloud Shell](https://www.oracle.com/webfolder/technetwork/tutorials/infographics/oci_functions_cloudshell_quickview/functions_quickview_top/functions_quickview/index.html)
9
+
* A - Set up your tenancy
10
+
* B - Create application
11
+
* C - Set up your Cloud Shell dev environment
12
+
13
+
14
+
## List Applications
15
+
Assuming you have successfully completed the prerequisites, you should see your application in the list of applications.
16
+
```
17
+
fn ls apps
18
+
```
19
+
20
+
21
+
## Create or Update your Dynamic Group
22
+
In order to use other OCI Services, your function must be part of a dynamic group. For information on how to create a dynamic group, refer to the [documentation](https://docs.cloud.oracle.com/iaas/Content/Identity/Tasks/managingdynamicgroups.htm#To).
23
+
24
+
When specifying the *Matching Rules*, we suggest matching all functions in a compartment with:
25
+
```
26
+
ALL {resource.type = 'fnfunc', resource.compartment.id = 'ocid1.compartment.oc1..aaaaaxxxxx'}
27
+
```
28
+
Please check the [Accessing Other Oracle Cloud Infrastructure Resources from Running Functions](https://docs.cloud.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsaccessingociresources.htm) for other *Matching Rules* options.
29
+
30
+
31
+
## Create or Update IAM Policies
32
+
Create a new policy that allows the dynamic group to write to the target bucket.
33
+
34
+
Your policy should look something like this:
35
+
```
36
+
Allow dynamic-group <dynamic-group-name> to use buckets in compartment <compartment-name>
37
+
Allow dynamic-group <dynamic-group-name> to manage objects in compartment <compartment-name>
38
+
```
39
+
For more information on how to create policies, check the [documentation](https://docs.cloud.oracle.com/iaas/Content/Identity/Concepts/policysyntax.htm).
40
+
41
+
42
+
## Review and customize your function
43
+
Review the following files in the current folder:
44
+
* the code of the function, [func.ts](./func.ts)
45
+
* its dependencies, [package.json](./package.json)
46
+
* its dockerfile, [Dockerfile](./Dockerfile)
47
+
* the function metadata, [func.yaml](./func.yaml)
48
+
49
+
50
+
## Set the function environment values
51
+
The function requires the following environment values to be set:
52
+
- OS_NAMESPACE, the value should be your tenancy's object storage namespace name
53
+
54
+
Configure the value before deployment in the `func.yaml` file.
55
+
56
+
57
+
## Deploy the function
58
+
In Cloud Shell, run the fn deploy command to build the function and its dependencies as a Docker image,
59
+
push the image to OCIR, and deploy the function to Oracle Functions in your application.
* Context is the function invocation context - it enables functions to read and write metadata from the request including event headers, config and the underlying payload
0 commit comments