Oracle by Example brandingCreating an Application in Oracle Application Container Cloud

section 0Before You Begin

This tutorial shows you how to create a JavaScript application and upload it to Oracle Application Container Cloud. This tutorial takes approximately 15 minutes to complete.

Background

The following image illustrates the integration of Oracle IoT Cloud Service and Oracle Mobile Cloud Service by using Oracle Application Container Cloud. This tutorial covers the bordered area.

Process to Integrate Oracle Mobile Cloud Service with Oracle IoT Cloud Service
Description of the illustration mcs_intg_1.png

What Do You Need?


section 1 Configure Oracle IoT Cloud Service

  1. On the Oracle IoT Cloud Service home page, under Applications, click Oracle IoT Asset Monitoring Application.
  2. Click Action action menu and then click Integration. On the Integrations page, click Add, and select Enterprise Application.
    Oracle IoT Asset Monitoring Application Integrations page
    Description of the illustration iot_intg_create.png
  3. In the Enterprise Application dialog box, enter the following values, and then click Create:
    • Name: AMContainerIntegration
    • Description: Integration for Asset Monitoring
    • URL: http://localhost
    • Note: You can enter a nonfunctional URL.

  4. On the Integrations page, select your integration and click Edit.
  5. On the Overview tab of the AMContainerIntegration page, enter your password in the File Protection Password and Confirm Password fields, and click Download Provisioning File.
    a section of the AMContainerIntegration page, where you can download the provisioning file after entering a file protection password
    Description iot_intg_view.png
  6. Save the AAAAAAGWZICA-54BQ-provisioning-file-apps.conf file.

section 2 Set Up the Oracle IoT Cloud Service JavaScript ECL

  1. Create a directory for your project files and name it node-server.
  2. In node-server, install JavaScript ECL with Node Package Manager (npm):
    npm install node-forge
    npm install iotcs-csl-enterprise-x.x.x.tgz
  3. To expose the JavaScript ECL API to Oracle Mobile Cloud Service, define a generic API:
    npm install express

section 3Implement the Application

In this section, you modify and examine the code of a JavaScript application for Oracle Application Container Cloud. This application uses JavaScript ECL to connect to Oracle IoT Cloud Service and implement the business functionality, and it uses the express module to expose the generic REST APIs.

  1. Download server.js and save it in the node-server directory. This file is your application.
  2. In a text editor where you can display line numbers, open server.js. At line numbers 9 and 10, replace the trustFile and trustPass values with the name of your provisioning file and its protection password, respectively. Save the changes.
    9 var trustFile = 'AAAAAAGWZICA-54BQ-provisioning-file-apps.conf';
    10 var trustPass = 'Changeit';
  3. To review the business functionality of the application, read the comments and examine the code sections after the comments, as shown in the following code snippet:
    1//exposes the defined APIs by adding express to the application
    2 var express = require('express');
    3 var app = express();

    Note: To review the code in a logical sequence, read the comments in the following order of line numbers: 75, 86, 104, 119, 24, 42, and 1.

  4. Test the code.
    node server.js

section 4Upload the Application to Oracle Application Container Cloud

  1. Copy the following items to the node-server directory:
    • server.js: The application file
    • node_modules: The directory, installed by npm, for the dependencies
    • AAAAAAGWZICA-54BQ-provisioning-file-apps.conf: The truststore file
    • manifest.json: The configuration information file for Oracle Application Container Cloud
  2. Compress the directory and name it node-server.zip.
  3. Sign in to your instance of Oracle Application Container Cloud.
  4. Click Create Application, and then click Node.
    The Create Application page, where you select the application platform
    Description of the illustration acc_appln_node.png
  5. On the Create Application page, in the Name field, enter iotcs-mcs-api-integration, select Upload Archive, click Browse, select node-server.zip, and click Create. The application begins deploying.
    Create a Node.js application form
    Description of the illustration node_appln_create.png
  6. Record the URL of the new application that is displayed after the deployment is completed. The URL is similar to https://iotcs-mcs-api-integration-v2-a210401.apaas.us6.oraclecloud.com/. You'll need this URL when you configure a connector in Oracle Mobile Cloud Service. Record the URL of the new application that is displayed after the deployment is completed. The URL is similar to https://iotcs-mcs-api-integration-v2-a210401.apaas.us6.oraclecloud.com/. You'll need this URL when you configure a connector in Oracle Mobile Cloud Service.

more informationWant to Learn More?