Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 


Following the recent announcements at SAP TechEd, I was delighted to know that the support for Functions (that enables serverless computing) is available as Beta in SAP cloud platform. Although FaaS (Functions as a service) has been in the existence already - AWS Lambda, Google Cloud functions etc., it's adoption into the SAP Cloud Platform is seen as a great welcome gesture!  Not only does it add on to the arsenal of features that's already present, it goes hand-in-hand with the microservices architecture, cloudfoundry adoption and the latest CAP model.

I am planning to cover this feature in Parts. The first part being a general intro and a quick 'hello world'. More interesting stuff with FaaS is coming ahead. Make sure you stay tuned to this series ! 🙂

Without spending much time describing the stuff, let's get into some action. There are 3 key things that you should note while trying this out.

  1. Create a SubAccount with "Enable Beta Features" checked.Functions is still in beta.SAP CP Trial Account is suffice https://account.hanatrial.ondemand.com.

  2. In the Global Account, under the "Entitlement" section, make sure you add the quota for the corresponding subaccount.

  3. Stick to using node.js core libraries in functions. There is a memory limitation for each function (~500MB), which might be removed in the future.


 



By default, we have one unassigned quota.



 



 

Once the initial subaccount setup, space creation and quota allocation is done, you can navigate to the Service Marketplace. Under the Service Marketplace, you will see Functions.

 



You can create a instance directly from here using Create New Instance button. For now, we are not specifying any external parameters and we skip the optional fields. Provide an instance name.

In the upcoming posts, I will explain how FaaS can be created using SAP WebIDE Full Stack as well.



The service instance would be created almost instantly ! You can go to the Functions Designer dashboard by clicking on the icon under the Actions column. The Function designer lets you create

  1. Functions - The code to be executed when it is invoked by the corresponding trigger

  2. Triggers - As the name implies, a trigger is something which invokes the function and SAP CP currently offers 3 kinds of triggers.

    1. HTTP - An HTTP url through which the function can be invoked.

    2. Timer - Timer lets you schedule function using a cron pattern. For example: This pattern "0 * * * *" executes the function every hour.

    3. Event - Executes the function on an event received or published from the enterprise messaging service



  3. Secrets - It is needed to create event based triggers. Basically it contains the credentials and service instance information of the enterprise messaging service.


 



You can create a new function using the "Create function" command. By default, it would have a Hello World code. However, we need to attach a trigger to execute it.



Under the Triggers tab, you can create a simple HTTP trigger and select the function name to execute.



Upon successful creation, you'd have a HTTPS url which you can open in the browser.



There it is ! A simple hello world app that we never coded. It was all a bit of setup and configurations done in minutes to have this running.



However, let's not get carried away by the simplicity. In order to know how it works, I've added a specific page from documentation which will be handy when you start developing further. It is detailed further in the Functions programming model over here

Let's play around with the event parameters a bit. The guide states the following:



Let's print the request headers.
module.exports = {
handler: function(event, context) {
console.log(event.extensions.request.url);
return JSON.stringify(event.extensions.request.headers);
}
}



Here we go ! Make sure you "Save and Deploy" the code every time you make the changes.



Play around with the feature and let me know your interesting findings ! I will be covering the use-cases for FaaS in-depth in the next post. Stay tuned ! 🙂

References:

  1. Getting Started with SAP CP Functions (Beta)

  2. Official Documentation


Let me know if you have any queries and please share your interesting findings as well! You can contact me on LinkedIn or Twitter or through any of the profiles mentioned in my site regarding the same! Until then stay tuned!
14 Comments
Labels in this area