As enterprises move toward cloud-native architectures, serverless computing has emerged as a powerful paradigm to build and deploy lightweight, event-driven applications. SAP Business Technology Platform (SAP BTP) embraces this model through the SAP BTP, Kyma runtime and the Function-as-a-Service (FaaS) approach. Developers can write and deploy serverless functions directly from the SAP Business Application Studio (BAS), SAP’s cloud-based development environment.
In this article, we will explore the step-by-step process of developing and deploying serverless functions to SAP BTP using SAP Business Application Studio.
Serverless functions on SAP BTP are lightweight code snippets that respond to events (HTTP requests, database changes, etc.) without the need to manage underlying infrastructure. SAP enables serverless development primarily via the Kyma runtime, an open-source project built on Kubernetes and Istio.
These functions are ideal for:
Before getting started, ensure you have:
kubectl, k3d, etc.) if you prefer CLI-based interaction.You can use the built-in terminal to scaffold a Kyma function using CLI or manually set up a project structure:
mkdir hello-function
cd hello-function
Create a simple function handler (e.g., handler.js for Node.js):
module.exports = {
main: async function (event, context) {
return {
statusCode: 200,
body: "Hello from SAP BTP Function!"
};
}
};
Create a package.json if needed and add dependencies.
function.yaml DescriptorThis YAML file defines the function for deployment in Kyma:
apiVersion: serverless.kyma-project.io/v1alpha1
kind: Function
metadata:
name: hello-function
spec:
runtime: nodejs18
source:
inline:
handler: handler.main
dependencies: |
{
"name": "hello-function",
"version": "1.0.0"
}
source: |
module.exports = {
main: async function (event, context) {
return {
statusCode: 200,
body: "Hello from SAP BTP Function!"
};
}
};
kubectl from terminal).kubectl apply -f function.yaml
Check the deployment status:
kubectl get functions
Once the function is deployed, it will be exposed via an HTTP endpoint.
apiVersion: gateway.kyma-project.io/v1alpha1
kind: APIRule
metadata:
name: hello-function
spec:
gateway: kyma-gateway.kyma-system.svc.cluster.local
host: hello-function
service:
name: hello-function
port: 80
rules:
- accessStrategies:
- handler: allow
methods: ["GET"]
path: /.*
kubectl apply -f api-rule.yaml
Deploying serverless functions on SAP BTP using the SAP Business Application Studio offers a modern, scalable way to extend and integrate SAP solutions. By abstracting infrastructure and focusing purely on business logic, developers can innovate faster, reduce operational overhead, and build highly responsive applications.
Start small—perhaps with a simple webhook or automation task—and scale your serverless architecture as needed. The power of Kyma and the elegance of SAP BAS make it easier than ever.