Serverless computing has revolutionized the way modern cloud applications are built and deployed. In the SAP ecosystem, SAP Cloud Functions, part of the SAP Business Technology Platform (SAP BTP), enable developers to create lightweight, event-driven serverless functions that respond to triggers and events in real time — without managing the underlying infrastructure.
This article explores how to build and deploy serverless functions using SAP Cloud Functions within the SAP Business Application Studio (BAS), a powerful cloud-based development environment tailored for SAP development.
SAP Cloud Functions provide Function-as-a-Service (FaaS) capabilities on SAP BTP. Built on top of Kyma, an open-source Kubernetes runtime, SAP Cloud Functions allow you to:
Before you start building serverless functions in SAP BAS, ensure the following:
KymaDeveloper, FunctionDeveloper, NamespaceAdmin.Launch BAS from your SAP BTP Cockpit and open your development Dev Space. This acts as your IDE in the cloud.
Open the terminal in BAS.
Run the following command to create a Kyma project:
mkdir my-serverless-fn && cd my-serverless-fn
kubectl config use-context kyma-cluster
Note: Ensure that you are authenticated and connected to your Kyma runtime via
kubectl.
You can use the Kyma CLI or directly create function YAML files.
Using Kyma CLI:
kyma init function --name hello-world
cd hello-world
This scaffolds a function project with:
handler.js: your function logicconfig.yaml: deployment configurationSample handler.js:
module.exports = {
main: async function (event, context) {
return {
statusCode: 200,
body: `Hello from SAP Cloud Function! Received: ${JSON.stringify(event.data)}`
};
}
};
Use the Kyma CLI to deploy:
kyma deploy
Once deployed, Kyma creates a public HTTP endpoint for your function.
Retrieve the service URL via:
kubectl get function
Test using curl:
curl -X POST <your-function-url> -H "Content-Type: application/json" -d '{"message":"SAP"}'
Expected Output:
{
"statusCode": 200,
"body": "Hello from SAP Cloud Function! Received: {\"message\":\"SAP\"}"
}
Serverless functions are best suited for:
By leveraging SAP Cloud Functions in SAP Business Application Studio, developers can build agile, scalable, and event-driven applications without worrying about server management. With just a few lines of code, you can extend SAP solutions and respond to business events in real-time — all within the secure SAP BTP ecosystem.
Whether you're building a microservice, responding to SAP Event Mesh triggers, or integrating with SAP S/4HANA, serverless functions offer a powerful and modern approach to cloud development.