Quick-Start-Anleitung
Deployen Sie Ihre erste Serverless-Funktion in unter 5 Minuten. Keine Server, keine Konfiguration — nur Code.
CLI installieren
Laden Sie die OpenWhisk CLI (wsk) herunter, installieren Sie sie und konfigurieren Sie Ihren API-Host.
# Download wsk CLI from GitHub releases $ curl -L https://github.com/apache/openwhisk-cli/releases/latest -o wsk # Set API host $ wsk property set --apihost \ https://fnc.evrtng.cloud # Set auth key (from your dashboard) $ wsk property set --auth \ YOUR_AUTH_KEY
Schreiben Sie Ihre Funktion
Erstellen Sie eine Funktionsdatei. Die Funktion main() empfängt Parameter und gibt ein JSON-Ergebnis zurück.
// hello.js function main(params) { const name = params.name || 'World'; return { message: `Hello, ${name}!` }; }
Deployen
Erstellen Sie die Action auf der evrtng functions-Plattform.
$ wsk action create helloAction hello.js ok: created action helloAction # For dependencies: use a ZIP $ zip -r action.zip * $ wsk action create myAction \ --kind nodejs:18 action.zip
Aufrufen & Testen
Rufen Sie synchron für sofortige Ergebnisse auf oder exponieren Sie als Web Action für HTTP-Zugriff.
# Blocking invoke $ wsk action invoke helloAction \ --result --param name "evrtng" { "message": "Hello, evrtng!" } # Expose as Web Action $ wsk action update helloAction --web true $ wsk action get helloAction --url https://fnc.evrtng.cloud/api/v1/web/.../helloAction
Überwachen & Skalieren
Sehen Sie sich Logs und Aktivierungsverlauf an und lassen Sie OpenWhisk die Skalierung automatisch übernehmen.
# List recent activations $ wsk activation list --limit 5 # View logs for an activation $ wsk activation logs <ACTIVATION_ID> # List all your actions $ wsk action list
Cheat Sheet
# Action management $ wsk action create <name> file.js $ wsk action update <name> file.js $ wsk action invoke <name> --result $ wsk action get <name> $ wsk action delete <name> $ wsk action list # Pass parameters $ wsk action invoke <name> \ --param key "value" # Web Actions $ wsk action update <name> --web true $ wsk action get <name> --url # Sequences $ wsk action create mySeq \ --sequence fn1,fn2,fn3 # Monitoring $ wsk activation list $ wsk activation logs <id> $ wsk activation get <id>
