Introduction
When you run custom applications in the SAP BTP Cloud Foundry Runtime, it may be smart, purely from a resource-optimization standpoint, to shut them down at night and start them again in the morning. In this post, you’ll learn how to implement a ‘stop at night, restart in the morning’ routine by using Automation Pilot, SAP BTP’s low-/no-code automation service for operations.
This guide targets readers who already know Cloud Foundry and SAP BTP, but who are using Automation Pilot for the first time.
1. Create a Catalog and an Input
You start by creating a Catalog.
Catalog: Groups of Commands and Inputs so you can manage them per project.
For this tutorial, create a Catalog called ‘Sample’.
Next, create an Input for operating your Cloud Foundry app.
Input: A reusable collection of key-value pairs that Commands can access at runtime.
Create an Input named ‘CfAppOperation’.
Add the following information to the Input so you can authenticate and locate the target app:
user – BTP technical userpassword – Password (set Sensitive = ON is recommended)region – Cloud Foundry region (ex. cf-eu10)subAccount – Sub-account nameresourceGroup – Space nameresourceName – Application name (ex. cap-js-bookshop-srv)
Registering this information once as an Input saves you from typing it every time you run a stop or restart Command.
2. Create the Stop Command
Now you create the Command that actually stops the app.
Command: A runnable unit in Automation Pilot. It consumes Input Keys when it starts and returns Output Keys when it finishes. Commands themselves can be built from other Commands.
Create a new Command named ‘StopCfApp’ in the ‘Sample’ Catalog.
Add an Executor to the Command.
Executor: A wrapper that holds one or more Commands. Supply values for the underlying Command’s Input Keys – either hard-coded or via Dynamic Expressions.
Set the Executor’s alias to ‘StopApplication’ and choose the predefined Command ‘applm-sapcp’の’StopCfApp’.
Click the link to ‘applm-sapcp:StopCfApp:1’ to inspect its Input and Output Keys.
You can see the definitions of Input and Output Keys here. Use these details to configure the Input Keys and Output Keys in the next steps.
On the previous screen, create six Input Keys. Remember to mark password as Sensitive.
In the end, you should have the following six Input Keys.
Map each Input Key to the corresponding parameters of ‘StopApplication’ with Dynamic Expressions.
Next, define the Output Keys.
The Output Keys has to be look like below:
Map each Output Key to the outputs of ‘StopApplication’ via Dynamic Expressions.
It should look like this:
3. Test the Command
Your stop Command is now complete. Click the Trigger button in the upper-right corner of the screen to run it.
On the execution-result screen, choose Output > Show to confirm that the target app (e.g., cap-js-bookshop-srv) was stopped. If errors appear, recheck your Input settings, permissions, key mappings and so on.
4. Set Up a Schedule
Schedule the ‘StopCfApp’ Command so it runs automatically.
Select ‘StopCfApp’ as the target Command.
For example, schedule it to run every day at 22:00 (10 p.m.) Japanese time.
‘StopCfApp’ is now on a schedule.
5. Create the Restart Command
Repeat the same steps to create a restart Command, but choose the predefined Command ‘applm-sapcp:RestartCfApp‘. Link it to the same Input and schedule it, say at 07:00, so the app starts automatically each morning.
Conclusion
You have now used Automation Pilot to stop a Cloud Foundry app overnight and bring it back online every morning. Key takeaways:
Store authentication and app details in an InputLeverage predefined Commands (StopCfApp / RestartCfApp)Map Input and Output Keys correctlyUse schedules for recurring execution
While this tutorial walked through the GUI step-by-step for reproducibility, you can speed things up with Automation Pilot’s generative-AI features and extend the flow—for example, by sending email notifications when the app stops or restarts, or by applying the same logic to multiple applications.
Give it a try and take a step toward more efficient daily operations!
IntroductionWhen you run custom applications in the SAP BTP Cloud Foundry Runtime, it may be smart, purely from a resource-optimization standpoint, to shut them down at night and start them again in the morning. In this post, you’ll learn how to implement a ‘stop at night, restart in the morning’ routine by using Automation Pilot, SAP BTP’s low-/no-code automation service for operations.This guide targets readers who already know Cloud Foundry and SAP BTP, but who are using Automation Pilot for the first time.1. Create a Catalog and an InputYou start by creating a Catalog.Catalog: Groups of Commands and Inputs so you can manage them per project.For this tutorial, create a Catalog called ‘Sample’.Next, create an Input for operating your Cloud Foundry app.Input: A reusable collection of key-value pairs that Commands can access at runtime.Create an Input named ‘CfAppOperation’.Add the following information to the Input so you can authenticate and locate the target app:user – BTP technical userpassword – Password (set Sensitive = ON is recommended)region – Cloud Foundry region (ex. cf-eu10)subAccount – Sub-account nameresourceGroup – Space nameresourceName – Application name (ex. cap-js-bookshop-srv)Registering this information once as an Input saves you from typing it every time you run a stop or restart Command.2. Create the Stop CommandNow you create the Command that actually stops the app.Command: A runnable unit in Automation Pilot. It consumes Input Keys when it starts and returns Output Keys when it finishes. Commands themselves can be built from other Commands.Create a new Command named ‘StopCfApp’ in the ‘Sample’ Catalog.Add an Executor to the Command.Executor: A wrapper that holds one or more Commands. Supply values for the underlying Command’s Input Keys – either hard-coded or via Dynamic Expressions.Set the Executor’s alias to ‘StopApplication’ and choose the predefined Command ‘applm-sapcp’の’StopCfApp’. Click the link to ‘applm-sapcp:StopCfApp:1’ to inspect its Input and Output Keys.You can see the definitions of Input and Output Keys here. Use these details to configure the Input Keys and Output Keys in the next steps.On the previous screen, create six Input Keys. Remember to mark password as Sensitive.In the end, you should have the following six Input Keys.Map each Input Key to the corresponding parameters of ‘StopApplication’ with Dynamic Expressions.Next, define the Output Keys.The Output Keys has to be look like below:Map each Output Key to the outputs of ‘StopApplication’ via Dynamic Expressions.It should look like this:3. Test the CommandYour stop Command is now complete. Click the Trigger button in the upper-right corner of the screen to run it.On the execution-result screen, choose Output > Show to confirm that the target app (e.g., cap-js-bookshop-srv) was stopped. If errors appear, recheck your Input settings, permissions, key mappings and so on.4. Set Up a ScheduleSchedule the ‘StopCfApp’ Command so it runs automatically.Select ‘StopCfApp’ as the target Command.For example, schedule it to run every day at 22:00 (10 p.m.) Japanese time.’StopCfApp’ is now on a schedule.5. Create the Restart CommandRepeat the same steps to create a restart Command, but choose the predefined Command ‘applm-sapcp:RestartCfApp’. Link it to the same Input and schedule it, say at 07:00, so the app starts automatically each morning.ConclusionYou have now used Automation Pilot to stop a Cloud Foundry app overnight and bring it back online every morning. Key takeaways:Store authentication and app details in an InputLeverage predefined Commands (StopCfApp / RestartCfApp)Map Input and Output Keys correctlyUse schedules for recurring executionWhile this tutorial walked through the GUI step-by-step for reproducibility, you can speed things up with Automation Pilot’s generative-AI features and extend the flow—for example, by sending email notifications when the app stops or restarts, or by applying the same logic to multiple applications.Give it a try and take a step toward more efficient daily operations! Read More Technology Blog Posts by SAP articles
#SAP
#SAPTechnologyblog