Technology - SAP

CF CLI Commands for SAP BTP — Cheat Sheet with Examples

Your deploy has just failed in the VS Code terminal. The BTP cockpit shows the app as crashed and nothing else. So you open a browser and start searching for the CF CLI commands that will tell you why.

Most SAP developers know three commands by heart: cf login, cf push and cf deploy. Everything else gets looked up mid-crisis. That is backwards — the commands that save you hours are the ones that explain what is going on, not the ones that deploy.

This is the cheat sheet I would have wanted on my first BTP project. Every command a developer or consultant needs in real project work, grouped by what you are trying to do, with an example for each — and a clear warning on every command that deletes something you cannot get back.

🔗 Related Reading

This post builds on two earlier articles — start there if Cloud Foundry on BTP is new to you. SAP BTP Runtimes — Cloud Foundry, ABAP and Kyma Compared Getting Started with SAP BTP — A Hands-On Guide

Before You Start — CF CLI vs btp CLI and Where You Type

Get one thing straight first: CF commands do not belong to VS Code. They come from one tool, cf, and they behave the same in the VS Code terminal, SAP Business Application Studio (BAS), PowerShell or a Mac terminal.

The difference is setup. BAS ships with the CF CLI and the MultiApps plugin already installed. On your own machine with VS Code, you install both yourself. Check what you have:

cf version     # CLI version — you want 8.x
cf plugins     # installed plugins — look for 'multiapps'

Everything in this post targets CF CLI v8, the current major version as of 2026. Version 7 is no longer supported, so if cf version shows 7 or lower, upgrade before you do anything else.

Which CLI manages what

The most common beginner mix-up on BTP is cf versus btp. They are separate tools that manage different layers of the same account.

CLIWhat it managesExample
btp CLIGlobal account, directories, subaccounts, entitlementsbtp login
cf CLIOrgs, spaces, apps, services and routes inside the Cloud Foundry environmentcf push, cf deploy, cf logs
kubectlThe Kyma runtime (Kubernetes)kubectl get pods

Inside Cloud Foundry, everything sits in a simple hierarchy. Your org belongs to your subaccount, and spaces inside it separate environments like dev, test and prod. Your apps and service instances live in a space.

📌 Key Takeaway

Every cf command runs against your current target — one org, one space. Know your target and you know exactly what you are about to change.

Diagram of the SAP BTP account hierarchy showing which layers the btp CLI manages (global account and subaccount) and which the cf CLI manages (org, spaces, apps and services)

Logging In and Targeting the Right Space

Logging in needs one value most people have to look up: the API endpoint for your region. It follows a fixed pattern, and the overview page of your subaccount in the BTP cockpit shows the exact URL.

# Pattern: https://api.cf.<region>.hana.ondemand.com
cf login -a https://api.cf.eu10.hana.ondemand.com

# Corporate identity provider? Use a one-time passcode instead
cf login -a https://api.cf.eu10.hana.ondemand.com --sso

With --sso, the CLI gives you a link. You open it in the browser, copy the one-time passcode, and paste it back into the terminal.

CommandWhat it doesExample
cf loginInteractive login, then prompts for org and spacecf login -a <api-url>
cf login --ssoLogin with a one-time passcode from the browsercf login --sso
cf login --originLogin through a specific identity providercf login --origin <idp-origin-key>
cf authNon-interactive login for scripts and CI/CD pipelinescf auth ci-user@company.com (password from CF_PASSWORD)
cf targetShow the current org and space, or switchcf target -o my-org -s dev
cf orgs / cf spacesList the orgs and spaces you can accesscf spaces
cf logoutEnd the sessioncf logout

⚠️ Warning

Never put your password on the command line with -p. The CLI itself warns that it may be visible to others and recorded in your shell history. In pipelines, store it as a secret in the CF_PASSWORD environment variable.

The second habit matters even more than the first.

💡 Practical Tip

Before any deploy, run cf target with no arguments. It prints the org and space you are about to change. Deploying a test build into production because you forgot to switch spaces is the oldest mistake on this platform — and the cheapest one to prevent.

Deploying Apps — cf push vs cf deploy (MTA)

This is where most of the confusion lives. Cloud Foundry gives you two ways to deploy, and they are not interchangeable.

cf pushcf deploy
DeploysOne appA multi-target application (MTA) — apps and services together
Descriptormanifest.ymlmta.yaml, built into an .mtar archive
Built into the CLI?YesNo — needs the MultiApps plugin
Creates services?No — you create and bind them yourselfYes — from the descriptor’s resources
Typical BTP useQuick single-app testsCAP apps, Fiori apps, anything heading to production

My position: on SAP BTP, use cf deploy for anything that will reach production. A CAP project is never just one app — it is a service, a database deployer, an app router and several service instances. An MTA keeps them together as one versioned unit.

