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 btpThis sets up the connection to your BTP global account.
View BTP Information
# Display current BTP target
hana-cli btpInfoList BTP Subscriptions
# List subscribed services
hana-cli btpSubsHANA Cloud Instance Management
List All HANA Cloud Instances
hana-cli hanaCloudInstancesStart 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 hanaCloudHDIInstancesUISchema Instances
# List Cloud schema instances
hana-cli hanaCloudSchemaInstances
# UI version
hana-cli hanaCloudSchemaInstancesUISBSS Instances
Service Broker Secure Store instances.
# List Cloud SBSS instances
hana-cli hanaCloudSBSSInstances
# UI version
hana-cli hanaCloudSBSSInstancesUISecure Store Instances
# List Cloud secure store instances
hana-cli hanaCloudSecureStoreInstances
# UI version
hana-cli hanaCloudSecureStoreInstancesUIUPS Instances
User-Provided Service instances.
# List Cloud UPS instances
hana-cli hanaCloudUPSInstances
# UI version
hana-cli hanaCloudUPSInstancesUICloud Connection
Using Service Keys
Connect to HANA Cloud using service keys:
# Interactive service key connection
hana-cli connectViaServiceKeyCloud 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 trueCloud Shell Compatibility
The hana-cli works in cloud-based development environments:
SAP Business Application Studio
# Open BAS in browser
hana-cli openBASGoogle 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
Create instance in SAP BTP Cockpit
Generate service key
Connect via hana-cli:
hana-cli connectViaServiceKeyVerify connection:
hana-cli status hana-cli systemInfo
Cost Optimization
Check instance status:
hana-cli hanaCloudInstancesStop when not needed:
hana-cli hanaCloudStop myinstanceStart when needed:
hana-cli hanaCloudStart myinstance
HDI Container in Cloud
List cloud HDI instances:
hana-cli hanaCloudHDIInstancesCreate container:
hana-cli createContainer MY_APPCreate 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",
"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 myinstanceSSL Certificate Issues
# Ensure encryption enabled
hana-cli connect --encrypt true
# Custom trust store if needed
hana-cli connect --trustStore /path/to/DigiCertGlobalRootCA.crtBTP Target Issues
# Reconfigure BTP
hana-cli btp
# Verify target
hana-cli btpInfoCloud Resources
- SAP HANA Cloud: https://help.sap.com/docs/hana-cloud
- SAP BTP: https://help.sap.com/docs/btp
- HANA Cloud Getting Started: https://developers.sap.com/group.hana-cloud-get-started-1-trial.html
*Reference: https://github.com/SAP-samples/hana-developer-cli-tool-example*