How to do it...

We will login through IBM Cloud CLI and deploy a function following the as follows: steps. Exact outputs for these steps may differ slightly when you run these commands for the first time and further executions. 

  1. Execute ibmcloud login and enter the username and password as follows:
ibmcloud login

You should see an output as follows with further prompts:

  1. Enter the option number for us-south

You should see further response as:


If you have not updated credit card and using a lite account, you may see a different screen with lesser options.
  1. Run:
ibmcloud target –cf

There should be an organization with your email address. Select it.

  1. Install the cloud functions plug-in:
ibmcloud plugin install cloud-functions
  1. Create a file name hello.js with following contents:
function main(params) {
var name = params.name || 'World';
return {payload: 'Hello, ' + name + '!'};
}
I have used Node.js code as provided in IBM samples.
  1. Create hello action:
ibmcloud fn action create hello hello.js
  1. Invoke the function without passing parameters:
ibmcloud fn action invoke helloworld --blocking --result

You should see an output, as follows:

  1. Invoke action with parameters:
ibmcloud fn action invoke hello --blocking --result --param name Heartin

 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.77.63