cancel
Showing results for 
Search instead for 
Did you mean: 

How to create custom Cloud foundry Tasks in SAP BTP?

piyushvns20
Explorer
153

Hello everyone,
I want to build a custom Cloud foundry tasks.

Cloud foundry Tasks : 
A task is an app or script, the code of which is included as part of a deployed app, but runs independently in its own container.

For the reference i am following some of these articles:
https://docs.cloudfoundry.org/devguide/using-tasks.html
https://tutorials.cloudfoundry.org/cf4devs/advanced-concepts/tasks/
https://help.sap.com/docs/btp/sap-business-technology-platform/tasks
https://community.sap.com/t5/technology-blogs-by-sap/cloudfoundryfun-4-how-to-use-cloud-foundry-task...

I want to create my own CF tasks which have some business logic to perform some operation.
With the help of CF tasks i can automate some of my services in apps which is developed on SAP BTP CAP (node.js).
Any individual can guide or share some resources which can help me to achieve this would be really helpful.

Thank You.
@thomas_jung 

Accepted Solutions (0)

Answers (1)

Answers (1)

Beyhan
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Thomas,

I think you already found the most important sources of information. SAP BTP CF is based on the open source CF distribution that is why the sources you found should apply. 

To try a task execution I just deployed the cf-sample-app-nodejs application to SAP BTP with the name cf-nodejs-bv-test. After the deployment I could execute a task on it with:

cf run-task cf-nodejs-bv-test --command "echo hello" --name example-task 

In the application logs the output of the task could be found like:

cf logs cf-nodejs-bv-test --recent
...
   2024-11-11T12:16:39.94+0200 [APP/TASK/example-task/0] OUT hello
...

Additional sources to check are the CF stack docs especially the docs about the cflinuxfs4 receipt which describes what is included in the stack (the root file system of the container) which is currently offered on SAP BTP CF and that is why the echo command from above works . I also found this Stack Overflow discussion interesting which describes e.g. how to execute a Java command with the Java buildpack. I hope this helps further.