In this tutorial you will set up a cloud account on the SAP Cloud Platform through your YaaS project. You will then deploy your Tips micro service to the cloud and point your Storefront to it.
You will learn
In this tutorial you will learn how to deploy a micro service to the SAP Cloud Platform. As an example you will use the Tips micro service created in Extend the YaaS Storefront’s Functionality with a Micro Service tutorial. In order to deploy a micro service you will need to set up your Cloud Foundry Command Line interface and create a SAP Cloud Platform account. In the end you will run the micro service on the cloud.
Step 3: Subscribe to HCP, starter edition for cloud foundry services
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. If your package did not appear, log out and back in to the YaaS Builder, find your project, and you should see SAP Cloud Platform in your YaaS Project’s Menu on the left side of the page.
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 with a Micro Service, 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.
Run 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 (2)/yaasbite200.
Run 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 yourAppsName.cfapps.us10.hana.ondemand.com.
NOTE: The default SAP Cloud Platform 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://
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: yourAppsName.cfapps.us10.hana.ondemand.com. - 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.
Background Knowledge: You will get most from this tutorial if you already have basic knowledge of Node.js, Angular and Restangular. If you are not already familiar with them and would like to dive into the code, you can follow the provided links to start learning.
Software Requirements: Cloud Foundry CLI (Command line interface), Maven which we will download in this tutorial.
Getting Started with YaaS
Download and Run the Default YaaS Storefront
Extend the YaaS Storefront’s Functionality with a Micro Service