Deploy NodeJS API Microservice on SAP BTP Cloud Foundry

Welcome to the Fifth Episode of the Series: Hello World OpenAI: Crafting Accurate ChatGPT-Like Custom Search for SAPUI5 Application. Till now we installed IDE, set up the environment, created a Secret Key for our OpenAI Account, tested the same using Postman, and created a NodeJs-based API Service for BTP-CF & successfully tested the same. So, in this episode, we will deploy this Microservice to SAP BTP Cloud Foundry.

You can check all the existing & upcoming blog posts of this series via the introduction blog post available below link-

Click here

Prerequisites

  • I am assuming that you have a Trial Account Setup for OpenAI and have created your Secret Key in the previous episode.
  • You have NodeJS & VS Code installed as shared in an earlier episode.
  • You have created the NodeJS-based API Service shared in the last episode[Link].
  • You have CF-CLI installed. [If not check the Setup Episode for Links]

Manifest File

We have all the code ready, written in the last episode[Link]. We will first need to create a Manifest File, a configuration file required for Deployment on SAP BTP-CF(Cloud Foundry).

Step 1: Create a New File: manifest.yml.

Step 2: Copy-paste the below snippet intoManifest.yml.

---
applications:
- name: openaiapi
  path: .
  buildpack: nodejs_buildpack
  memory: 256M

Note: name is the App name, and memory is the Size of the Application. (Allocated Memory)

 

Time to Deploy

Step 1: Open your SAP BTP Trail Account & open SubAccount

Step 2: Note down the API URL.

Step 3: Open the VS Code terminal, type cf api [cf API endpoint] and press enter.

 cf api https://api.cf.us10-001.hana.ondemand.com

 

Step 3: Open the terminal, type cf login, and enter.

cf login

Enter Email-Password and you will be logged in.

Step 4: Open data.json & clear this file (Delete the highlighted data for fresh deployment).

Step 5: Open the terminal, type cf push, and enter.

cf push

And the deployment will start.

We will finally end up with this.

This will show the Route/URL of the deployed microservice, its current state & other information. Congratulations, you have successfully deployed our NodeJss API Microservice.

Test our Deployed Service

We can test our service in Postman. Copy-paste the route/URL, choose GET Call, add the Auth, and click send. You should get Status 200 & Welcome Message.  Congratulations we have our service up & running.

Let’s Summarize

We created our Manifest File for our Microservice & deployed it on BTP Cloud Foundry. Further, we tested the same using the Postman Tool. That’s all for this episode, will meet you guys in Episode 6.

Next Episode : Epidosde 6

 

Scroll to Top