Orchestrate

Report an issue

Something wrong, out of date or unclear? Tell us. Corrections are prioritized over new topics. You don't need to sign in.

0 / 2000

Don't include personal or confidential company details. Reports are reviewed with AI assistance.

Set up for Unit 21: a BTP trial and command-line tools

Know what SAP's BTP trial and free tier give in November 2026, add the btp command-line tool, map your account and deploy one small app to Cloud Foundry.

Updated Nov 27, 2026
Foundational layer · 8 min read

The 60-second version

Unit 21 looks at SAP Business Technology Platform (BTP) the way an architect does: how accounts are organized, which runtimes and services exist, how they connect, and what they cost. To follow it, a learner needs a BTP account to look at and two command-line tools to work with it.

The course already gave you most of this. Unit 18 created a free BTP trial, and Unit 5 installed the Cloud Foundry tool (cf) and logged in. This setup adds one more tool, the btp CLI, which manages the account itself: subaccounts, regions, entitlements and users. Then it deploys one tiny app that reports where it runs.

As of 26 November 2026, SAP's documentation describes two free ways in:

  • The trial: free, for individuals, 90 days, deleted at the end, never for production or team work.
  • Free tier plans: free plans for many services inside a real enterprise account (Pay-As-You-Go or CPEA). Data can stay, and projects can move to production by switching to paid plans.

The course uses the trial. Setup takes 30 to 45 minutes and costs nothing.

Why it matters to the business

Almost every SAP extension, integration and AI service a company buys or builds lands in a BTP account. Calder Pumpworks, the course's fictional pump maker, will run its order-exception agent, its integration flows and its data products there. Who can create a subaccount, in which region, with which services, is a decision with cost, security and compliance attached.

Architects who have only seen BTP through slides tend to miss three things that the tools make obvious:

  • Accounts are a structure, not a login. A global account is the contract; subaccounts hold the actual work, each in one region. Where a subaccount lives is where its data lives.
  • Administration can be scripted. The btp CLI does in one line what takes several screens in the cockpit, and its output can be checked by a script. That is the basis for repeatable environments and audits.
  • Free has terms. The trial stops apps every night and deletes everything after 90 days. Free tier plans come with community support only and no service level agreement. Neither is a place to pilot with real data.

How SAP does it

SAP documents both offers on one page, Trial Accounts and Free Tier (read 26 November 2026):

Trial account Free tier plans
Who Anyone, self-registration Customers and partners with a Pay-As-You-Go or CPEA enterprise account
How long 90 days, in intervals of up to 30 days that extend when you sign in; suspended after 30 days without a sign-in A time span defined per service
Production Not allowed, nor team development Possible after upgrading to paid plans (not available for every service yet, Kyma included)
Support No service level agreement Community support only, no service level agreement
Limits 4 GB memory for apps, 8 GB instance memory, 10 routes, 40 services, 2 on-premise systems through the Cloud Connector; apps stop every day Per service plan, shown in SAP Discovery Center

Trials can be created in two Cloud Foundry regions, us10 (US East, on AWS) and ap21 (Singapore, on Azure), according to SAP's regions page. New trials can no longer be created in eu10 (Frankfurt); existing ones keep working.

For tools, SAP offers the cockpit (the web console), the btp CLI for account administration, the cf CLI for apps in Cloud Foundry, and a Terraform provider for automation. SAP's documentation shows the btp CLI and cf CLI working together on a trial, from creating a subaccount to listing the service marketplace.

What this unit adds

Item What it is Cost Used in
Your BTP trial (from Unit 18) The account you will map and deploy to Free, 90 days Every Unit 21 topic
cf CLI (from Unit 5) Deploys and manages apps in Cloud Foundry Free Runtimes, observability and deployment topics
btp CLI Manages global accounts, directories, subaccounts, entitlements and users Free The account model, security and automation topics
unit21/account_map.py Prints your account as a small map with the right cf endpoint Free The account model topic
unit21/hello-btp/ A tiny app that reports its org, space and memory limit Free Runtimes and observability topics
check_unit21.py Checks tools, logins, files and the trial clock Free Before every Unit 21 topic

Later Unit 21 topics may add the Terraform provider and Kubernetes tools; each says so when it needs them. Automating BTP with Terraform adds Terraform in an optional step.

Time and money

  • Time: 30 to 45 minutes, most of it installing the btp CLI and waiting for the first deployment.
  • Money: nothing. Both tools are free, and so is the trial.
  • The trial clock: 90 days from sign-up. If your Unit 18 trial has ended, create a new one; nothing in this setup depends on old content.
  • Don't start other clocks now. SAP says the Kyma environment on a trial has its own validity, and the Kyma free plan in an enterprise account is available once, for up to 30 days. Enable Kyma only when a topic asks.

Questions to ask

Ask IT before you start:

  • Does the company network allow SAP's BTP hosts (the cockpit, cli.btp.cloud.sap and the Cloud Foundry endpoints)? Is there a proxy I must configure?
  • May I install command-line tools on my laptop, or must I use SAP Business Application Studio in the browser?

Ask your BTP administrator or SAP when you plan real work:

  • Who in our company may create subaccounts, and in which regions?
  • Do we have free tier plans in our global account, and who may assign them?
  • Which of our subaccounts carry the "Used for production" flag?

Common misconceptions

  • "The trial and the free tier are the same thing." The trial is personal and deleted after 90 days. Free tier plans sit inside an enterprise account and can lead to production.
  • "The btp CLI and the cf CLI do the same job." The btp CLI manages the account. The cf CLI manages apps inside one Cloud Foundry org and space.
  • "A deployed trial app stays up." SAP stops trial apps every day; you restart them.
  • "My subaccount runs where I am." A subaccount runs in the region chosen at creation, wherever its users are.
  • "Free plans come with SAP support." SAP says free tier plans get community support only, with no service level agreement.

