October 18, 2018 | Written by: and Prashanth Bhat


Categorized: How-tos | Mobile





Share this post:

Taking advantage of IBM Cloud Mobile Foundation Service

Mobile apps are the brand ambassadors of a company, delivering the intended business value in a secure, reliable, and innovative way. Developers strive to offer the most engaging experience to the users by adapting a continuous user feedback loop. In a traditional on-premise architecture, change requests traverse through multiple approval processes, resulting in long development, test, and release cycles. This inhibits app developers from quickly reacting to user feedback and continuously delivering app features.

Successful enterprises have adopted a two-pronged strategy by using Cloud as a hyper-scale feature delivery system, powered with agile and continuous delivery, while still relying on tried and tested on-premise Systems-Of-Records. The two—sometimes called fast IT and slow IT—are loosely coupled with a secure connectivity that has traceability and governance.

The IBM MobileFirst Platform Foundation powers many on-premise customers in more than 50 countries, delivering the best-of-the-best apps and serving a large number of users. IBM Cloud Mobile Foundation Service offers all the same capabilities available in on-premise MobileFirst Foundation, with the additional benefits of fully managed service with instant deployment and scale-out option. And that’s just the beginning.

IBM Cloud offers other services, such as DevOps for continuous integration, Bitbar for device testing, Watson for AI use cases, Monitoring, and so on. Developers can adopt a number of strategies to take advantage of Mobile Foundation Service and jumpstart their journey of delivering continuous innovation to its end users. Some of the capabilities include the following:

  • Develop and test apps on IBM Cloud and deploy to on-premise MobileFirst Platform Foundation
  • Develop, test, and deploy new apps on IBM Cloud
  • Migrate existing on-premise apps and deploy on IBM Cloud

The following sections provide steps to migrate an existing on-premise app in order to use the Mobile Foundation service and enable logging and tracing on the cloud

Migrating MobileFirst Platform on-premise apps to IBM Mobile Foundation Service on Cloud

Mobile Foundation v8 artifacts can be easily migrated to leverage Mobile Foundation Service on Cloud. For apps running on versions other than v8, refer to the migration cookbook to first migrate to v8. Moving an on-premise v8 app to IBM Cloud involves the following steps:

  1. Setting up a new Mobile Foundation Service instance.
  2. Moving the configuration data (e.g., apps, adapters, confidential clients, etc.).
  3. Updating the apps to point to the new Cloud Service instance.

1. Setting up a new Mobile Foundation Service Instance

Mobile Foundation Service is available under the “Mobile” section on the IBM Cloud catalog. You can select the region, org, and space and deploy the instance. Mobile Foundation Service offers three different service plans, allowing you to pick the one that suits your needs. IBM Cloud cost calculator can be used for an estimation of monthly costs. Refer to Steps 1 and 2 in getting started for help.

2. Moving the configuration data from on-premise to Cloud Instance

Moving from an on-premise setup to Mobile Foundation Service includes moving MobileFirst Application definition, Adapters, Runtime configuration, and Confidential Clients  (if any).

The following options are available to move these artifacts:

  • Using the MobileFirst REST APIs (for moving all MFP data)
  • Using the MobileFirst Administration Console (for individual application and adapters)
  • Using the mfpdev Command Line tool (for individual application and adapters)

This section will take you through the steps to move MobileFirst data using the REST API.

a. Export all the MobileFirst artifacts from your on-premise setup to a zip file using the API:

GET /management-apis/2.0/runtimes/runtime-name/export

For example:

curl -X GET -u username:password -o /Users/testuser/exportedArtifacts.zip http://host:port/mfpadmin/management-apis/2.0/runtimes/mfp/export/all

Where:

Username and password: The login details from your on-premise MobileFirst instance.
Host and port: Hostname/IP and port of your on-premise instance.
mfp: The runtime-name (if you have changed the default runtime then use that name).
exportedArtifacts.zip: The file name where all the artifacts are exported.

b. Extract the details ( URL, user, and password ) of your newly create Mobile Foundation instance:

i)   Log in to the IBM Cloud dashboard and navigate to your list of Cloud Foundry services.

ii)  Click on your Mobile Foundation service instance under the Cloud Foundry Services section of the dashboard.

iii) Select the Service credentials tab in the left navigation menu, and select View credentials.

iv)  Note down the URL, user, and password for your instance.

c. Import the zip file from the previous step onto your Mobile Foundation Service instance:

POST /management-apis/2.0/runtimes/runtime-name/deploy/multi

For example:

curl -X POST -u username:password -F file=@/Users/testuser/exportedArtifacts.zip http://bit.ly/2R6CQHk

Where:

https://mobilefoundation-server-host.mybluemix.net:443: The URL to your Mobile Foundation service instance (from Step b).
username and password: The user and password of your Mobile Foundation instance (from Step b).

You can log into the console by clicking on the Cloud Foundry service instance and viewing the imported apps and adapters. In order to transfer artifacts using CLI or admin console, please refer to “Transferring server-side artifacts to another server” and “Export and import of specific artifacts such as apps and adapters.”

