Oracle Developers
Published in

Oracle Developers

The FaaScination with Oracle Functions

Oracle offers a Functions as a Service (FaaS) in the Oracle cloud. It is named Oracle Functions.

Oracle Functions is based on an open source project named Fn Project.

So Oracle Functions has the Fn Project as its core.

Oracle Functions and the Cloud Shell

In setting up Oracle Functions, it is possible to setup from your workstation. However, there is a significant amount of installation required.

For this reason, for evaluation purposes, the easiest way to get started with the Oracle Functions service is to setup via the console and the Cloud Shell.

These instructions detais 4 steps in setting up Oracle Functions. The full instructions to set up Oracle Functions are here:

What follows below is just a summary, with a tip or two along the way, to give you an idea of how easy it is to setup Oracle Functions.

1. Set up your tenancy for Oracle Functions

In this stage you will setup the groups, users, and compartment. You’ll also create a VCN and a subnet, then a policy.

Everything is explained in the full instructions.

After setting up the tenancy for Oracle Functions, the next step is to create an application.

2. Create an application via the console

In this step you get to create an application.

From the menu Developer Services, choose Functions, and then you’ll be given an opportunity to create a HelloWorld app. As an example, we’ll choose a name of our app to be ‘myFirstFunctionsApplication’.

Later, the function will be placed in this application.

3. Finish the setup in the Cloud Shell environment

Now that the application has been created, the console will now guide us for the instructions to come next.

The instructions are actually customised, for our tenancy, and listed in the ‘Getting Started’ page of the application. Most of the instructions are for execution in the Cloud Shell.

So the first step is to create a shell session in the browser by clicking on ‘Launch Cloud Shell’.

After several seconds, the Cloud Shell command prompt will appear.

Now from here on, you simply copy the commands shown on the page, and and paste them into the Cloud Shell.

One of the tasks is to provide a prefix name for an Oracle Cloud Infrastructure Docker registry.

Important — the prefix name you define must have all characters as lowercase.

You’ll also be required to generate a token, which you need to record for later reference. This token will be used to login to a Docker registry to download the java image (ie Hello-java).

4. Create, deploy, and invoke your function

Now there are just 4 tasks remaining:

  • Generate a ‘hello-world’ boilerplate function.
  • Switch into the generated directory.
  • Deploy your function.
  • Invoke your function

The hello-java function (inside the myFirstFunctionsApplication) will be invoked as follows:

fn invoke myFirstFunctionsApplication hello-java

If all is well, then you’ll receive the output of ‘Hello, world!’.

Then you can pass in customised text to the application:

echo -n 'John' | fn invoke myFirstFunctionsApplication hello-java

Now you’ll receive the output of ‘Hello, John!’.

From here, you can inspect the code that is run by the function by launching the in-built code editor from the console. (See the icon highlighted in yellow below.)

Using the code editor, you can inspect the function configuration file.

Also via the code editor, you can inspect the source code of the function.

That’s the full setup.

For evaluation purposes, everything is available through the console, the Cloud shell, and the code editor.

If you’re curious about the goings-on of Oracle Developers in their natural habitat, come join us on our public Slack channel! We don’t mind being your fish bowl 🐠

Paul Guerin has presented at some of the world’s leading Oracle conferences, including Oracle Open World 2013. Since 2015, his work has been featured in the IOUG Best Practices Tip Booklet, and in publications from AUSOUG, Oracle Technology Network, Quest, and Oracle Developers (Medium). In 2019, he was awarded as a most valued contributor for the My Oracle Support Community. He continues to be a participant of the Oracle ACE program.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store