quick start

Apache OpenWhisk – Quick Start Guide

1. Upload a Function (Action)

Prerequisites

  • Install the OpenWhisk CLI (wsk).
  • Set your API host (OW_API_HOST=https://fnc.evrtng.cloud) and authentication key (OW_AUTH_KEY).

Steps to Upload a Function

Option 1: Using the CLI

  1. Write your function (e.g., in JavaScript, Python, or Java).
    Example (JavaScript – hello.js):
   function main(params) {
       return { message: "Hello, " + params.name + "!" };
   }
  1. Deploy the function as an action:
   wsk action create helloAction hello.js

(Replace helloAction with your function name and hello.js with your file.)

Option 2: Using a ZIP File (for Dependencies)

  1. Bundle dependencies (e.g., node_modules for Node.js).
  2. Compress the file and upload:
   zip -r action.zip *
   wsk action create myAction --kind nodejs:14 action.zip

2. Accessing & Invoking Your Function

Method 1: Synchronous Invocation (Blocking)

wsk action invoke helloAction --result --param name "World"

Output:

{
  "message": "Hello, World!"
}

Method 2: Asynchronous Invocation (Non-blocking)

wsk action invoke helloAction --param name "OpenWhisk"  

Check logs later using:

wsk activation logs 

Method 3: Expose as a Web API (Web Action)

  1. Make your function web-accessible:
   wsk action update helloAction --web true
  1. Get the public URL:
   wsk action get helloAction --url
  1. Access via HTTP GET/POST:
   curl "https://fnc.evrtng.cloud/api/v1/web//default/helloAction?name=User"

3. Managing & Monitoring Functions

List Actions

wsk action list

View Function Code

wsk action get helloAction

Check Execution Logs

wsk activation list --limit 5  # Show recent runs  
wsk activation logs   # See logs for a specific run  

Delete a Function

wsk action delete helloAction

Next Steps

  • Trigger Functions Automatically: Set up event triggers (e.g., database changes, HTTP requests).
  • Chain Functions: Use sequences to link multiple actions.
  • Deploy via CI/CD: Integrate with GitHub Actions or Jenkins.

Need help? Visit the Apache OpenWhisk Docs. 🚀