cf push — single apps

cf push my-app                            # uses manifest.yml in the current folder
cf push my-app -f ./manifest-dev.yml      # use a specific manifest
cf push my-app -m 512M -i 2               # override memory and instance count
cf push my-app --no-start                 # upload without starting
cf push my-app --strategy rolling         # update without downtime
cf push my-app --vars-file vars-dev.yml   # fill ((variables)) in the manifest

🔗 Related Reading

Both manifest.yml and mta.yaml are YAML, and indentation errors in them are the most common deploy failure I see.
YAML — How It Works and When to Use It Over JSON covers the rules in ten minutes.

cf deploy — multi-target applications

First, install the MultiApps plugin. Skip this step in BAS, where it is already installed.

cf install-plugin multiapps
cf plugins          # confirm 'multiapps' is listed

Then build and deploy. mbt build is the Cloud MTA Build Tool, not a CF command — but you run it right before every deploy, so it belongs here.

mbt build                                           # creates mta_archives/<id>_<version>.mtar
cf deploy mta_archives/my-app_1.0.0.mtar
cf deploy my-app_1.0.0.mtar -e prod.mtaext          # apply an extension descriptor
cf deploy my-app_1.0.0.mtar --strategy blue-green   # zero-downtime MTA deploy

Extension descriptors (.mtaext) let you deploy the same .mtar to dev, test and prod with different settings. Build once, deploy many — that habit is what makes transports through CI/CD predictable.

Watching and controlling MTA operations

CommandWhat it does
cf mtasList the MTAs deployed in the current space
cf mta <mta-id>Show the apps, services and status of one MTA
cf mta-opsList active MTA operations
cf dmol -i <operation-id>Download the logs of an operation (short for download-mta-op-logs)
cf deploy -i <operation-id> -a abortAbort a running or stuck operation
cf deploy -i <operation-id> -a retryRetry a failed operation
cf deploy -i <operation-id> -a resumeContinue a blue-green deploy after the testing phase

A blue-green deploy pauses in a testing phase and prints the exact resume and abort commands, operation ID included. Copy them somewhere safe — or add --skip-testing-phase if you do not need the pause.

⚠️ Warning

cf deploy -f does more than skip a prompt. It forces the deployment without asking about aborting any conflicting process — and that process can be a colleague’s deployment running in the same space. Use it in pipelines you control, never casually.

Deployment flow diagram showing a VS Code project built with mbt build into an .mtar archive and deployed with cf deploy to apps and services in an SAP BTP space, compared with cf push for a single app

Inspecting What’s Running

These commands are read-only. Run them as often as you like — they change nothing.

CommandWhat it shows
cf appsEvery app in the space with its state, instances, memory and routes
cf app <app>One app in detail — each instance’s state, CPU, memory and disk
cf env <app>All environment variables, including service credentials in VCAP_SERVICES
cf events <app>Recent events — starts, stops, crashes, scaling
cf routesEvery route in the space and the app it points to
cf servicesService instances in the space and what they are bound to
cf domainsDomains available to your org

💡 Practical Tip

cf env prints live credentials — client secrets, database passwords, everything. Never paste its full output into a ticket, chat or email. Copy only the part you need.

Org, space and quota checks

When a deploy fails on memory, the question is always the same: have we hit the quota? These commands answer it in seconds.

cf org my-org                 # spaces, domains and quota of the org
cf org-quotas                 # list org quota plans
cf org-quota <quota-name>     # limits in one org quota (alias: cf quota)
cf space dev                  # apps, services and quota of the space
cf space-quota <quota-name>   # limits in a space quota
cf org-users my-org           # who holds which org role
cf space-users my-org dev     # who holds which space role

📝 Note

cf quota still works in v8 — it is an alias for cf org-quota. If you learned the CLI on an older version, both names do the same thing.

Troubleshooting — Logs, SSH and Crashed Apps

When an app breaks, run these in order. In my experience, most problems are solved by the second command.

StepCommandWhat it tells you
1cf app <app>Is it running, crashed or starting? How many instances are healthy?
2cf logs <app> --recentThe last log lines before it failed — usually the actual error
3cf events <app>Why it stopped — crash, out of memory, failed health check
4cf env <app>Whether the bindings and variables you expect are really there
5cf ssh <app>What is happening inside the running container

cf logs --recent dumps what has already happened. Without --recent, cf logs streams live — open it in a second VS Code terminal, then reproduce the problem in the first.

cf logs my-app --recent
cf logs my-app            # live stream — Ctrl+C to stop

Getting inside the container with cf ssh

SSH has to be allowed for both the space and the app, and the app needs a restart after you enable it. Once inside, you are in a plain Linux shell — the Linux Command Line post covers what to do there.

