Files
gh-secondsky-sap-skills-ski…/references/cloud-operations.md
2025-11-30 08:55:22 +08:00

5.6 KiB

SAP HANA CLI - Cloud & BTP Operations

Source: https://github.com/SAP-samples/hana-developer-cli-tool-example

Commands for managing SAP HANA Cloud instances and SAP BTP integration.


BTP CLI Integration

The hana-cli integrates with SAP BTP CLI for cloud resource management.

Configure BTP Target

# Configure BTP CLI targeting
hana-cli btp

This sets up the connection to your BTP global account.

View BTP Information

# Display current BTP target
hana-cli btpInfo

List BTP Subscriptions

# List subscribed services
hana-cli btpSubs

HANA Cloud Instance Management

List All HANA Cloud Instances

hana-cli hanaCloudInstances

Start HANA Cloud Instance

# Start a stopped instance
hana-cli hanaCloudStart [instance]

Use Cases:

  • Resume development after break
  • Scheduled startup
  • Cost management (stop during off-hours)

Stop HANA Cloud Instance

# Stop running instance
hana-cli hanaCloudStop [instance]

Note: Stopping instances helps reduce costs. Trial instances auto-stop after inactivity.


Cloud Instance Types

HDI Instances

# List Cloud HDI instances
hana-cli hanaCloudHDIInstances

# UI version
hana-cli hanaCloudHDIInstancesUI

Schema Instances

# List Cloud schema instances
hana-cli hanaCloudSchemaInstances

# UI version
hana-cli hanaCloudSchemaInstancesUI

SBSS Instances

Service Broker Secure Store instances.

# List Cloud SBSS instances
hana-cli hanaCloudSBSSInstances

# UI version
hana-cli hanaCloudSBSSInstancesUI

Secure Store Instances

# List Cloud secure store instances
hana-cli hanaCloudSecureStoreInstances

# UI version
hana-cli hanaCloudSecureStoreInstancesUI

UPS Instances

User-Provided Service instances.

# List Cloud UPS instances
hana-cli hanaCloudUPSInstances

# UI version
hana-cli hanaCloudUPSInstancesUI

Cloud Connection

Using Service Keys

Connect to HANA Cloud using service keys:

# Interactive service key connection
hana-cli connectViaServiceKey

Cloud Connection File

{
  "VCAP_SERVICES": {
    "hana": [{
      "name": "hana-cloud",
      "credentials": {
        "host": "xxxxxxxx.hana.trial-eu10.hanacloud.ondemand.com",
        "port": "443",
        "user": "DBADMIN",
        "password": "SecurePass123!",
        "encrypt": true,
        "sslValidateCertificate": true
      }
    }]
  }
}

SSL Requirements

HANA Cloud requires SSL:

hana-cli connect \
  -n "instance.hanacloud.ondemand.com:443" \
  -u DBADMIN \
  --encrypt true

Cloud Shell Compatibility

The hana-cli works in cloud-based development environments:

SAP Business Application Studio

# Open BAS in browser
hana-cli openBAS

Google Cloud Shell

Full compatibility with GCP Cloud Shell.

AWS Cloud9

Full compatibility with AWS Cloud9.

Video Demo

Cloud shell usage: https://youtu.be/L7QyVLvAIIQ


Cloud Workflows

Development Instance Setup

  1. Create instance in SAP BTP Cockpit

  2. Generate service key

  3. Connect via hana-cli:

    hana-cli connectViaServiceKey
    
  4. Verify connection:

    hana-cli status
    hana-cli systemInfo
    

Cost Optimization

  1. Check instance status:

    hana-cli hanaCloudInstances
    
  2. Stop when not needed:

    hana-cli hanaCloudStop myinstance
    
  3. Start when needed:

    hana-cli hanaCloudStart myinstance
    

HDI Container in Cloud

  1. List cloud HDI instances:

    hana-cli hanaCloudHDIInstances
    
  2. Create container:

    hana-cli createContainer MY_APP
    
  3. Create users:

    hana-cli createContainerUsers MY_APP
    

CDS Bind for Cloud

Use CDS binding for secure cloud credentials:

Setup

# In your CAP project directory
cds bind --to hana --for hybrid

.cdsrc-private.json

{
  "requires": {
    "db": {
      "kind": "hana",
      "binding": {
        "type": "cf",
        "apiEndpoint": "[https://api.cf.eu10.hana.ondemand.com",](https://api.cf.eu10.hana.ondemand.com",)
        "org": "my-org",
        "space": "dev",
        "instance": "hana-hdi"
      }
    }
  }
}

Benefits

  • No local credential storage
  • Dynamic credential lookup
  • Works with rotated credentials
  • Most secure option

Tradeoff

Each command execution includes credential lookup, adding slight latency.


Troubleshooting Cloud Connections

Instance Not Responding

# Check if stopped
hana-cli hanaCloudInstances

# Start if needed
hana-cli hanaCloudStart myinstance

SSL Certificate Issues

# Ensure encryption enabled
hana-cli connect --encrypt true

# Custom trust store if needed
hana-cli connect --trustStore /path/to/DigiCertGlobalRootCA.crt

BTP Target Issues

# Reconfigure BTP
hana-cli btp

# Verify target
hana-cli btpInfo

Cloud Resources


*Reference: https://github.com/SAP-samples/hana-developer-cli-tool-example*