I've blogged about our awesome Oracle Notification Service (ONS) and Oracle Functions in the past, and the teams have been hard at work with some new improvements to make your life a little easier. Previously you could set up subscriptions for a Custom URL, PagerDuty, or Email, and could trigger an Oracle Function from services like Cloud Events, API Gateway and Oracle Integration Cloud. But today you can combine these two awesome services and add your serverless function as a subscription to your notification topic. This opens up many possible integrations and adds another reason why you should take advantage of all the different products and services available on Oracle Cloud.
Let's take a deeper look at this integration. Here are a few diagrams from the documentation that I've updated to show the new feature. The first diagram shows how ONS Notifications can be triggered as a result of a monitoring metric rule moving into an alarm state.
Previously you could receive a notification about this which probably meant that your on-call engineer rolled out of bed at 4AM and logged on to see that one of your sites made it to the front page of Hacker News and were getting hammered with traffic. While that's great news - congrats! - it still meant that she had to wake up and take some action instead of getting some much needed rest. Wouldn't it be nice to be able to automatically take some action instead? That's what a function subscription could do for you. Your function could determine that additional servers were necessary and could utilize the OCI SDK to perform some automated and scripted action.
The next diagram illustrates how your custom services and applications can use the notification service directly to perform certain actions. Maybe your gigantic e-commerce application sends an email confirmation of a customer's order and you use notifications to send that confirmation to the customer, but you've also recently created the world's first fully autonomous factory and you need to initiate the order fulfillment robots launch sequence via a serverless function. In that case, we've got you covered!
Disclaimer: Perhaps fully autonomous warehouses with bots launched by serverless functions is a bit far fetched, but the use case has certainly been illustrated i think.
Let me show you how to set up a function subscription to a notification topic.
If you're new to Oracle Functions, check out this video to learn how to set up your tenancy (or use the quick start guide):
Once your tenancy has been configured, create a "hello world" function and deploy it. Here's another video that shows you how to create, deploy and invoke your first Oracle Function:
Now that you have created your first function, let's move on.
If you're new to Oracle Functions, be sure to check out the Quick Start Guide to get your tenancy ready for serverless deployments!
The first step is to create a new notification topic, or choose an existing topic. Go into the topic details page and click 'Create Subscription'.
Under 'Protocol', select 'Function'.
When you choose the 'Function' protocol, additional inputs appear. Choose the function compartment, application and function ID that you would like invoked.
After your subscription is created, test it out by clicking 'Publish Message'.
Enter some details and click 'Publish'.
Now head over to your function's detail page and view the metrics to confirm the function was invoked.
If you've enabled logging to Object Storage on your function:
Then you'll be able to see any logged output in the given bucket:
Which you can download and view:
And that's what it takes to have your ONS notifications trigger a serverless function in the Oracle Cloud. Make sure to check the product announcement for more example scenarios, documentation links for the API and CLI.
Welcome back to this series where we looking at using Terraform to manage our cloud infrastructure. In the first post of this series, we looked at the ...
Back in September, we announced the Micronaut Oracle Cloud Infrastructure module to help developers easily integrate with the OCI SDK as well as use Micronaut...
In our last post, we took a high-level look at the basics of Terraform for developers. Hopefully you’ve read that (or are already familiar with Terraform...