Key terms

All course terms, A to Z, in the glossary

  • Global account: the realization of a contract with SAP; it holds subaccounts, entitlements and quotas.
  • Subaccount: the unit where apps and services run, tied to one region.
  • Directory: an optional folder for grouping subaccounts, which can also manage entitlements for them.
  • Entitlement: permission to use a service plan, with a quota, assigned down to a subaccount.
  • btp CLI: SAP's command-line tool for account administration.
  • cf CLI: the Cloud Foundry command-line tool for deploying and managing apps.
  • Free tier plan: a free, limited service plan inside a consumption-based enterprise account.

Check yourself

Pick one answer for each question. The explanation appears after you choose.

1A partner suggests running Calder's three-month AI pilot on a learner's BTP trial to save money. What is the main objection?

Answer: D. SAP's documentation says a trial must not be used for production or team development, and it is deleted after 90 days. It does have Cloud Foundry, and new trials are offered in us10 and ap21, not Frankfurt.

2What separates free tier plans from the trial?

Answer: C. Free tier plans live in Pay-As-You-Go or CPEA enterprise accounts, keep data, and can usually be upgraded to paid plans. SAP gives them community support only and no service level agreement, and each service sets its own time span.

3Why does this unit add the btp CLI when Unit 5 already installed the cf CLI?

Answer: C. The cf CLI works inside one Cloud Foundry org and space. The btp CLI works one level up, on the global account, directories and subaccounts, which is what Unit 21's architecture topics are about.

4A Calder manager asks why the region of a subaccount matters. What is the best answer?

Answer: C. SAP's account model ties each subaccount to one region, the physical location of its apps, data and services. That makes region a data residency and latency decision, not a display setting.

5Which question should go to IT before learners install the Unit 21 tools?

Answer: D. Both tools talk to SAP's servers, and company proxies often block them. The other questions don't apply: the setup uses no customer data, needs no AI Units, and SAP documents the 90-day end.

6A learner deployed an app on the trial yesterday and finds it stopped this morning. What happened?

Answer: A. SAP's trial documentation says apps stop automatically each day for cleanup and must be restarted. Suspension only follows 30 days without a sign-in, and an expired CLI session doesn't stop apps.
Deep layer · 35 min read

Mental model: two tools, two levels

A BTP account has two levels that matter for this unit. The account level is the global account, its directories and subaccounts, regions and entitlements. The runtime level is what runs inside one subaccount, here a Cloud Foundry org with spaces and apps.

Each level has its own tool. The btp CLI talks to the account level; the cf CLI talks to one Cloud Foundry org. They use separate logins, and you need both to go from "I have an account" to "my app runs".

flowchart TB
  B[btp CLI] -->|btp login --sso| GA[Global account<br/>the contract]
  GA --> D[Directory<br/>optional]
  GA --> SA[Subaccount trial<br/>region us10]
  SA --> ORG[Cloud Foundry org]
  ORG --> SP[Space dev]
  SP --> APP[App hello-btp]
  C[cf CLI] -->|cf login -a endpoint| ORG

The region is the hinge between the two. The subaccount's region decides the Cloud Foundry API endpoint that cf must use. The account map you build in this setup reads the region from the btp CLI and prints the endpoint for you.

How it works

The btp CLI client and server

SAP's documentation describes the btp CLI as a client you install and a CLI server at SAP. The client sends each command to the server, which checks your login with an authorization server and passes the call to the platform services. Most new commands arrive through the server, so you rarely need a new client. SAP says each client version is supported for at least one year.

Commands follow one pattern: btp [OPTIONS] ACTION GROUP/OBJECT [PARAMS]. The action is a verb such as list, get, create or assign. The groups are accounts, security and services. So btp list accounts/subaccount lists subaccounts, and btp list accounts/entitlement lists entitlements and quotas.

Logging in, and what is stored

You log in to a global account, not a subaccount. SAP recommends btp login --sso, which opens a browser to sign in. The CLI then saves a session token in a configuration file:

System Configuration file
Windows C:\Users\<you>\AppData\Roaming\SAP\btp\config.json
macOS ~/Library/Application Support/.btp/config.json
Linux ~/.config/.btp/config.json

The session lasts at most 12 hours. After that, you log in again. btp target then narrows the default context to a directory or subaccount, so later commands don't need its ID.

Text for people, JSON for scripts

The btp CLI prints readable tables by default. SAP warns that this text isn't stable enough to parse: column widths and line breaks depend on the data. For scripts, SAP recommends --format json, which prints a stable structure with more fields. For subaccounts, SAP's example shows fields such as guid, displayName, region, subdomain, betaEnabled, usedForProduction and state. Your account map reads exactly those.

Deploying to Cloud Foundry with the Python buildpack

On Cloud Foundry, cf push uploads your folder. A buildpack turns it into something runnable. SAP's tips for Python apps on BTP point to the community Python buildpack, which, according to the Cloud Foundry documentation:

  • recognizes a Python app by a requirements.txt (or setup.py) file;
  • takes the Python version from runtime.txt, such as python-3.12.x for the newest 3.12 patch;
  • has no default start command, so you give one in the manifest, in a Procfile or with cf push -c;
  • expects the app to listen on the port in the PORT environment variable.