Note: Your Mobile Foundation adapters might be connecting to on-premise backend to access resources. If these resources are not accessible for the Mobile Foundation service instance, then you can use Secure Gateway service on IBM Cloud to expose those endpoints. To do this, you will have to follow these steps:

  • Create an instance of Secure Gateway service on IBM Cloud.
  • Create a connection between Secure Gateway on IBM Cloud and on-premise by configuring the Secure Gateway client on the on-prem network.
  • Change your adapter to connect to the endpoints which are exposed via Secure Gateway.

This article provides the steps to create and set up a Secure Gateway instance and connect it to your on-premise back-end.

3. Updating the client apps to point to the new Cloud Instance

Client Apps will now have to point to the new service instance.

a. To update the client apps to point to the new cloud instance, open mfpclient.properties or mfpclient.plist in the Android or iOS application. Update the “wlServerHost,” “wlServerPort,” and “wlServerProtocol” to point to the Mobile Foundation server url. The server url can be obtained by clicking on the Service credentials tab in the Cloud Foundry service instance as specified in Step 2 (b).

b. Update your apps to use the latest MobileFirst Client SDKs. Download the latest MobileFirst Client SDKs, and upgrade your app to use the latest Client SDK before redistributing. Follow the steps of your platform to update to the latest SDK: Andriod, iOS, Cordova.

c. The apps need to be updated and distributed through the app store.

d. You can optionally choose to block the older versions (pointing to Mobile Foundation on-premise) and support only the latest version (which points to Mobile Foundation service), or you can continue with both versions for a period of time until all users update their client app. Refer to the docs for detailed steps.

Logging and tracing of Mobile Foundation Service Instances

Once migrated to IBM Cloud, some developers struggle to set up appropriate logging and tracing infrastructure, which is quite different from on-premise setups. The following section explains how to familiarize yourself for logging and tracing of your app.

Prerequisite: To execute the commands below, you need to have the IBM Cloud Command Line Tool installed. Download and install the IBM Cloud CLI. Log in with the instructions below

a. Connect to an API endpoint in your IBM Cloud region. For example, enter the following command to connect to the IBM Cloud US-South region:

ibmcloud api http://bit.ly/2pEpvLA

b. Log in to IBM Cloud with your IBMid:

ibmcloud login

c. Switch to the org and space where the Mobile Foundation instance is set up:

ibmcloud target -o <value> -s <value>

Logging for Mobile Foundation Service Instances 

IBM Cloud offers multiple ways of accessing application logs:

1. The first is using the command line:

a. The following displays the recent logs:

ibmcloud cf logs <appname> –recent

For example: ibmcloud cf logs mobilefoundation-serverapp –recent

b. Log in to the Cloud Foundry Application instance:

ibmcloud cf ssh <appname> [ -i instance_index ]

For example, ibmcloud cf ssh mfpserver –i 0

c. Navigate to logs directory:

cd logs

        You should be able to see the following log files:

./message-*.log

./ffdc/

d. Copy the logs from the Cloud Foundry Application to your local machine:

ibmcloud cf ssh <appname> -i 0 -c “cat /home/vcap/logs/file-name” > ./file-name

For example, ibmcloud cf ssh <appname> -i 0 -c “cat /home/vcap/logs/message.log” > ./message.log

2. The second method is to use the IBM Cloud console. In the overview, navigate to your app, click on its entry to open the details, and then go to Logs. Current logs are shown with the most recent at the bottom. On the upper right, you can search for an entry or filter by log type. Select Application (APP).

3. The IBM Log Analysis service offers access to the logs. In contrast to the first two, more historical logs from all the apps in a space are available. The logs can be accessed, searched, and visualized using a browser-based UI (Kibana dashboard). Using the IBM Cloud dashboard, navigate to App Name > Logs > View in Kibana view.

Applications running in the IBM Cloud generate diagnostic output (i.e., logs) that can be accessed without any additional service. Using the Log Analysis service, you can aggregate logs from various apps and retain them as long as needed. This allows you to analyze and troubleshoot more complex situations.

Log Analysis is found in the IBM Cloud Catalog in the DevOps category. Click on it and select the region, organization, and space to which you want to provision the service. This should be the same as for the app you are going to deploy in the next step. Once the correct values are set, click on Create. Choose the right plan based on your requirement.

For details, see this section in the Log Analysis documentation.

Enable tracing in Mobile Foundation Cloud Foundry App

1. Log in to the Cloud Foundry application instance that the Mobile Foundation service instance has created:

ibmcloud cf ssh <appname> [-i instance_index ]

2. Locate and edit the file /app/wlp/usr/servers/mfp/configDropins/overrides/tracespec.xml to add the MFP specific traces.

Note: The server.xml or tracespec.xml change will be lost on a restage or restart. It is only valid for the instance you ssh into, so you have to enable traces on all the instances of your application.

Refer to Tracing for Liberty for Java Cloud Foundry applications on IBM Cloud.

Continue your Cloud Journey:

#awvi,#IBMCloud

via IBM Cloud Blog https://ibm.co/2pQcNaA

October 18, 2018 at 11:09AM