Power of serverless with SAP BTP, Kyma runtime. Se...
Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
SAP BTP, Kyma runtime is SAP's fully managed commercial kubernetes offering, part of SAP Business Technology Platform. It is often bundled with SAP Commerce Cloud and nowadays is becoming an extensibility runtime of choice.
Kyma brings a collection of additional modules on top of a kubernetes cluster. And serverless manager is one of them.
This is really useful when using the standard SAP libraries of the likes of xsenv, xssec and others with the BTP services provisioned with the btp service operator. and really essential when it comes to implementing portable, multi-environment services with one single code line.
Let's have a look at a snippet of a template of a function definition with the secretMounts.
The secretMounts allow to map values of the kubernetes secrets into a function's volume mount paths. The mounts paths are like the base directories in a folder structure and, combined with the secrets keys names, they become the data paths.
Thus, a function code can easily read secrets keys values from these data paths as if they were files.
Eventually, this is how this works with most of the commonly used SAP libraries. We are using the SERVICE_BINDING_ROOT env variable to define thebinding directory root folder (here called binding) to expose the mounted SAP BTP services binding secrets to SAP libraries that may be used in the function code.
This way any code relying on SAP libraries to manipulate the secrets can be used across runtime environments without modifications.
Using standard SAP libraries with mounted secrets
Let's see how to use SAP HANA Cloud with functions using @sap/hana-client and other SAP libraries.
The below code snippet demonstrates the most commonly used SAP libraries:
and here goes a couple of simple calls against a SAP HANA Cloud database instance:
const session = await queryDB(`SELECT * FROM M_SESSION_CONTEXT`);
const db = await queryDB(`SELECT SYSTEM_ID, DATABASE_NAME, HOST, VERSION, USAGE FROM M_DATABASE`);
const connections = await queryDB(`SELECT TOP 10 USER_NAME, CLIENT_IP, CLIENT_HOST, START_TIME FROM M_CONNECTIONS WHERE OWN='TRUE' ORDER BY START_TIME DESC`);
Conclusion
This concludes a short excursion into the land of kyma serverless. To help you get started please refer to our Power of serverless with SAP BTP, Kyma runtime code samples here.