Two details make this more than a formality. First, the community buildpack's default Python line is 3.10.x, and its manifest gives 3.10 a deprecation date of 4 October 2026 (version 1.9.10, read 26 November 2026). The buildpack version installed on your BTP region may differ, but an app without runtime.txt can start on a version that is past its end of life. Second, SAP notes that without a memory setting the platform gives an app a default of 1 GB. On a trial with 4 GB in total, that matters.

Once running, every app can read VCAP_APPLICATION, a JSON environment variable with its name, org, space, memory limit and routes. The hello app shows it back to you.

Build it yourself: the btp CLI, an account map and one deployment

You will install the btp CLI, log in to your trial's global account, save its subaccounts as JSON and turn them into a small map. Then you will deploy a tiny app with cf and run the Unit 21 check. Steps 1, 2, 5 (with --sample), 8 and 10 work without any account.

flowchart LR
  A[btp login] --> B[subaccounts.json]
  B --> C[account_map.py]
  C -->|endpoint| D[cf login]
  D --> E[cf push hello-btp]
  E --> F[check_unit21.py]

Before you start: complete Set up your computer for this course, Set up for Unit 18 (your BTP trial) and Set up for Unit 5 (the cf CLI). This walkthrough doesn't repeat those steps.

What you need

  • Your SAP BTP trial from Unit 18, or a new one if it has ended. Only Steps 4, 6, 7 and 9 need it.
  • The cf CLI version 8 from Unit 5.
  • About 30 to 45 minutes. Everything is free.

Step 1: Open your course folder and turn on the virtual environment

  1. Open VS Code, choose File > Open Folder, and open orchestrate-course.

  2. Open a terminal: Terminal > New Terminal.

  3. If the prompt doesn't start with (.venv), turn it on:

    • Windows (PowerShell):

      .venv\Scripts\Activate.ps1
    • macOS / Linux:

      source .venv/bin/activate
  4. Create the folder for this unit:

    mkdir unit21

Run every command in this topic from the course folder unless a step says otherwise.

Step 2: Record your trial's start date

The check in Step 10 counts down your 90 days. It needs the date you started the trial.

  1. Open the trial cockpit at https://cockpit.hanatrial.ondemand.com/trial/ and sign in. If you don't remember the start date, use the date of your Unit 18 notes, or today if you create a new trial now.

  2. Open the .env file in your course folder and add one line (with your date):

    BTP_TRIAL_START=2026-11-20
  3. Save the file. This line is not a secret, but .env stays out of Git as before.

Step 3: Install the btp CLI

SAP offers an install script, a package manager and a manual download. The package managers are the simplest to keep up to date.

  • Windows (PowerShell):

    winget install SAP.btp --source winget
  • macOS (with Homebrew):

    brew install --cask btp
  • Linux: SAP's install script guides you through the install. Read it first if your company asks you to review scripts before running them:

    curl https://cli.btp.cloud.sap/btpcli-install.sh | bash

