Run cf -v to see if you have the Cloud Foundry CLI installed. If not, download the Cloud Foundry CLI: Go to https://docs.cloudfoundry.org/cf-cli/install-go-cli.html, and install Cloud Foundry’s CLI. Run
cf from your command line to verify your installation.
Set the Cloud Foundry CLI’s endpoint to SAP’s HCP address, by running the command:
cf api https://api.cf.us10.hana.ondemand.com
Go to Builder. Choose the YaaS Project which you created in the Getting Started with YaaS tutorial to subscribe to the HCP, starter edition for cloud foundry services (beta) package. This package allows you to develop, deploy and run services and applications.
- Open your YaaS Projects Administration page.
- Click Subscription, select + Subscription, select the Beta Worldwide tab, and subscribe to the package called HCP, STARTER EDITION FOR CLOUD FOUNDRY SERVICES (BETA) in there.
Wait 10 seconds and your package will appear in Builder in your YaaS Project*. If your package did not appear, log out and back in to the YaaS Builder, find your project, and you should see SAP HANA Cloud Platform in your YaaS Project’s Menu on the left side of the page. Select the SAP HANA Cloud Platform menu and click Create to activate your HCP account. This will trigger the email mentioned in the next step.
You should now get an email from HCP, guiding you through steps to activate your HCP account.
NOTE: You can skip this step if you already have an HCP Account.
You can then log in using the command
cf login. After entering your credentials, your HCP Cloud foundry account will be ready to deploy to.
Familiarize yourself with the
manifest.yml file which is located on the root folder of your Tips Service in your folder
(2)/yaasbite200. This is the file that instructs your Cloud Foundry CLI where and how to deploy your war file.
NOTE: If you have skipped the tutorial Extend the YaaS Storefront’s Functionality, you can clone the Tips Micro Service with this command.
git clone https://github.com/SAP/yaas-getting-started-yaasbites.git
Ensure your deployment name is unique to you, by adjusting the name value in the file
manifest.yml to for example
yourNameTipsService. This will ensure that your application will not clash with other applications deployed to the same environment by other users.
mvn -v to confirm that you have maven installed. If not, follow instructions on Apache Maven Website, and confirm that
mvn -v then runs. Now build and package your micro service into a war file, by running the command
mvn clean package from the folder
Push the war file to the cloud, by running
cf push from the same location. This will use the information in
manifest.yml to guide the deployment.
NOTE: The default HCP settings require the secure, https protocol. Therefore you must use https for all calls to your deployed services and when accessing your website in the cloud @ https://
cf apps to check whether the war file was successfully deployed and started and note the URL where it is running. It should be something like
Now that your service has been deployed to the cloud, you could access it directly from your StoreFront. However, YaaS is all about security, so instead we should register this service in the YaaS Builder, so that instead, we can access it via the YaaS Security Proxy. To register your service on YaaS:
- Go to your YaaS Project’s page.
- Select Services, select + Service and here you need to add the URL to your service on HCP:
- Enter the other required fields and then click Save.
- Click the Deploy button and you will see a Generated Proxy URL which is the URL to your service on YaaS. Calls to this address will be checked by the YaaS Security framework and only if okay, passed along to your service.
NOTE: In order to access your service at the Generated Proxy URL you will need to acquire an Access Token. This is because all calls to a service on YaaS are secured. If you are interested to learn more about this please refer to YaaS Dev Portal.
Now that you have deployed your service to the cloud, you need to tell your StoreFront about it. Open the file
(1) site-config.js in
yaas-storefront/public/js/app/shared and modify the
baseUrl of the
tipsEndpoint to point to the Generated Proxy URL found given in the previous step, giving you something like the code below. Rebuild your storeFront with
grunt build, and restart the storefront with
npm start. Your storeFront should now be communicating with your deployed service. Open your Chrome developer tools to observe the REST traffic and confirm that this is the case.
// NEEDS_ADJUSTING : Define the end-point of your Tips Service e.g. http://localhost:8080
In this tutorial you learned how to deploy a micro service based on YaaS to the HANA Cloud Platform, and how to modify your storefront to communicate with it.