cf space-ssh-allowed dev        # is SSH allowed in the space?
cf ssh-enabled my-app           # is SSH enabled for the app?
cf enable-ssh my-app
cf restart my-app               # required before SSH works
cf ssh my-app                   # connect to instance 0
cf ssh my-app -i 1              # connect to a specific instance
cf ssh my-app -c "ls -la"       # run one command and exit

If only one instance is misbehaving, do not restart the whole app. Restart just that one with cf restart-app-instance my-app 1.

Common symptoms and where to look

SymptomLikely causeStart with
Deploy or scale fails on memoryOrg or space quota reachedcf org, cf org-quota
App crashes right after startingStartup error or missing bindingcf logs --recent, cf env
App keeps restartingOut of memory or failing health checkcf events, cf app
401 or 403 from a bound serviceWrong or missing credentialscf env, cf service-key
MTA deploy blocked by another operationAn earlier operation is still activecf mta-ops, then -a abort
”Not authorized” on a commandMissing space rolecf space-users

Troubleshooting flowchart that starts with cf app and branches to cf logs, cf events, cf env, cf ssh, quota checks and MTA operation logs depending on the symptom

Services, Bindings and Service Keys

On BTP, nearly every app depends on services — XSUAA for security, Destination for connectivity, HANA Cloud for data. Here is the full lifecycle in one block.

cf marketplace                       # everything you can create
cf marketplace -e xsuaa              # plans for one offering
cf create-service xsuaa application my-xsuaa -c xs-security.json
cf services                          # what exists in the space
cf service my-xsuaa                  # details and last operation status
cf bind-service my-app my-xsuaa
cf restage my-app                    # app picks up the new credentials

Service keys are credentials for something outside Cloud Foundry — Postman, a local test run, an external system.

cf create-service-key my-xsuaa my-key
cf service-keys my-xsuaa             # list keys
cf service-key my-xsuaa my-key       # print the credentials

For a system that is not in the marketplace — an on-premise API, a third-party SaaS — a user-provided service wraps its credentials so apps can bind to it like any other service.

cf cups my-external-api -p credentials.json   # short for create-user-provided-service
cf update-service my-db -p <new-plan>         # change a service plan
cf rename-service old-name new-name

Passing JSON inline works on Mac and Linux, but Windows quoting is different and easy to get wrong. Put the JSON in a file and pass the file path instead — it works the same in every terminal.

✅ Best Practice

After you bind a service, unbind one or change an environment variable, restage the app. It only reads its environment when it starts, and the CLI even prints a tip telling you to restage.

Restart, Restage, Scale and Environment Variables

Restart, restage and push sound alike. They are not, and picking the wrong one is why “I changed it but nothing happened” is such a common complaint.

CommandWhat it doesUse it whenDowntime?
cf restartStops all instances, then starts them with the existing buildThe app is stuck and you changed nothingYes, unless --strategy rolling
cf restageRebuilds the app from its last upload, then restarts itYou changed env variables, bindings, buildpack or stackYes, unless --strategy rolling
cf push / cf deployUploads new code, builds it and starts itYou changed the codeAvoid with rolling (push) or blue-green (deploy)
cf restart my-app --strategy rolling
cf restage my-app --strategy rolling
cf scale my-app -i 3              # more instances — no restart
cf scale my-app -m 1G             # more memory — restarts the app
cf set-env my-app LOG_LEVEL debug
cf unset-env my-app LOG_LEVEL
cf stop my-app
cf start my-app
cf rename old-app-name new-app-name

Routes are just as easy to change. Run cf domains to see your region’s shared domain, then map or unmap a hostname.

cf map-route my-app cfapps.eu10.hana.ondemand.com --hostname my-app-v2
cf unmap-route my-app cfapps.eu10.hana.ondemand.com --hostname my-app-v2

⚠️ Warning

cf set-env is a quick fix, not a configuration strategy. If the app belongs to an MTA, the next cf deploy applies the environment from your descriptors — and a value you set by hand can be overwritten. Put anything permanent in mta.yaml or an extension descriptor.

Deleting and Cleaning Up — Know the Risks First

Every command in this section asks for confirmation — unless you add -f. That flag exists for scripts. In a terminal at the end of a long day, it is how people delete the wrong thing.

Here is what each delete command really removes, rated by how hard it is to undo:

  • 🟢 Recoverable — redeploy and you lose nothing
  • 🟠 Disruptive — something breaks or configuration is lost, but you can rebuild it
  • 🔴 Permanent — data or credentials are gone for good