No package manager, or the script is blocked? Download the archive for your system from SAP Development Tools (https://tools.hana.ondemand.com, the btp CLI downloads), unpack it, and copy the btp program into a folder on your PATH. SAP suggests /usr/local/bin on macOS and Linux.

Then close the terminal, open a new one, turn on .venv again (Step 1) and run:

btp --version

What success looks like: one line naming the SAP BTP command line interface and its client version, such as 2.x.y. The number will differ; any version prints.

Step 4: Log in to your trial's global account

  1. Run:

    btp login --sso
  2. When asked for the CLI server URL, press Enter to accept https://cli.btp.cloud.sap/.

  3. Your browser opens. Sign in with the same SAP account you used for the trial in Unit 18.

  4. Back in the terminal, if you see more than one global account, pick your trial. A trial's global account usually has "trial" in its name or subdomain.

  5. Run btp with nothing after it. It shows the client version, your user and the current target.

What success looks like: the target shows your trial global account. A typical shape (yours will have your own names and IDs):

Current target:
  a1b2c3d4trial (global account, subdomain: a1b2c3d4trial-ga)

The login lasts up to 12 hours. When a later command says you aren't logged in, repeat this step.

Step 5: Save your subaccounts as JSON and map them

  1. Save the subaccounts of your global account as JSON:

    • Windows (PowerShell):

      btp --format json list accounts/subaccount | Out-File -Encoding utf8 unit21/subaccounts.json
    • macOS / Linux:

      btp --format json list accounts/subaccount > unit21/subaccounts.json
  2. In VS Code, create unit21/account_map.py, paste the code below and save:

"""Print your SAP BTP account as a small map: subaccounts, regions and the Cloud Foundry endpoint.

Run it from your course folder:
  python unit21/account_map.py --sample                 made-up trial, no account needed
  python unit21/account_map.py                          reads unit21/subaccounts.json
  python unit21/account_map.py --file some_other.json   reads another file in the same shape

The input is the JSON that `btp --format json list accounts/subaccount` prints.
It uses built-in Python only and changes nothing in SAP BTP.
"""
import argparse
import json
import re
import sys
from pathlib import Path

# Cloud Foundry API endpoints for the regions where SAP's documentation lists trial accounts
# (us10 and ap21; eu10 only for trials created before new eu10 trials stopped).
TRIAL_ENDPOINTS = {
    "us10": "https://api.cf.us10.hana.ondemand.com",
    "ap21": "https://api.cf.ap21.hana.ondemand.com",
    "eu10": "https://api.cf.eu10.hana.ondemand.com",
}

# A made-up trial in the shape btp prints (IDs shortened). Not a real account.
SAMPLE = {
    "value": [
        {
            "guid": "5f0c1e2a-0000-4000-8000-000000000001",
            "displayName": "trial",
            "globalAccountGUID": "9a7b6c5d-0000-4000-8000-000000000000",
            "parentGUID": "9a7b6c5d-0000-4000-8000-000000000000",
            "parentType": "ROOT",
            "region": "us10",
            "subdomain": "a1b2c3d4trial",
            "betaEnabled": False,
            "usedForProduction": "UNSET",
            "state": "OK",
            "stateMessage": "Subaccount created.",
        }
    ]
}


def region_key(region: str) -> str:
    """Turn a region value such as 'us10' or 'cf-us10' into its short key 'us10'."""
    match = re.search(r"[a-z]{2}\d{2}", (region or "").lower())
    return match.group(0) if match else ""


def looks_like_production(sub: dict) -> bool:
    """Course rule: a subaccount meant for production says so in intendedUse or in its name."""
    if sub.get("intendedUse"):                       # course field, not part of SAP's output
        return sub["intendedUse"].lower() == "production"
    return bool(re.search(r"\bprod", sub.get("displayName", "").lower()))


def main() -> int:
    parser = argparse.ArgumentParser(description="Map your SAP BTP subaccounts.")
    parser.add_argument("--sample", action="store_true", help="use a made-up trial instead of a file")
    parser.add_argument("--file", default="unit21/subaccounts.json", help="JSON from btp list accounts/subaccount")
    args = parser.parse_args()

    if args.sample:
        data, source = SAMPLE, "made-up sample (not a real account)"
    else:
        path = Path(args.file)
        if not path.exists():
            print(f"No file {path}. Run Step 5 first, or try: python unit21/account_map.py --sample")
            return 1
        try:
            raw = path.read_bytes()
            # Windows PowerShell 5.1 writes UTF-16 when you use '>'; accept both.
            text = raw.decode("utf-16") if raw[:2] in (b"\xff\xfe", b"\xfe\xff") else raw.decode("utf-8-sig")
            data = json.loads(text)
        except (json.JSONDecodeError, UnicodeDecodeError) as error:
            print(f"{path} is not valid JSON ({error}). Did you forget --format json?")
            return 1
        source = str(path)

    subs = data.get("value", []) if isinstance(data, dict) else []
    if not subs:
        print(f"Source: {source}\nNo subaccounts found. A new trial has one; check the global account in the cockpit.")
        return 1

    print(f"Source: {source}")
    print(f"Global account: {subs[0].get('globalAccountGUID', '?')}\n")
    print(f"{'Subaccount':<20} {'Region':<8} {'Subdomain':<22} {'State':<6} {'Production flag':<16} Beta")
    for sub in subs:
        print(f"{sub.get('displayName', '?'):<20} {sub.get('region', '?'):<8} {sub.get('subdomain', '?'):<22} "
              f"{sub.get('state', '?'):<6} {str(sub.get('usedForProduction')):<16} {sub.get('betaEnabled')}")

    print("\nCloud Foundry endpoint for cf login (known for trial regions only):")
    notes = 0
    for sub in subs:
        key = region_key(sub.get("region", ""))
        endpoint = TRIAL_ENDPOINTS.get(key)
        if endpoint:
            print(f"  {sub.get('displayName')}: {endpoint}")
        else:
            print(f"  {sub.get('displayName')}: not a trial region; copy the API endpoint from the subaccount overview")

    print("\nNotes:")
    regions = {region_key(s.get("region", "")) for s in subs}
    if len(regions) > 1:
        notes += 1
        print(f"  - Subaccounts sit in {len(regions)} regions ({', '.join(sorted(regions))}): "
              "data and apps live where the subaccount lives.")
    for sub in subs:
        name = sub.get("displayName", "?")
        if sub.get("state") != "OK":
            notes += 1
            print(f"  - {name}: state {sub.get('state')} ({sub.get('stateMessage')}).")
        if looks_like_production(sub):
            if sub.get("usedForProduction") in (None, "UNSET"):
                notes += 1
                print(f"  - {name}: meant for production but the 'Used for production' flag isn't set.")
            if sub.get("betaEnabled"):
                notes += 1
                print(f"  - {name}: beta features are on in a production subaccount; SAP advises against it.")
    if not notes:
        print("  - none")
    return 0


if __name__ == "__main__":
    sys.exit(main())
  1. Run it on the made-up sample first, then on your own file:

    python unit21/account_map.py --sample
    python unit21/account_map.py

What success looks like with --sample (made-up account; your own run shows your names, IDs and region):

Source: made-up sample (not a real account)
Global account: 9a7b6c5d-0000-4000-8000-000000000000

Subaccount           Region   Subdomain              State  Production flag  Beta
trial                us10     a1b2c3d4trial          OK     UNSET            False

Cloud Foundry endpoint for cf login (known for trial regions only):
  trial: https://api.cf.us10.hana.ondemand.com

Notes:
  - none

A trial normally has one subaccount. If your file shows a region the script doesn't know, copy the API endpoint from the subaccount's overview page in the cockpit instead.

Step 6: Look around the account with the btp CLI (optional)

These commands read and change nothing. They show what later Unit 21 topics build on:

btp get accounts/global-account
btp list accounts/available-region
btp list accounts/entitlement

The first shows your global account and its structure. The second lists the regions your global account may use, with their environments and infrastructure providers. The third lists the service plans you are entitled to and their quotas. Don't create or delete subaccounts in your trial yet; the account model topic later in Unit 21 explains the choices first.

Step 7: Log in with cf to the endpoint from your map

  1. Use the endpoint account_map.py printed:

    cf login -a https://api.cf.us10.hana.ondemand.com --sso
  2. Open the web address cf prints, sign in, copy the one-time passcode and paste it into the terminal.

  3. If asked, pick your trial org and the dev space.

  4. Run cf target to confirm.

What success looks like:

API endpoint:   https://api.cf.us10.hana.ondemand.com
user:           you@example.com
org:            a1b2c3d4trial
space:          dev

Step 8: Write the hello-btp app and run it on your computer

  1. Create the folder unit21/hello-btp and the four files below in it.

unit21/hello-btp/app.py:

"""A tiny web app that says where it runs: on your laptop, or in a Cloud Foundry space on SAP BTP.

Run locally:   python app.py        then open http://localhost:8080
On SAP BTP:    cf push              (from this folder; manifest.yml says how)
Built-in Python only, so the buildpack has nothing to install.
"""
import json
import os
from http.server import BaseHTTPRequestHandler, HTTPServer


def where_am_i() -> dict:
    """Read what Cloud Foundry tells every app about itself; on a laptop these are missing."""
    app = json.loads(os.environ.get("VCAP_APPLICATION", "{}"))
    if not app:
        return {"running_on": "your computer", "message": "Not on Cloud Foundry yet. Run cf push next."}
    return {
        "running_on": "Cloud Foundry on SAP BTP",
        "app": app.get("application_name"),
        "org": app.get("organization_name"),
        "space": app.get("space_name"),
        "cf_api": app.get("cf_api"),
        "memory_limit_mb": app.get("limits", {}).get("mem"),
        "instance": os.environ.get("CF_INSTANCE_INDEX"),
        "routes": app.get("application_uris"),
    }


class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        body = json.dumps(where_am_i(), indent=2).encode("utf-8")
        self.send_response(200)
        self.send_header("Content-Type", "application/json")
        self.send_header("Content-Length", str(len(body)))
        self.end_headers()
        self.wfile.write(body)

    def log_message(self, fmt, *args):   # one short line per request, which cf logs shows
        print(f"{self.command} {self.path} -> {args[1] if len(args) > 1 else ''}", flush=True)


if __name__ == "__main__":
    port = int(os.environ.get("PORT", "8080"))   # Cloud Foundry sets PORT; 8080 on your laptop
    print(f"Listening on port {port}", flush=True)
    HTTPServer(("0.0.0.0", port), Handler).serve_forever()

unit21/hello-btp/manifest.yml:

---
applications:
- name: hello-btp
  memory: 128M
  instances: 1
  random-route: true
  buildpacks:
  - python_buildpack
  command: python app.py

unit21/hello-btp/requirements.txt:

# No libraries needed: app.py uses built-in Python only.
# The file must exist so the Python buildpack recognizes the app.

unit21/hello-btp/runtime.txt:

python-3.12.x
  1. Run the app on your computer:

    cd unit21/hello-btp
    python app.py
  2. Open http://localhost:8080 in your browser. Then stop the app with Ctrl+C and go back: cd ../..

What success looks like:

{
  "running_on": "your computer",
  "message": "Not on Cloud Foundry yet. Run cf push next."
}

Step 9: Deploy it to your trial

  1. Go into the app folder and push:

    cd unit21/hello-btp
    cf push
  2. Wait one to three minutes. cf uploads the folder, the buildpack installs Python 3.12 and the app starts. The last lines show the app as running, with a routes line: a web address that starts with hello-btp- followed by random words.

  3. Open that address in your browser (add https:// in front).

  4. Go back to the course folder: cd ../..

What success looks like: the same JSON, now filled in by Cloud Foundry. The shape (your org, routes and API differ):

{
  "running_on": "Cloud Foundry on SAP BTP",
  "app": "hello-btp",
  "org": "a1b2c3d4trial",
  "space": "dev",
  "cf_api": "https://api.cf.us10.hana.ondemand.com",
  "memory_limit_mb": 128,
  "instance": "0",
  "routes": [
    "hello-btp-<random words>.<your region's app domain>"
  ]
}

Useful commands while it runs: cf apps lists your apps, cf logs hello-btp --recent shows the last log lines (one line per request), cf stop hello-btp stops it, and cf delete hello-btp removes it and frees its memory. The trial stops it every night anyway; cf start hello-btp brings it back.

Step 10: Run the Unit 21 check

This unit adds no Python libraries, so requirements.txt in your course folder doesn't change. The app's own requirements.txt in unit21/hello-btp is only for the buildpack.

  1. In the course folder, create check_unit21.py, paste the code below and save:
"""Check that your computer is ready for Unit 21 (SAP BTP as a platform).

Run it from your course folder:  python check_unit21.py
It uses built-in Python only. It asks cf and btp for their versions and whether you are logged in,
and reads the trial start date from .env. It changes nothing and never prints passwords or tokens.
"""
import datetime
import json
import os
import re
import shutil
import subprocess
import sys

problems = 0
TRIAL_DAYS = 90   # SAP's documented trial length


def report(ok: bool, label: str, fix: str = "", optional: bool = False) -> None:
    """Print one line: OK, MISSING (must fix) or LATER (optional for now)."""
    global problems
    if ok:
        print(f"  OK       {label}")
    elif optional:
        print(f"  LATER    {label}  ->  {fix}")
    else:
        problems += 1
        print(f"  MISSING  {label}  ->  {fix}")


def run(tool: str, *args: str):
    """Run a command-line tool and return (exit code, output), or (None, "") if it isn't installed."""
    path = shutil.which(tool)
    if path is None:
        return None, ""
    try:
        done = subprocess.run([path, *args], capture_output=True, text=True, timeout=60,
                              stdin=subprocess.DEVNULL,
                              env={**os.environ, "CF_COLOR": "false", "NO_COLOR": "1"})
    except (OSError, subprocess.TimeoutExpired) as error:
        return 1, str(error)
    return done.returncode, (done.stdout or "") + (done.stderr or "")


def first_version(text: str) -> str:
    match = re.search(r"(\d+)\.(\d+)\.(\d+)", text)
    return match.group(0) if match else ""


def env_value(name: str) -> str:
    """Read one line NAME=value from .env without extra libraries."""
    if not os.path.exists(".env"):
        return ""
    with open(".env", encoding="utf-8") as handle:
        for line in handle:
            if line.strip().startswith(name + "="):
                return line.split("=", 1)[1].strip().strip('"').strip("'")
    return ""


print("\n1. Python")
v = sys.version_info
report(v >= (3, 11), f"Python {v.major}.{v.minor}.{v.micro}",
       "the course needs Python 3.11 or newer (see Set up for Unit 17)")
report(sys.prefix != sys.base_prefix, "virtual environment is active", "activate .venv (Step 1)")

print("\n2. Cloud Foundry CLI (from Unit 5)")
code, out = run("cf", "version")
cf = first_version(out) if code == 0 else ""
report(cf.startswith("8."), f"cf CLI {cf or 'not found'}", "install the cf CLI v8 (Set up for Unit 5, Step 4)")
if cf:
    code, out = run("cf", "target")
    fields = {}
    for line in out.splitlines():
        if ":" in line:
            key, value = line.split(":", 1)
            fields[key.strip().lower()] = value.strip()
    org, space = fields.get("org", ""), fields.get("space", "")
    report(code == 0 and bool(org), f"cf logged in to org '{org}', space '{space}'" if org else "cf logged in",
           "cf login -a <endpoint from Step 5> --sso (Step 7)", optional=True)

print("\n3. SAP BTP command line interface (btp CLI)")
code, out = run("btp", "--version")
btp = first_version(out) if code == 0 else ""
report(bool(btp), f"btp CLI {btp or 'not found'}", "install the btp CLI, then open a new terminal (Step 3)")
if btp:
    code, out = run("btp", "--format", "json", "list", "accounts/subaccount")
    count = None
    if code == 0:
        try:
            count = len(json.loads(out).get("value", []))
        except (json.JSONDecodeError, AttributeError):
            count = None
    report(count is not None, f"btp logged in, {count} subaccount(s) visible" if count is not None else "btp logged in",
           "btp login --sso (Step 4); a session lasts at most 12 hours", optional=True)

print("\n4. Course folder")
for path, step in [(os.path.join("unit21", "account_map.py"), "5"),
                   (os.path.join("unit21", "hello-btp", "app.py"), "8"),
                   (os.path.join("unit21", "hello-btp", "manifest.yml"), "8"),
                   (os.path.join("unit21", "hello-btp", "requirements.txt"), "8"),
                   (os.path.join("unit21", "hello-btp", "runtime.txt"), "8")]:
    report(os.path.exists(path), path, f"create it (Step {step})")
runtime = os.path.join("unit21", "hello-btp", "runtime.txt")
if os.path.exists(runtime):
    with open(runtime, encoding="utf-8") as handle:
        pinned = handle.read().strip()
    report(pinned not in ("", "python-3.10.x") and pinned.startswith("python-3."),
           f"runtime.txt asks for {pinned or 'nothing'}",
           "write python-3.12.x; the buildpack's default 3.10 line is past its end of life (Step 8)")

print("\n5. Your deployment and trial clock")
if cf:
    code, out = run("cf", "app", "hello-btp")
    state = re.search(r"requested state:\s*(\w+)", out or "")
    label = f"hello-btp deployed ({state.group(1)})" if code == 0 and state else "hello-btp deployed"
    report(code == 0, label, "cf push from unit21/hello-btp (Step 9)", optional=True)
    if code == 0 and state and state.group(1).lower() == "stopped":
        print("           tip: trial apps stop every night; cf start hello-btp brings it back")
start = env_value("BTP_TRIAL_START")
try:
    started = datetime.date.fromisoformat(start) if start else None
except ValueError:
    started = None
if started:
    left = TRIAL_DAYS - (datetime.date.today() - started).days
    report(left > 0, f"BTP trial: {max(left, 0)} of {TRIAL_DAYS} days left (started {started})",
           "the trial is deleted after 90 days; create a new one (Set up for Unit 18)")
    if 0 < left <= 14:
        print("           tip: fewer than 14 days left; finish what you need or plan a new trial")
else:
    report(False, "BTP trial start date", "add BTP_TRIAL_START=YYYY-MM-DD to .env (Step 2)", optional=True)

print()
if problems:
    print(f"{problems} item(s) to fix. Fix them in order, then run this again.")
    sys.exit(1)
print("All set. Your computer is ready for Unit 21.")
  1. Run it:

    python check_unit21.py

What success looks like (from our test with stand-ins for a logged-in cf and btp; your versions, names and days differ):

1. Python
  OK       Python 3.13.18
  OK       virtual environment is active

2. Cloud Foundry CLI (from Unit 5)
  OK       cf CLI 8.18.4
  OK       cf logged in to org 'a1b2c3d4trial', space 'dev'

3. SAP BTP command line interface (btp CLI)
  OK       btp CLI 2.x.y
  OK       btp logged in, 1 subaccount(s) visible

4. Course folder
  OK       unit21/account_map.py
  OK       unit21/hello-btp/app.py
  OK       unit21/hello-btp/manifest.yml
  OK       unit21/hello-btp/requirements.txt
  OK       unit21/hello-btp/runtime.txt
  OK       runtime.txt asks for python-3.12.x

5. Your deployment and trial clock
  OK       hello-btp deployed (started)
  OK       BTP trial: 84 of 90 days left (started 2026-11-20)

All set. Your computer is ready for Unit 21.

LATER lines are fine for now: they mean you haven't logged in, deployed or recorded the date yet. MISSING lines must be fixed first. We ran this check without the tools (two MISSING lines, as expected) and with stand-ins that print cf and btp output in the documented shape; the btp version line shows 2.x.y because the stand-in's number isn't a real release.

Step 11: Save your work in Git

git add unit21 check_unit21.py
git commit -m "Set up Unit 21: btp CLI, account map and hello-btp"

unit21/subaccounts.json holds your account's IDs and subdomain. They aren't passwords, but if your repository is public, leave the file out: add unit21/subaccounts.json to .gitignore before the commit.

How the code works

Part What it does
account_map.py, TRIAL_ENDPOINTS The Cloud Foundry API endpoints SAP documents for trial regions
account_map.py, reading the file Accepts UTF-8 and the UTF-16 that Windows PowerShell 5.1 writes with >
account_map.py, notes Flags several regions, a state other than OK, and production subaccounts without the flag or with beta features on
looks_like_production A course rule: a name containing "prod", or the course field intendedUse used in the exercise
app.py, where_am_i Reads VCAP_APPLICATION and CF_INSTANCE_INDEX, which Cloud Foundry sets for every app
app.py, PORT Cloud Foundry tells the app which port to listen on; 8080 on your laptop
manifest.yml Name, 128 MB of memory (not the 1 GB default), one instance, a random route, the Python buildpack and the start command
runtime.txt Pins Python 3.12 instead of the buildpack's default 3.10 line
check_unit21.py Versions, logins, files and the trial countdown; MISSING must be fixed, LATER can wait

If something goes wrong

What you see What it means What to do
python is not recognized, or command not found Python isn't installed, or the terminal can't find it Windows: repeat the Python step of Set up your computer, then open a new terminal. macOS/Linux: use python3 until .venv is active
btp or cf is not recognized The terminal started before the install changed PATH, or the program isn't in a PATH folder Close the terminal, open a new one and try again. With a manual download, copy btp into a PATH folder (Step 3)
winget is not recognized The Windows Package Manager isn't installed Use the manual download in Step 3
brew: command not found Homebrew isn't installed on your Mac Use SAP's install script (curl https://cli.btp.cloud.sap/btpcli-install.sh | zsh) or the manual download
btp login times out, or cf push says Request error A company proxy or firewall blocks SAP's hosts Set HTTPS_PROXY (ask IT for the value) or try another network
btp says you are not logged in, or the check shows LATER btp logged in No login yet, or the 12-hour session ended Run btp login --sso (Step 4)
No trial global account offered at login You signed in with a different SAP account, or the trial was deleted Sign in with the account from Unit 18, or create a new trial
subaccounts.json is not valid JSON The command printed text, or an error went into the file Run Step 5 again with --format json and after logging in
cf login rejects your credentials Two-factor or single sign-on is in use Use cf login -a <endpoint> --sso (Step 7)
cf push says an app name is required, or deploys something other than hello-btp You ran it outside unit21/hello-btp, so cf didn't find the manifest cd unit21/hello-btp, then cf push again
cf push: staging fails with DEPENDENCY_MISSING_IN_MANIFEST The buildpack no longer offers the version in runtime.txt Write another supported line, such as python-3.13.x
cf push: memory or quota exceeded Other apps use the trial's 4 GB cf apps, then cf delete apps you no longer need
cf push ends with the app crashed The app didn't listen on PORT, or the start command is wrong Check command: python app.py in the manifest; run cf logs hello-btp --recent
The route shows 404 Not Found: Requested route ... does not exist The app is stopped (the trial stops apps daily) cf start hello-btp
Address already in use on your computer Another program uses port 8080 Stop it, or run with another port: PowerShell $env:PORT="8081"; python app.py, macOS/Linux PORT=8081 python app.py

Where this shows up in SAP

The same two levels appear in every customer landscape. An administrator, or a pipeline, uses the btp CLI or the Terraform provider to create subaccounts, assign entitlements and grant role collections. Developers use the cf CLI, or a deployment service, inside the spaces they are given. SAP's own workflow for setting up a trial from the command line uses exactly this split: btp for the global account and subaccount, cf once the Cloud Foundry org exists.

The JSON you saved is also how SAP recommends automating: the text output is for people, --format json for scripts. The account model, security and automation topics later in Unit 21 build on that.

Where AI fits

Nothing in this setup uses AI. Two things matter for later topics. An AI agent that administers BTP would call the same btp CLI or APIs and need the same roles as a person, so the authorization design comes first. And the AI services covered in SAP BTP foundations for AI builders and deploying AI apps on BTP are entitlements in the same account model you mapped here.

Production concerns

  • Logins on shared machines. The btp CLI keeps a session token in its configuration file for up to 12 hours. On a build server, use a separate technical login and clear it after the run, and never put passwords on the command line.
  • Verbose output. SAP warns that btp --verbose prints the content of files you pass as parameters. Don't use it where logs are kept.
  • The production flag. SAP says "Used for production" changes no configuration, but operators and SAP use it in incidents. Set it on production subaccounts, and keep beta features off there. SAP notes that once beta features are enabled in a subaccount they can't be disabled, so decide before you create it.
  • Memory is money. In paid accounts, Cloud Foundry memory is metered. Set memory in every manifest instead of taking the 1 GB default.
  • Runtime versions age. The Python buildpack's default line already passed its deprecation date. Pin a supported version and review it each quarter.

Pitfalls

  • Logging in to the wrong level. btp login is at the global account; cf login is at a Cloud Foundry endpoint. Mixing them up gives confusing "not found" errors.
  • Parsing the text output. It changes with the data. Use --format json.
  • Starting every free clock at once. Enabling Kyma or extra trials now starts timers you may need later.
  • Committing account details to a public repository. IDs and subdomains aren't secrets, but there is no reason to publish them.
  • Leaving apps running in a paid account. On a trial they stop nightly. In an enterprise account, they keep consuming memory.

Exercise

Draft Calder's first BTP account structure as data, and let the map judge it. The file feeds the account model topic later in Unit 21.

  1. In unit21, create calder_accounts_draft.json with this content. intendedUse is a course field, not part of SAP's output; everything else follows SAP's JSON shape:
{
  "value": [
    {"displayName": "calder-dev", "intendedUse": "development", "globalAccountGUID": "calder-ga-draft",
     "region": "us10", "subdomain": "calder-dev", "state": "OK", "usedForProduction": "UNSET", "betaEnabled": true},
    {"displayName": "calder-test", "intendedUse": "test", "globalAccountGUID": "calder-ga-draft",
     "region": "us10", "subdomain": "calder-test", "state": "OK", "usedForProduction": "UNSET", "betaEnabled": false},
    {"displayName": "calder-prod", "intendedUse": "production", "globalAccountGUID": "calder-ga-draft",
     "region": "us10", "subdomain": "calder-prod", "state": "OK", "usedForProduction": "UNSET", "betaEnabled": true},
    {"displayName": "calder-prod-eu", "intendedUse": "production", "globalAccountGUID": "calder-ga-draft",
     "region": "eu20", "subdomain": "calder-prod-eu", "state": "OK", "usedForProduction": "UNSET", "betaEnabled": false}
  ]
}
  1. Run the map on it:

    python unit21/account_map.py --file unit21/calder_accounts_draft.json
  2. Read the notes. Expected:

Notes:
  - Subaccounts sit in 2 regions (eu20, us10): data and apps live where the subaccount lives.
  - calder-prod: meant for production but the 'Used for production' flag isn't set.
  - calder-prod: beta features are on in a production subaccount; SAP advises against it.
  - calder-prod-eu: meant for production but the 'Used for production' flag isn't set.
  1. Fix the draft: set betaEnabled to false on calder-prod (SAP doesn't let you turn beta features off once a real subaccount has them, so this is decided before creation), and for both production subaccounts write a short decision in a new course field "calderNote" saying who sets the "Used for production" flag and when.
  2. Decide the region question: does Calder need calder-prod-eu (Europe, Netherlands) for CP20 Augsburg's data, or one US region for both company codes? Write one sentence in "calderNote" on calder-prod-eu, or remove it.
  3. Run the map again.

Done when the map prints no beta warning, every production subaccount carries a calderNote with your flag decision, and your region decision is written down in the file.

Check yourself

Pick one answer for each question. The explanation appears after you choose.

1Which tool and login do you need to list the subaccounts of your trial's global account?

Answer: A. The btp CLI works at the account level and logs in to a global account; btp list accounts/subaccount lists its subaccounts. The cf CLI only sees inside a Cloud Foundry org and has no account commands.

2Why does account_map.py read btp --format json output instead of the normal table?

Answer: D. SAP's documentation warns that column widths and line breaks in text output depend on the data, and recommends --format json for automation. The JSON is stable and carries more fields, such as usedForProduction.

3You push hello-btp without runtime.txt. What does the Python buildpack (version 1.9.10) do?

Answer: A. The buildpack's manifest sets 3.10.x as the default and gives it a deprecation date of 4 October 2026. Pinning python-3.12.x in runtime.txt keeps the app on a supported line.

4hello-btp crashes right after staging. The log shows it listening on 8080. What is the likely cause?

Answer: C. Cloud Foundry tells each app which port to listen on through PORT; an app fixed on another port fails its health check. The empty requirements.txt is fine because the app uses built-in Python only.

5Why does the manifest set memory: 128M?

Answer: C. SAP notes the platform assigns a default of 1 GB when no memory is set, and the trial has 4 GB for all apps. In paid accounts memory is metered, so setting it is also a cost control.

6Calder's draft has calder-prod with beta features on and the production flag unset. What do you change, and why?

Answer: A. SAP says beta features shouldn't be used in subaccounts of productive enterprise accounts, and the "Used for production" flag helps operators in incidents. The flag changes no configuration by itself, and beta can't be switched off once a subaccount has it, so it is settled in the draft.

7A build server runs btp CLI commands each night. Which practice fits SAP's guidance?

Answer: B. SAP warns that passwords on the command line can land in shell history and that --verbose prints files passed as parameters. A login session lasts up to 12 hours in a local file, so a shared machine needs its own login cleaned up after the run.
NextThe BTP account model: global accounts, directories and subaccountsDesign an SAP BTP account structure for development, test and production, decide who administers each level, and check Calder's model before anyone creates it.

Sources

Sign in to track your progress

We'll email you a one-time sign-in link. No password needed.

or

Tell us a little about you

Optional, every field. It helps us pitch answers to your questions at the right level and decide which topics to write next. It is never shown publicly, and you can change or clear it anytime from the account menu.

SAP areas you work in