Trying to run .Net Core applications in SAP Cloud Foundry and SAP HANA XSA

SAP is now actively developing Cloud Foundry (CF) and has implemented it in the SAP Cloud Platform, as a core element of the cloud infrastructure. CF acts as a PaaS and allows you to run applications in an SCP environment. In this article we will tell you how to prepare CF for the release of your project into production (“Go Live” phase), as well as how to deploy applications in the Cloud Foundry SCP and HANA XSA environment. We'll look at examples and show you how to intelligently manage server computing resources while providing a controlled environment for applications to run.





IDE , Python, Java, JavaScript, Go. CF (runtime environment) . SAP CF HANA Platform, HANA XSA (XS Advanced Runtime). HANA XSA CF SAP SCP.





SAP SCP Cloud Application Programming Model (CAP) . SAP CAP CF.





CAP , back-end Java JavaScript, SqlLite. SAP SCP HANA Cloud , CDS (Core Data Services), .





  CF/XSA LINUX, Linux. Microsoft .NET Core , .NET HANA XSA.





.Net CF / XSA?





, buildpack, , , . CF/XSA, , .





  buildpack .





  buildpack , , . HANA XSA buildpack’, SAP, : nodejs (javascript), java. , CF, HANA XSA, : php, go, dotnet_core, ruby.





buildpack?





·  ,





·  , buildpack,





·  , .





  , HANA XSA , HANA XSA .





execution agent controller, XSA , cli . XSA/CF, help.sap.com (SAP HANA Developer Guide for XS Advanced Model), .





buildpack , , , shell script Linux, go.





buildpack Microsoft .Net Core Runtime 3.1 HANA XSA 2.0 SP4, : 





1.  .NET Core Runtime 3.1. c HANA XSA, Linux. .NET Core Runtime . dotnet Linux.





2.  zip, gzip ( ), . dotnet .NET Core Runtime.





3.  shell script, : compile, detect, release.





4.  zip ( zip), , 2, , 3.





5.  buildpack xs create-buildpack ( help.sap.com->SAP HANA Developer Guide for XS Advanced Model Create a PHP Buildpack for XS Advanced)





  buildpack, , Cloud Foundry . HANA XSA, CF, .





  buildpack compile, detect, release, .Net Core Runtime 3.1 HANA XSA 2.0 SP4.





· ompile HANA XSA (build) , appsettings.json, framework, assembly ..





   compile >>
#!/bin/bash
# bin/compile <build-dir> <cache-dir>

BUILD_DIR=$1
BIN_DIR=`dirname $0`
BUILD_PACK_DIR=`dirname ${BIN_DIR}`
echo "Extracting .NET runtime into..."
echo ${BUILD_DIR}
cd ${BUILD_DIR}
tar xzvf ${BIN_DIR}/../runtime/runtime.tgz
echo "Extracting .NET runtime Done."

      
      



, compile CF supply finalize, HANA XSA compile.





·Detect HANA XSA buildpack .





#!/bin/bash
# bin/detect <build-dir>
if [ -f $1/appsettings.json ];
    then exit 0
fi
exit 1

      
      



· Release HANA XSA , yaml, .





   detect >>

#!/bin/bash
# bin/detect <build-dir>
if [ -f $1/appsettings.json ];
    then exit 0
fi
exit 1

      
      



· Release HANA XSA , yaml, .





   release >>

#!/bin/bash
# bin/release

cat <<EOF
---
config_vars:
addons:
default_process_types:
  web: /bin/bash ./start.sh 

EOF

      
      



buildpack .Net Core Runtime 3.1. .





, zip, , , buildpack.





..





 





 





bin





bin\detect bin\compile bin\release





buildpack





runtime





runtime\runtime.tgz





.net core 3.1 runtime





HANA XSA ?





  HANA XSA XSA, .





  HANA XSA Multi-Host, HANA HANA XSA (. .).





HANA XSA Multi-Host Configuration
HANA XSA Multi-Host

HANA XSA Multi-Host HANA, HANA XSA.





Multi-Host XS_WORKER XS_STANDBY, Auto-Failover HANA XSA .





  HANA XSA Multi-Host, .





