How-tos

Migrate an application from Azure to Bluemix

Share this post:

Bluemix is an implementation of IBM’s Open Cloud Architecture, leveraging Cloud Foundry to enable developers to rapidly build, deploy, and manage applications and services. Although Microsoft Azure, another popular PaaS platform, shares quite a few similarities with Cloud Foundry, several elements still need to be addressed when porting Microsoft Azure applications to IBM Bluemix.

This tutorial will take you step-by-step from creating a Node.js app on Azure and then migrating that app onto IBM Bluemix; it will also give you the key differences between Microsoft Azure and IBM Bluemix from a developer’s point of view. This application is a simple Node.js app and services are not discussed in this first tutorial.

Below is a screenshot of the migrated application:

Migrated application

Source code of this application is in the IBM-Bluemix/Migrate-Node-App project on GitHub.

Before Starting

There are a few things to be aware of when porting a Microsoft Azure application to IBM Bluemix:

  • The environment variables for service binding. In Bluemix, all the bound service credentials are stored in an environment variable named VCAP_SERVICES. However, for Microsoft Azure, the environment variables for service binding can be different depending on the services. To address this gap, the environment variables must be reconfigured so that they can be mapped correctly, and the original Microsoft Azure application needs to be modified before migrating to Bluemix.
  • Different sets of services. When porting an application to IBM Bluemix, you need to consider services. IBM Bluemix has a very big catalog of services from both IBM services and open source services. When porting your app to Bluemix, you need to consider the services available to you and configure the service within your app.
  • When porting your app to IBM Bluemix I recommend to add a Manifest.yml file where you declare the application setup (this will be covered in the steps below).
  • On Bluemix we are using Node version 4.2.6, but you have the flexibility to use the version you want; you just need to specify in the package.JSON file where Azure’s Node.js version 4.2.3 is used.

Following is a step-by-step process describing how to migrate a sample application from Microsoft Azure to IBM Bluemix. The sample Azure application, named MigrateNodeApp, is a Node.js application; it consumes a JSON Data file as the back-end data to retrieve the app data.

Migration Steps to Bluemix

First you will need to register and download some tools. Specifically you will need:

In order to migrate the app from Azure to Bluemix, you will need to make few small changes to the source code.

Step 1: Verify Node.js engine is specified

See the package.json file excerpt below:

{
"name": "NodejsStarterApp01",
"version": "0.0.1",
"auther": "Twana Dnaiel",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.13.2",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"ejs": "~2.3.3",
"express": "~4.13.1",
"morgan": "~1.6.1",
"serve-favicon": "~2.3.0"
},
"repository": {},
"engines": {
"node": "4.2.x"
}
}

Step 2: Add a manifest.yml file to your root of your application

The manifest.yml contains the application configuration that will be running on Bluemix (see Deploying with Application Manifests for more details). Our example manifest file is as follows:

applications:
- path: .
memory: 256M
instances: 1
domain: mybluemix.net
name: DeveloperNodeApp01
host: developernodeapp01
disk_quota: 1024M

Step 3: Connect to database (optional)

For our sample application, we are loading the data from a JSON file, but if your application is connected to a database and reads and writes to the database, then the environment variables must be reconfigured so that they can be mapped correctly. In Bluemix, all the bound service credentials are stored in an environment variable named VCAP_SERVICES. However, for Microsoft Azure, the environment variables for service binding can be different depending on the services. If you want to see working sample Node.js code with connection to a database, see Sample Node App with Cloudant.

Step 4: Navigate to the folder directory and push the app to Bluemix

Verify the name of the folder is the same name in which you have it named in your manifest file. For example, the sample web app is called MigrateNodeApp. Then run the following commands to login, navigate to your space on Bluemix, and push your app to Bluemix:

$ cd MigrateNodeApp ### Navigate to the application directory
$ cf login ### Login to Bluemix and navigate to your space
$ cf push MigrateNodeApp ### Push app to Bluemix

You’re done!

What’s next?

You should now be able to access your application in its staging domain xxxxxx.mybluemix.net. In my case, it is located in migratenodeapp.mybluemix.net. In the next post, we will bind a Cloudant database service to load the data instead of loading data from a JSON data file as in this post’s example. In the meantime, if you have any questions or need help, please contact me at @twanawebtech or leave a comment below.

References

Full-Stack Software Developer & Developer Advocate at IBM Cloud

More How-tos stories
May 3, 2019

Kubernetes Tutorials: 5 Ways to Get You Building Fast

Ready to start working with Kubernetes? Want to build your Kubernetes skills? The five tutorials in this post will teach you everything you need to know about how to manage your containerized apps with Kubernetes.

Continue reading

May 3, 2019

Using Portworx to Deploy and Manage an HA MySQL Cluster on IBM Cloud Kubernetes Service

This tutorial is a walkthrough of the steps involved in deploying and managing a highly available MySQL cluster on IBM Cloud Kubernetes Service.

Continue reading

May 2, 2019

Kubernetes v1.14.1 Now Available in IBM Cloud Kubernetes Service

We are excited to announce the availability of Kubernetes v1.14.1 for your clusters that are running in IBM Cloud Kubernetes Service. IBM Cloud Kubernetes Service continues to be the first public managed Kubernetes service to support the latest upstream versions from the community.

Continue reading