Deploying Application on Bluemix using CLI

I found the Command Line Interface (CLI) of IBM Bluemix (rather IBM Cloud now) very useful. I have tried deploying a few test applications. This article is more for my reference to be able to deploy more application on my IBM Bluemix account. Elaborate steps are provided in the IBM Training on Bluemix and IBM User Manuals. This is a subset of that with just the commands I require.

To be able to use this feature, one needs having a IBM Bluemix account. Also, one needs installing IBM Bluemix CLI on their machine.

I provide here the necessary commands and a few troubleshooting steps in case they do not work.

On you terminal, the first step is to change the current directory to the directory where the Application is available. Next, one needs to login to IBM Bluemix. The command for that is as follows:

NOTE: The words in Italics are the parameters needed for the command or command option. These need to be replaced suitably.

bx login -u partha -o majumdar -s dev
  • The -u parameter should be provided with the User ID as defined in IBM Bluemix when the account was created.
  • The -o parameter should be provided with the Organisation as defined in IBM Bluemix when the account was created.
  • The -s parameter should be provided with the Space as defined in IBM Bluemix when the account was created. An account can have more than one Space. For example, I have created 3 spaces – one for Development, one for Testing and one for Production.
  • When this command executes, it will ask for the API end-point to  connect to. The API end-point is the region where your account belongs like US-South, United Kingdom, Sydney, etc.
  • it will ask for the password. The correct password for the account needs providing for the same.
  • If the credentials are accepted, it will display a list of Account IDs. The Account IDs are assigned internally by IBM Bluemix. These are long numbers. Against each Account ID, IBM Bluemix CLI provides numbers like 1., 2., etc. Choose the correct option.
If this command gives an error, check for the following:

  1. Whether the User ID is correct.
  2. Whether the Organisation is correct.
  3. If User ID and Organisation are correct and yet this command fails, then check whether the used User ID has been defined for the Organisation. In IBM Bluemix, it is possible to create more than one Organisation and each Organisation can have a different set of Users.
Login - Edited

Next, we need to bind the services required for the Application. To find the available services and the plans for the same, use the following command.

bx service offerings | grep -i Language
  • If you give this command without piping the output to grep, the command will output all the available services. This list would be very large and it will be difficult to go through the same. As I require the Language Translator, I scan the output for only these services.
  • This command will take some time before it produces the output.
  • This command is not expected to give any errors.
 Service Offerings
In this example, I am interested in the “language_translator” service. It is offered in standard*, advanced*, premium*, lite plans. The plan with an asterix (*) against them are paid plans.

Now, bind the service.

 bx service create language_translator lite "Language Translator-x1"
Provide the name of the service as found in the Service Offerings.
Provide the name of the plan as found in the Service Offerings.
Provide the name of your service as defined in the manifest file created by you.
The command can give an error only if the Service being binded is not available to you. It needs noting that all services are not available in all regions. Also, if the service being binded is a paid service, it needs to be subscribed before it can be binded.
Bind Service - Edited

Now, all you need to do is to push your application.

bx app push
This command can give a number of errors. However, these are out of scope of this article. The errors can arise because of the code written for the application. These errors are compilation errors. One would need to debug their program to rectify these errors.

The below screen shot provides the last bit of the output if the push of the application takes place successfully.

Push - Edited

 

Advertisements

This site uses Akismet to reduce spam. Learn how your comment data is processed.