HANA XSA ?





HANA XSA Multi-Host, , . . , ?





  Linux, – Linux Control Groups (Cgroups). Cgroups, , Linux . , , . , - , , .





  Linux Cgroups, Go Live, HANA XSA.





  Linux Cgroups shell script, buildpack .Net Core Runtime 3.1.





   start.sh >>

#!/bin/bash


if [ -z "$CGNAME" ]
then
	echo "[ERR]Please check CGNAME to place cgroup name limits."
	exit 1
else
	echo "[OK] CGNAME is set to '$CGNAME'"
fi

if [ -z "$MemoryLimitInMB" ]
then
	echo "[ERR] Please check memory limit settings."
	exit 1
else
	echo "[OK] MemoryLimitInMB is set to '$MemoryLimitInMB'."
fi

if [[ ! $(sudo echo 0) ]]; then echo "[ERR] sudo rights for user '$USER' needed.";exit 1; else echo "[OK] sudo rights for user '$USER' exist"; fi

create_cgroup_for_space(){
	if [[ $(sudo mkdir /sys/fs/cgroup/memory/$CGNAME) ]]; then echo "[ERR] can not create cgroup with name '$CGNAME'."; exit 1; else echo "[OK] cgroup '$CGNAME' successfully created."; fi
}

if [[ ! $(sudo ls /sys/fs/cgroup/memory/$CGNAME 2>/dev/null) ]]
then 
	echo "[WRN] cgroup '$CGNAME' is not set."
	create_cgroup_for_space
else 
	echo "[OK] cgroup '$CGNAME' is set." 
fi

if [[ $(sudo sh -c "echo $MemoryLimitInMB > /sys/fs/cgroup/memory/$CGNAME/memory.limit_in_bytes") ]]
then
	echo "[ERR] Can not set memory limit for app."
	exit 1
else
	echo "[OK] Successfully set memory limit to '$MemoryLimitInMB'."
fi

ATTACH=`awk '/^__MS_DOT_NET_RUN__/ {print NR + 1; exit 0; }' $0`

tail -n+$ATTACH $0 > ./run.sh

_PID=`echo $$`

if [[ ! $(sudo sh -c "echo $_PID > /sys/fs/cgroup/memory/$CGNAME/tasks") ]]
then
	chmod +x ./run.sh && /bin/bash ./run.sh	
else
	echo "[ERR] Unable to start app"
	exit 1
fi

exit 0

__MS_DOT_NET_RUN__

#!/bin/bash

trap "exit" INT TERM ERR
trap "kill 0" EXIT

export ASPNETCORE_URLS="http://localhost:$VCAP_APP_PORT"
 
echo "ASPNETCORE_URLS: '$ASPNETCORE_URLS'";
 
# Getting runnable dll.
runtimeconfigs=($(ls *.runtimeconfig.json));
if [ ${#runtimeconfigs[@]} -gt 1 ] ;
then
    echo "Error! Found '${#runtimeconfigs[@]}' *.runtimeconfig.json files! Expecting only one. Files: '${runtimeconfigs[@]}'.'" 1>&2;
    exit 1;
fi;
 
if [[ ${#runtimeconfigs[@]} -eq 0 ]] ;
then
    echo "Error! Can't find *.runtimeconfig.json file!" 1>&2;
    exit 1;
fi;
 
exeFile=$(echo "${runtimeconfigs[0]//.runtimeconfig.json/}")
if [ -f $exeFile ]
then
    echo "starting '$exeFile'...";
    exec "./$exeFile" --urls $ASPNETCORE_URLS;
    exit;
fi
 
dllFile=$(echo "${runtimeconfigs[0]//.runtimeconfig.json/.dll}")
if [[ !(-e $dllFile) ]] ;
then
    echo "File '$dllFile' is not found." 1>&2;
    exit 1;
fi
 
exec ./dotnet $dllFile --urls $ASPNETCORE_URLS;

      
      



, HANA XSA , Linux HANA XSA. SAP (SAP Co-Innovation Lab). , .





  - , SAP Labs CIS








All Articles