CommandRiskWhat you actually lose
cf delete my-app🟢The app. Its routes stay unless you add -r. Any values you set by hand with cf set-env go with it.
cf delete my-app -r🟢The app and its mapped routes
cf undeploy <mta-id>🟢The MTA’s apps. Its services stay unless you add the delete flags.
cf unbind-service my-app my-svc🟠The app’s access to that service — it fails as soon as it needs those credentials again
cf delete-service-key my-svc my-key🟠The key’s credentials. Postman, pipelines or external systems using them stop working.
cf delete-orphaned-routes🟠Every route in the space not mapped to an app or service — including any you kept on purpose
cf delete-service my-svc🔴The instance plus all its bindings and service keys. For an HDI container, the data. Recreating XSUAA means new credentials everywhere.
cf undeploy <mta-id> --delete-services --delete-service-keys🔴Every service in the MTA, databases included, and their keys
cf delete-space dev🔴The space and every app, service and route in it
cf delete-org my-org🔴The org and every space inside it

⚠️ Warning

The v8 change that catches people out: cf delete-service no longer stops at bindings. Older CLI versions refused to delete an instance that still had bindings. In v8 the delete goes through and takes the bindings and service keys with it — the confirmation prompt says so, so read it to the end.

The safest habit costs ten seconds.

✅ Best Practice

Before any 🔴 command, run its read-only partner first: cf services before cf delete-service, cf mta <mta-id> before cf undeploy, cf routes before cf delete-orphaned-routes, and cf target before all of them.

One last cleanup command for MTA users: cf purge-mta-config. If someone removed MTA apps with cf delete instead of cf undeploy, stale configuration entries stay behind, and this command removes them.

Power-User Extras

CommandWhat it does
cf help -aLists every command in your installed version
cf <command> --helpFull syntax and options for one command
CF_TRACE=true cf <command>Shows the raw API requests and responses — invaluable for strange errors (PowerShell: $env:CF_TRACE="true")
cf curl /v3/appsCalls the Cloud Foundry API directly and returns raw JSON
cf oauth-tokenPrints your current access token for Postman or scripts — treat it like a password
cf install-plugin <name>Installs a CLI plugin, such as multiapps

📝 Note

What is deliberately missing: commands for platform operators — creating quotas, service brokers, security groups, buildpacks, feature flags. On BTP, SAP runs that layer and customer users usually cannot run them. If you ever need one, cf help -a lists it.

At a Glance — CF CLI Commands Cheat Sheet

CommandOne-line summary
Log in and target
cf login -a <api> --ssoLog in to your BTP region with a one-time passcode
cf target -o <org> -s <space>Check or switch where your CF CLI commands will act
Deploy
cf push <app>Deploy one app from manifest.yml
mbt build + cf deploy <file>.mtarBuild and deploy a multi-target app — the BTP default
cf deploy -i <id> -a abortAbort a stuck MTA operation
Inspect
cf apps / cf app <app>State, instances and memory of your apps
cf org / cf org-quotaOrg details and quota limits (cf quota is an alias)
Troubleshoot
cf logs <app> --recentThe last log lines — usually the real error
cf events <app>Why the app stopped or restarted
cf env <app>Variables and service credentials — never share the output
cf ssh <app>Shell into a container (enable SSH and restart first)
Services
cf create-service / cf bind-serviceCreate a service instance and connect an app to it
cf create-service-keyCredentials for use outside Cloud Foundry
cf cupsWrap an external system as a bindable service
Lifecycle
cf restart vs cf restageRestart reuses the build; restage rebuilds it with new config
--strategy rollingRestart, restage or push without downtime
cf scale -i / -mInstances need no restart; memory does
Delete (read the prompt)
cf delete <app> -r🟢 App and routes — redeployable
cf delete-service🔴 Instance, bindings and keys — data can be lost
cf undeploy --delete-services🔴 The whole MTA including databases

One-page CF CLI command map grouped into log in, deploy, inspect, troubleshoot, services and delete, with risk dots on the delete commands

What to take away

Look back at the list and count the commands that actually deploy something. A handful, at most. Everything else inspects, explains or diagnoses.

That is the real shape of working on Cloud Foundry. Deploying is one command; understanding why it did not do what you expected is the job. The people who seem fast on BTP are not faster at typing cf deploy — they run cf logs --recent, cf events and cf env before they start guessing.

And the commands that can really hurt you are few. Learn those, respect -f, and read every confirmation prompt to the end. A cheat sheet makes you quick — knowing which commands cannot be undone is what keeps you trusted with production.

🔗 Continue Reading

SAP CAP — The Framework Behind Modern BTP Development — the app type you will most often deploy with cf deploy. SAP Fiori Deployment Using CTMS with CI/CD on SAP BTP — take these commands into a pipeline with proper transports. YAML — How It Works and When to Use It Over JSON — read and fix manifest.yml and mta.yaml with confidence. Linux Command Line — The Mental Model for Developers — the terminal habits that make every CLI, including cf, easier.