Functions & Events In Oracle Cloud (OCI)

Oracle

Share Post Now :

HOW TO GET HIGH PAYING JOBS IN AWS CLOUD

Even as a beginner with NO Experience Coding Language

Explore Free course Now

Table of Contents

Loading

Sometimes, we come across scenarios where we need to track the change in the state of our OCI services and need to take immediate action for the same. For this Oracle has introduced Functions and Events in OCI

In this post, I am going to cover:

  • Overview of Functions & Events.
  • Steps to configure Functions and Events in OCI.
  • Integration of Functions with Events.
  • Use cases of Functions and Events.

Overview Of Functions

Oracle Functions is a Function-as-a-service Platform. Functions in oracle are used to perform multiple and sequential actions at a particular moment. In Oracle, we can code a Function in Java, Python, Node, Go, and Ruby. We can also integrate functions with Events which we will cover later in the blog.

Oracle Functions is based on Fn ProjectFn Project is an open-source, container-native, serverless platform that can be run anywhere (cloud or on-premises)

functions in OCI

Note: Although, defining a function is a task for Oracle developers but its deployment and invocation in OCI is a task of OCI Architect.

Steps To Configure Functions

There are three ways to configure function in OCI:

  1. Cloud Shell Option
  2. Local Machine Option
  3. OCI compute Instance Option

In this post, we will be following the Cloud Shell option.

1) We need to specify some policies

function policy

2) Navigate to Developer Services under Solutions and Platform, Click Functions.

Functions

3) Click Create Application and add application details.

function details

4) In the application created under Resources, click Getting Started and follow the steps listed

creating function

5) Here we need to specify the repository in which we want to create the image of the function.

To know more about OCIR click here.

repository creation

6)  We need to generate an Auth Token which we will use as a password to login to OCIR.

generate token

Auth Token

7) We will deploy the function in the application.

deploy a function in application

8) Now we will invoke the function. We can see that the “Hello, world” message is printed on the screen.

invoking the function

9) We can also see that the function has been deployed in the application through the console.

function

Note: To know how to deploy function using Local Machine and OCI compute instance click here.

Overview Of Events

The event is used to automate an action to a change in the state of services in OCI. The event triggers a message that specifies a change in the resources and decides immediately what action needs to be taken.

Action for an Event can be of three types:

  1. NotificationIt will generate a message based on the topic and subscription(like email).
  2. Streaming: It stores the stream of data such as application logs, operational telemetry.
  3. Functions: Event trigger a specified function (integrating events with function).

Steps To Configure Events

We are going to trigger a notification using an Event that will send an email with the details of the bucket created.

1) Navigate to the Application Integration under Solutions and Platform and click Notifications.

Notification

2) Create a Topic and Subscription for a notification.

Topic and Subscription

Note: while creating a subscription we need to confirm the subscription through the mail given in the subscription.

3) Navigate to the Application Integration under Solutions and Platform and click Events Services.

Events Service

4) Create an Event with the following details.

Event details

5) Now we will create a bucket and see that a mail has been generated with the details of the bucket created.

event mail

Integration Of Functions With Events

By Integrating Functions with Events we can track changes in our cloud environment and automatically act by running our infrastructure as code. All we need to do is to select the function which we want to trigger while configuring an Event (Topic).

For eg: We want to create a bucket whenever we create an instance.

integrating function with events

To follow the complete step click here.

Use Cases Of Functions & Events

  • Perform cleanup tasks when resources are terminated.
  • Analyze network logs when anomalies are detected in the network. Network logs can be uploaded to Oracle Cloud Infrastructure Object Storage or sent to third-party tools such as Splunk for further security analysis.
  • Process a file immediately and automatically when new files are uploaded in an Object Storage bucket.
  • Create an Object Storage when a new user is created.
  • Archive all events in a specific compartment to a stream for later analysis.
  • Trigger an action when long-lived tasks, such as a backup, are completed.

Related/Further Readings

Next Task For You

In our OCI Architect Professional [1Z0-997] Certification training, we cover Functions & Events in Implement and Operate Solutions module. In this module, we also cover Streaming Services, Service Requests and SLAs, and Oracle Registry Service.

For the list of Hands-On guide click here.

1z0-997

 

Picture of mike

mike

I started my IT career in 2000 as an Oracle DBA/Apps DBA. The first few years were tough (<$100/month), with very little growth. In 2004, I moved to the UK. After working really hard, I landed a job that paid me £2700 per month. In February 2005, I saw a job that was £450 per day, which was nearly 4 times of my then salary.